from magento.brand_registry_sync import sync_brand_registry_for_connection


def test_brand_registry_sync_does_not_use_deploy_recovery_sleeps(monkeypatch):
    captured = {}

    class FakeOAuth:
        def __init__(self, **kwargs):
            captured.update(kwargs)

    class FakeApi:
        def __init__(self, _client):
            pass

        def sync_brand_registry(self, brands, *, replace_existing=True):
            return 200, {"ok": True, "brands": len(brands)}, None

    monkeypatch.setattr("magento.brand_registry_sync.MagentoOAuthClient", FakeOAuth)
    monkeypatch.setattr("magento.brand_registry_sync.MagentoRestClient", FakeApi)
    monkeypatch.setattr("magento.brand_registry_sync.build_brand_registry_payload", lambda _session: [])
    monkeypatch.setattr(
        "magento.brand_registry_sync.build_magento_oauth_kwargs",
        lambda _conn, timeout=60.0: {"timeout": timeout},
    )

    result = sync_brand_registry_for_connection(object(), {"id": 4}, replace_existing=True)

    assert captured["max_recovery_rounds"] == 1
    assert captured["timeout"] == 180.0
    assert result["ok"] is True
    assert result["brands_sent"] == 0
