test: retarget v2 coverage monkeypatch targets to definition modules after handler split (assertions unchanged)
This commit is contained in:
1 parent
3a72ed3847
commit
36ddc7a874
7 files changed
+45
-48
No files matched your search
@@ -387,7 +387,7 @@ class TodosAutomationLoopTestCase(_Base):
|
||||
def test_todos_update_generic_error_502(self):
|
||||
todo = self._todo()
|
||||
h = self._h(body={"title": "new"})
|
||||
with mock.patch("cloud.server._todo_update",
|
||||
with mock.patch("cloud.handler_automation._todo_update",
|
||||
side_effect=RuntimeError("db down")):
|
||||
h._todos_update("u1", "p1", todo["id"])
|
||||
self.assertEqual(self._last(h)[0], 502)
|
||||
@@ -509,7 +509,7 @@ class TodosAutomationLoopTestCase(_Base):
|
||||
|
||||
def test_auto_memory_run_extracted_audits(self):
|
||||
h = self._h(body={})
|
||||
with mock.patch("cloud.server._auto_process_due",
|
||||
with mock.patch("cloud.handler_identity._auto_process_due",
|
||||
return_value=[{"status": "extracted",
|
||||
"task_id": "t1"},
|
||||
{"status": "skipped",
|
||||
@@ -756,7 +756,7 @@ class OauthGatewayTestCase(_Base):
|
||||
h.path = ("/oauth/github/login?client_id=c"
|
||||
"&redirect_uri=https://example.com/cb")
|
||||
err = OAuthError("denied", reason="bad_client")
|
||||
with mock.patch("cloud.server.start_oauth_login",
|
||||
with mock.patch("cloud.handler_oauth.start_oauth_login",
|
||||
side_effect=err):
|
||||
h._oauth_login("/oauth/github/login")
|
||||
code, payload = self._last(h)
|
||||
@@ -767,7 +767,7 @@ class OauthGatewayTestCase(_Base):
|
||||
h = self._h()
|
||||
h.path = ("/oauth/github/login?client_id=c"
|
||||
"&redirect_uri=https://example.com/cb")
|
||||
with mock.patch("cloud.server.start_oauth_login",
|
||||
with mock.patch("cloud.handler_oauth.start_oauth_login",
|
||||
side_effect=ValueError("bad scope")):
|
||||
h._oauth_login("/oauth/github/login")
|
||||
self.assertEqual(self._last(h)[0], 400)
|
||||
@@ -784,7 +784,7 @@ class OauthGatewayTestCase(_Base):
|
||||
"redirect_uri": "https://example.com/cb"})
|
||||
h._authenticate = lambda: "u1"
|
||||
err = OAuthError("denied", reason="bad_client")
|
||||
with mock.patch("cloud.server.build_authorization_url",
|
||||
with mock.patch("cloud.handler_oauth.build_authorization_url",
|
||||
side_effect=err):
|
||||
h._oauth_bind_initiate("github")
|
||||
code, payload = self._last(h)
|
||||
@@ -795,7 +795,7 @@ class OauthGatewayTestCase(_Base):
|
||||
h = self._h(body={"client_id": "c",
|
||||
"redirect_uri": "https://example.com/cb"})
|
||||
h._authenticate = lambda: "u1"
|
||||
with mock.patch("cloud.server.build_authorization_url",
|
||||
with mock.patch("cloud.handler_oauth.build_authorization_url",
|
||||
side_effect=ValueError("bad scope")):
|
||||
h._oauth_bind_initiate("github")
|
||||
self.assertEqual(self._last(h)[0], 400)
|
||||
@@ -813,8 +813,8 @@ class OauthGatewayTestCase(_Base):
|
||||
def create_state(self, provider, redirect_uri, client_id=None,
|
||||
bind_user_id=None):
|
||||
return "st1"
|
||||
with mock.patch("cloud.server.OAuthStateStore", _Store), \
|
||||
mock.patch("cloud.server.build_authorization_url",
|
||||
with mock.patch("cloud.handler_oauth.OAuthStateStore", _Store), \
|
||||
mock.patch("cloud.handler_oauth.build_authorization_url",
|
||||
return_value="https://example.com/auth"):
|
||||
h._oauth_bind_initiate("github")
|
||||
code, payload = self._last(h)
|
||||
@@ -824,7 +824,7 @@ class OauthGatewayTestCase(_Base):
|
||||
def _finish_h(self, identity):
|
||||
h = self._h()
|
||||
h._oauth_clients = lambda provider: (None, None)
|
||||
patcher = mock.patch("cloud.server.handle_oauth_callback",
|
||||
patcher = mock.patch("cloud.handler_oauth.handle_oauth_callback",
|
||||
return_value=dict(identity))
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
@@ -864,7 +864,7 @@ class OauthGatewayTestCase(_Base):
|
||||
h = self._finish_h({"external_id": "ext-new"})
|
||||
with mock.patch.dict(os.environ,
|
||||
{"SUB2API_BASE_URL": "https://gw.example"}), \
|
||||
mock.patch("cloud.server._ensure_sub2api_key",
|
||||
mock.patch("cloud.handler_oauth._ensure_sub2api_key",
|
||||
side_effect=RuntimeError("gw down")):
|
||||
result = h._oauth_finish("github", "code", "st", "c", "r")
|
||||
self.assertTrue(result[1])
|
||||
@@ -888,8 +888,8 @@ class OauthGatewayTestCase(_Base):
|
||||
def __init__(self, db_path):
|
||||
self.conn = mock.Mock()
|
||||
self.conn.close.side_effect = RuntimeError("close down")
|
||||
with mock.patch("cloud.server.OAuthStateStore", _Store), \
|
||||
mock.patch("cloud.server.handle_oauth_callback",
|
||||
with mock.patch("cloud.handler_oauth.OAuthStateStore", _Store), \
|
||||
mock.patch("cloud.handler_oauth.handle_oauth_callback",
|
||||
return_value={"bind_user_id": uid,
|
||||
"external_id": "ext1"}):
|
||||
result = h._oauth_finish("github", "code", "st", "c", "r")
|
||||
@@ -1174,7 +1174,7 @@ class WebhookBrowserFullAutoTestCase(_Base):
|
||||
h = self._full_auto_h({"repo": "o/r"})
|
||||
with mock.patch.dict(os.environ, {"CODEX_GLOBAL_ADMINS": "u1",
|
||||
"FULL_AUTO_ENABLED": "1"}), \
|
||||
mock.patch("cloud.server._resolve_app_token",
|
||||
mock.patch("cloud.handler_fullauto._resolve_app_token",
|
||||
return_value=None):
|
||||
h._full_auto_execute("u1")
|
||||
code, payload = self._last(h)
|
||||
@@ -1189,7 +1189,7 @@ class WebhookBrowserFullAutoTestCase(_Base):
|
||||
from cloud.full_auto import FullAutoError
|
||||
with mock.patch.dict(os.environ, {"CODEX_GLOBAL_ADMINS": "u1",
|
||||
"FULL_AUTO_ENABLED": "1"}), \
|
||||
mock.patch("cloud.server.auto_config_plan",
|
||||
mock.patch("cloud.handler_fullauto.auto_config_plan",
|
||||
side_effect=FullAutoError(
|
||||
"bad plan", reason="bad")):
|
||||
h._full_auto_execute("u1")
|
||||
@@ -1205,9 +1205,9 @@ class WebhookBrowserFullAutoTestCase(_Base):
|
||||
from cloud.full_auto import FullAutoDenied
|
||||
with mock.patch.dict(os.environ, {"CODEX_GLOBAL_ADMINS": "u1",
|
||||
"FULL_AUTO_ENABLED": "1"}), \
|
||||
mock.patch("cloud.server.auto_config_plan",
|
||||
mock.patch("cloud.handler_fullauto.auto_config_plan",
|
||||
return_value=[{"step": "s1"}]), \
|
||||
mock.patch("cloud.server.run_plan",
|
||||
mock.patch("cloud.handler_fullauto.run_plan",
|
||||
side_effect=FullAutoDenied(
|
||||
"nope", reason="step_denied")):
|
||||
h._full_auto_execute("u1")
|
||||
@@ -1223,9 +1223,9 @@ class WebhookBrowserFullAutoTestCase(_Base):
|
||||
from cloud.full_auto import FullAutoError
|
||||
with mock.patch.dict(os.environ, {"CODEX_GLOBAL_ADMINS": "u1",
|
||||
"FULL_AUTO_ENABLED": "1"}), \
|
||||
mock.patch("cloud.server.auto_config_plan",
|
||||
mock.patch("cloud.handler_fullauto.auto_config_plan",
|
||||
return_value=[{"step": "s1"}]), \
|
||||
mock.patch("cloud.server.run_plan",
|
||||
mock.patch("cloud.handler_fullauto.run_plan",
|
||||
side_effect=FullAutoError(
|
||||
"boom", reason="plan")):
|
||||
h._full_auto_execute("u1")
|
||||
|
||||
Reference in new issue
Block a user