test: retarget v2 coverage monkeypatch targets to definition modules after handler split (assertions unchanged)
This commit is contained in:
1 parent
6e0660e97b
commit
741eb387ed
7 files changed
+45
-48
No files matched your search
@@ -22,6 +22,7 @@ from unittest import mock
|
||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(REPO_ROOT))
|
||||
|
||||
from cloud.handler_fullauto import _full_auto_installation_verified, _full_auto_parse_plan_params
|
||||
from cloud.server import (
|
||||
CloudControlPlaneHandler,
|
||||
RateLimiter,
|
||||
@@ -31,8 +32,6 @@ from cloud.server import (
|
||||
_classify_goal_followup,
|
||||
_deployed_commit,
|
||||
_default_executor,
|
||||
_full_auto_installation_verified,
|
||||
_full_auto_parse_plan_params,
|
||||
_make_rate_limiter,
|
||||
_read_agent_entries,
|
||||
_read_agent_entries_multi,
|
||||
@@ -311,23 +310,23 @@ class HelpersTestCase(_Base):
|
||||
|
||||
def test_installation_verified_config_none(self):
|
||||
c = _conn(self.db_path)
|
||||
with mock.patch("cloud.server.get_app_config",
|
||||
with mock.patch("cloud.handler_fullauto.get_app_config",
|
||||
return_value=None):
|
||||
self.assertFalse(_full_auto_installation_verified(c))
|
||||
c.close()
|
||||
|
||||
def test_installation_verified_config_error(self):
|
||||
c = _conn(self.db_path)
|
||||
with mock.patch("cloud.server.get_app_config",
|
||||
with mock.patch("cloud.handler_fullauto.get_app_config",
|
||||
side_effect=RuntimeError("config down")):
|
||||
self.assertFalse(_full_auto_installation_verified(c))
|
||||
c.close()
|
||||
|
||||
def test_installation_verified_repo(self):
|
||||
c = _conn(self.db_path)
|
||||
with mock.patch("cloud.server.get_app_config",
|
||||
with mock.patch("cloud.handler_fullauto.get_app_config",
|
||||
return_value={"id": 1}), \
|
||||
mock.patch("cloud.server.find_installation_for_repo",
|
||||
mock.patch("cloud.handler_fullauto.find_installation_for_repo",
|
||||
return_value={"id": 9}):
|
||||
self.assertTrue(
|
||||
_full_auto_installation_verified(c, "o/r"))
|
||||
@@ -335,9 +334,9 @@ class HelpersTestCase(_Base):
|
||||
|
||||
def test_installation_verified_any(self):
|
||||
c = _conn(self.db_path)
|
||||
with mock.patch("cloud.server.get_app_config",
|
||||
with mock.patch("cloud.handler_fullauto.get_app_config",
|
||||
return_value={"id": 1}), \
|
||||
mock.patch("cloud.server.list_installations",
|
||||
mock.patch("cloud.handler_fullauto.list_installations",
|
||||
return_value=[{"id": 9}]):
|
||||
self.assertTrue(_full_auto_installation_verified(c))
|
||||
c.close()
|
||||
@@ -391,7 +390,7 @@ class HelpersTestCase(_Base):
|
||||
def __init__(self, db_path):
|
||||
self.conn = mock.Mock()
|
||||
self.conn.close.side_effect = RuntimeError("down")
|
||||
with mock.patch("cloud.server.AuthStore", _FakeStore):
|
||||
with mock.patch("cloud.handler_support.AuthStore", _FakeStore):
|
||||
with _auth_store_cm(self.db_path) as store:
|
||||
self.assertIsNotNone(store)
|
||||
|
||||
@@ -475,7 +474,7 @@ class HandlerLeftoversTestCase(_Base):
|
||||
|
||||
def index_file(self, project_id, path, content, kind="file"):
|
||||
return "d1"
|
||||
with mock.patch("cloud.server.KBStore", _Store):
|
||||
with mock.patch("cloud.handler_identity.KBStore", _Store):
|
||||
h._kb_index("u1", "p1")
|
||||
code, payload = self._last(h)
|
||||
self.assertEqual(code, 201)
|
||||
@@ -539,7 +538,7 @@ class HandlerLeftoversTestCase(_Base):
|
||||
self.assertTrue(h._check_coordinator_reserve("u1", 1))
|
||||
|
||||
def test_oauth_login_close_failure_swallowed(self):
|
||||
from cloud.server import OAuthStateStore as _RealStore
|
||||
from cloud.handler_oauth import OAuthStateStore as _RealStore
|
||||
|
||||
class _ClosingProxy:
|
||||
def __init__(self, real):
|
||||
@@ -558,7 +557,7 @@ class HandlerLeftoversTestCase(_Base):
|
||||
h = self._h()
|
||||
h.path = ("/oauth/github/login?client_id=c"
|
||||
"&redirect_uri=https://x.test/cb")
|
||||
with mock.patch("cloud.server.OAuthStateStore", _Store):
|
||||
with mock.patch("cloud.handler_oauth.OAuthStateStore", _Store):
|
||||
h._oauth_login("/oauth/github/login")
|
||||
# Either 200 (login started) or 400 (no client config): both
|
||||
# pass through the close-failure swallow in the finally.
|
||||
|
||||
Reference in new issue
Block a user