feat: add one-click sync for website group bindings
This commit is contained in:
@@ -28,6 +28,7 @@ def db_session():
|
||||
connect_args={"check_same_thread": False},
|
||||
poolclass=StaticPool,
|
||||
)
|
||||
from app.models import admin_user, upstream, snapshot, webhook_config, notification_log, custom_page, website, revoked_token, upstream_key
|
||||
Base.metadata.create_all(bind=engine)
|
||||
TestingSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
db = TestingSessionLocal()
|
||||
@@ -116,6 +117,10 @@ def test_create_binding_runs_initial_sync(monkeypatch, client, db_session):
|
||||
class FakeClient:
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
def __enter__(self):
|
||||
return self
|
||||
def __exit__(self, *args):
|
||||
pass
|
||||
|
||||
def get_groups(self, endpoint):
|
||||
return [{"id": "target", "name": "Target group", "rate_multiplier": "1"}]
|
||||
@@ -204,6 +209,10 @@ def test_update_binding_runs_sync_after_save(monkeypatch, client, db_session):
|
||||
class FakeClient:
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
def __enter__(self):
|
||||
return self
|
||||
def __exit__(self, *args):
|
||||
pass
|
||||
|
||||
def get_groups(self, endpoint):
|
||||
return [{"id": "target", "name": "Target group", "rate_multiplier": "1"}]
|
||||
@@ -254,6 +263,10 @@ def test_update_binding_skips_write_when_disabled(monkeypatch, client, db_sessio
|
||||
class FakeClient:
|
||||
def __init__(self, **kwargs):
|
||||
raise AssertionError("should not write when binding is disabled")
|
||||
def __enter__(self):
|
||||
return self
|
||||
def __exit__(self, *args):
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(websites_router, "Sub2ApiWebsiteClient", FakeClient)
|
||||
monkeypatch.setattr("app.services.website_sync.Sub2ApiWebsiteClient", FakeClient)
|
||||
@@ -289,6 +302,10 @@ def test_create_binding_notifies_when_website_rate_changes(monkeypatch, client,
|
||||
class FakeClient:
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
def __enter__(self):
|
||||
return self
|
||||
def __exit__(self, *args):
|
||||
pass
|
||||
|
||||
def get_groups(self, endpoint):
|
||||
return [{"id": "target", "name": "Target group", "rate_multiplier": "1"}]
|
||||
@@ -333,6 +350,10 @@ def test_create_binding_does_not_notify_when_website_rate_unchanged(monkeypatch,
|
||||
class FakeClient:
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
def __enter__(self):
|
||||
return self
|
||||
def __exit__(self, *args):
|
||||
pass
|
||||
|
||||
def get_groups(self, endpoint):
|
||||
return [{"id": "target", "name": "Target group", "rate_multiplier": "2.2"}]
|
||||
|
||||
Reference in New Issue
Block a user