id
int64
0
1.29M
original_id
stringlengths
32
32
swhid
stringlengths
100
170
sha1
stringlengths
40
40
repo_name
stringlengths
2
45
repo_group
stringclasses
12 values
filepath
stringlengths
5
153
name
stringlengths
1
14.9k
type
stringclasses
3 values
code
stringlengths
7
2.12M
1,500
b9aa3700f797f35baedb21eb41327894
swh:1:cnt:35a18c85eca73f31b32a73ce444bf2ee5a9f8eee;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=144-158/
8aeabfc9cb76a5184d33decbf5b60fb532768ed1
growthbook
analytics
ldap-sync/tests/test_cli.py
_stub_sync_pipeline(monkeypatch: pytest.MonkeyPatch)
function
def _stub_sync_pipeline(monkeypatch: pytest.MonkeyPatch) -> None: """Wire up the minimum stubs to let a `sync` invocation reach `push()` without touching any real LDAP, gitiles or GrowthBook endpoint.""" from ldap_sync.applier import ApplyResult monkeypatch.setattr( "ldap_sync.cli._validate_and...
1,501
df303e822728ad9de33153d807b92919
swh:1:cnt:35a18c85eca73f31b32a73ce444bf2ee5a9f8eee;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=167-168/
8aeabfc9cb76a5184d33decbf5b60fb532768ed1
growthbook
analytics
ldap-sync/tests/test_cli.py
test_pushgateway_job_overridable_via_env::fake_push(metrics: Any, *, pushgateway_url: Any, job: str)
function
def fake_push(metrics: Any, *, pushgateway_url: Any, job: str) -> None: captured.append(job)
1,502
90fdbadff96ded405394742ba55a2985
swh:1:cnt:35a18c85eca73f31b32a73ce444bf2ee5a9f8eee;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=185-193/
8aeabfc9cb76a5184d33decbf5b60fb532768ed1
growthbook
analytics
ldap-sync/tests/test_cli.py
test_pushgateway_job_rejects_empty_value()
function
def test_pushgateway_job_rejects_empty_value() -> None: """An empty/whitespace `job` would produce a malformed Pushgateway URL path and the resulting error would be swallowed by push()'s catch-all, so reject it loudly at parse time instead.""" runner = CliRunner() env = {**VALID_ENV, "PROMETHEUS_PUS...
1,503
2824b3099520c5f18ecefa158c9df405
swh:1:cnt:35a18c85eca73f31b32a73ce444bf2ee5a9f8eee;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=196-211/
8aeabfc9cb76a5184d33decbf5b60fb532768ed1
growthbook
analytics
ldap-sync/tests/test_cli.py
test_report_prints_source_health_block(monkeypatch: pytest.MonkeyPatch)
function
def test_report_prints_source_health_block(monkeypatch: pytest.MonkeyPatch) -> None: """report stdout must include a `sources:` block with OK/FAIL for each of ldap, data_yaml, growthbook.""" monkeypatch.setattr( "ldap_sync.cli._validate_and_collect_growthbook", _MarkingCollector("growthbook"...
1,504
3419f7e7f2fae16cd43d3d1bfaa1ccb1
swh:1:cnt:35a18c85eca73f31b32a73ce444bf2ee5a9f8eee;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=44-52/
8aeabfc9cb76a5184d33decbf5b60fb532768ed1
growthbook
analytics
ldap-sync/tests/test_cli.py
_Raiser
type
# ---- exit code coverage ---- class _Raiser: def __init__(self, exc: Exception) -> None: self._exc = exc def __call__(self, *args: Any, **kwargs: Any) -> Any: raise self._exc
1,505
07de192baa5f409d29f6ae96d438f0c0
swh:1:cnt:35a18c85eca73f31b32a73ce444bf2ee5a9f8eee;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=55-59/
8aeabfc9cb76a5184d33decbf5b60fb532768ed1
growthbook
analytics
ldap-sync/tests/test_cli.py
_FakeBitu
type
class _FakeBitu: """Minimal Bitu snapshot that satisfies the CLI's target-state build.""" memberships_by_group: dict[str, set[str]] = {} uid_to_email: dict[str, str] = {}
1,506
fc807390da9edff3e57b20f18e7e86ae
swh:1:cnt:35a18c85eca73f31b32a73ce444bf2ee5a9f8eee;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=62-77/
8aeabfc9cb76a5184d33decbf5b60fb532768ed1
growthbook
analytics
ldap-sync/tests/test_cli.py
_MarkingCollector
type
class _MarkingCollector: """Stub collector that flips the source_healthy gauge to 1 for the given label and returns a configurable value.""" def __init__(self, source: str, return_value: Any = None) -> None: self._source = source self._return_value = return_value if return_value is not None...
1,507
6eec7e251df05ea4e21e5e3fe377d2c1
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=13-14/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
_b64(yaml_text: str)
function
def _b64(yaml_text: str) -> str: return base64.b64encode(yaml_text.encode()).decode()
1,508
f26ac72ad36ee56948bc5d1ea7e6d2ac
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=42-44/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
_FakeResponse::__init__(self, text: str, status: int = 200)
function
def __init__(self, text: str, status: int = 200) -> None: self.content = text.encode() self.status_code = status
1,509
19814a05f4e7d4f89a69403831061ff6
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=54-55/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
_FakeSession::__init__(self, response: _FakeResponse)
function
def __init__(self, response: _FakeResponse) -> None: self.response = response
1,510
16623448cf9ce2cf7d201f0b36e621a1
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=61-67/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
test_happy_path()
function
def test_happy_path() -> None: session = _FakeSession(_FakeResponse(_b64(_yaml_with_groups()))) out = fetch_posix_memberships(url="http://example", session=session) # type: ignore[arg-type] assert out["analytics-privatedata-users"] == frozenset({"alice", "bob"}) assert out["analytics-product-users"] ==...
1,511
d48c09a7655212284100b95483aedf70
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=77-80/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
test_missing_groups_key_aborts()
function
def test_missing_groups_key_aborts() -> None: session = _FakeSession(_FakeResponse(_b64("other: stuff\n"))) with pytest.raises(DataYamlError, match="missing a 'groups' mapping"): fetch_posix_memberships(url="http://example", session=session) # type: ignore[arg-type]
1,512
53bbec05f795fc8a60c99f6f27cd11c6
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=89-92/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
test_http_error_aborts()
function
def test_http_error_aborts() -> None: session = _FakeSession(_FakeResponse("", status=500)) with pytest.raises(DataYamlError): fetch_posix_memberships(url="http://example", session=session) # type: ignore[arg-type]
1,513
d118a76cac026896360c1872247ea208
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=108-118/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
test_missing_members_key_aborts()
function
def test_missing_members_key_aborts() -> None: yaml_text = ( "groups:\n" " analytics-privatedata-users:\n description: gating group\n" " analytics-product-users:\n members: []\n" " analytics-wmde-users:\n members: []\n" " deployment:\n members: []\n" ) ...
1,514
f89228d01759813cb23236ec14d10106
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=17-38/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
_yaml_with_groups(extra: dict[str, list[str]] | None = None)
function
def _yaml_with_groups(extra: dict[str, list[str]] | None = None) -> str: parts = [ "groups:", " analytics-privatedata-users:", " members:", " - alice", " - bob", " analytics-product-users:", " members:", " - alice", " an...
1,515
60be5e821f6465f5c6d3cae9df951dfd
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=46-50/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
_FakeResponse::raise_for_status(self)
function
def raise_for_status(self) -> None: if not (200 <= self.status_code < 300): import requests raise requests.HTTPError(f"HTTP {self.status_code}")
1,516
2d12a0def26318b7db77f48d74f54175
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=57-58/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
_FakeSession::get(self, url: str, *, timeout: object = None)
function
def get(self, url: str, *, timeout: object = None) -> _FakeResponse: return self.response
1,517
fd1b97d613b220d0da4e0a65a519720e
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=70-74/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
test_missing_required_group_aborts()
function
def test_missing_required_group_aborts() -> None: yaml_text = "groups:\n analytics-privatedata-users:\n members: [alice]\n" session = _FakeSession(_FakeResponse(_b64(yaml_text))) with pytest.raises(DataYamlError, match="missing required group"): fetch_posix_memberships(url="http://example", sess...
1,518
e087f7f254497d45b607b32532ddb694
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=83-86/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
test_non_base64_aborts()
function
def test_non_base64_aborts() -> None: session = _FakeSession(_FakeResponse("not base64 #@$")) with pytest.raises(DataYamlError): fetch_posix_memberships(url="http://example", session=session) # type: ignore[arg-type]
1,519
6f9c4e26eed578bbaed44566a1734633
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=95-105/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
test_non_list_members_aborts()
function
def test_non_list_members_aborts() -> None: yaml_text = ( "groups:\n" " analytics-privatedata-users:\n members: alice\n" " analytics-product-users:\n members: []\n" " analytics-wmde-users:\n members: []\n" " deployment:\n members: []\n" ) session = _Fa...
1,520
2c0211df39eb46b25e33169bfb5eedc7
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=121-131/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
test_null_member_aborts()
function
def test_null_member_aborts() -> None: yaml_text = ( "groups:\n" " analytics-privatedata-users:\n members:\n - alice\n -\n" " analytics-product-users:\n members: []\n" " analytics-wmde-users:\n members: []\n" " deployment:\n members: []\n" ) ...
1,521
a6950ab77a52c1a0216e295a6d9d8171
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=134-144/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
test_non_string_member_aborts()
function
def test_non_string_member_aborts() -> None: yaml_text = ( "groups:\n" " analytics-privatedata-users:\n members:\n - alice\n - 42\n" " analytics-product-users:\n members: []\n" " analytics-wmde-users:\n members: []\n" " deployment:\n members: []\n" ...
1,522
0a7f938903c58ee4a5de6177b9539b19
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=41-50/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
_FakeResponse
type
class _FakeResponse: def __init__(self, text: str, status: int = 200) -> None: self.content = text.encode() self.status_code = status def raise_for_status(self) -> None: if not (200 <= self.status_code < 300): import requests raise requests.HTTPError(f"HTTP {sel...
1,523
c2694067def3ca663270b00e2e9e907d
swh:1:cnt:fa380dcb8c4086c9a7117ae2862ff049d35f6e85;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=53-58/
f23122122b46843af2bc0bcf35f0ba1a98ff8729
growthbook
analytics
ldap-sync/tests/test_data_yaml_collector.py
_FakeSession
type
class _FakeSession: def __init__(self, response: _FakeResponse) -> None: self.response = response def get(self, url: str, *, timeout: object = None) -> _FakeResponse: return self.response
1,524
d1434007e6a620565e1631ce42e052f7
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=16-36/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
_FakeResponse
type
class _FakeResponse: def __init__( self, *, status_code: int = 200, json_data: dict[str, Any] | None = None, ): self.status_code = status_code self._json = json_data self.content = b"x" if json_data is not None else b"" def json(self): if self...
1,525
7cef192ff1bc89e5148101e486aedf8c
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=66-189/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
TestPagination
type
# ---- pagination ---- class TestPagination: def test_single_page(self) -> None: session = _FakeSession( [ _FakeResponse( json_data={ "members": [{"id": "1"}, {"id": "2"}], "count": 2, "...
1,526
2821781f91973f87f97899a26848e615
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=39-55/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
_FakeSession
type
class _FakeSession: """Scriptable Session: pop responses off `responses` per request.""" def __init__(self, responses: Iterable[_FakeResponse]): self._responses = list(responses) self.calls: list[tuple[str, str, dict[str, Any] | None, dict[str, Any] | None]] = [] self.auth = None ...
1,527
2febc1a69fd5603fffcc0f45dc7cb95c
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=17-25/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
_FakeResponse::__init__( self, *, status_code: int = 200, json_data: dict[str, Any] | None = None, )
function
def __init__( self, *, status_code: int = 200, json_data: dict[str, Any] | None = None, ): self.status_code = status_code self._json = json_data self.content = b"x" if json_data is not None else b""
1,528
026325ebc4f02661e773104b770ce713
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=70-85/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
TestPagination::test_single_page(self)
function
def test_single_page(self) -> None: session = _FakeSession( [ _FakeResponse( json_data={ "members": [{"id": "1"}, {"id": "2"}], "count": 2, "total": 2, "hasMore": False...
1,529
d4d456e6a2395d912c3a0614f2132a55
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=114-139/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
TestPagination::test_total_mutation_retries_then_aborts(self)
function
def test_total_mutation_retries_then_aborts(self) -> None: """Pass 1 mismatch, pass 2 also mismatches → abort.""" session = _FakeSession( [ _FakeResponse( json_data={ "members": [{"id": str(i)} for i in range(100)], ...
1,530
96851c45a95ca762a5e7f9c8cfbaeaab
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=202-207/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
test_http_error_wrapped()
function
def test_http_error_wrapped() -> None: """Non-auth HTTP errors raise GrowthBookAPIError (not raw requests.HTTPError).""" session = _FakeSession([_FakeResponse(status_code=500)]) with pytest.raises(GrowthBookAPIError) as exc_info: _client(session).list_members() assert not isinstance(exc_info.val...
1,531
0e169bd8629b5863fedb71f028995149
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=214-215/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
test_network_error_wrapped::raise_conn_error(*args: Any, **kwargs: Any)
function
def raise_conn_error(*args: Any, **kwargs: Any) -> Any: raise requests.ConnectionError("simulated")
1,532
a2700a5d2fc8a1e1a141a8542cdc177f
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=222-232/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
test_update_member_role_posts_member_envelope()
function
# ---- update_member_role ---- def test_update_member_role_posts_member_envelope() -> None: session = _FakeSession([_FakeResponse(json_data={"updatedMember": {}})]) c = _client(session) c.update_member_role("m1", {"role": "readonly", "projectRoles": []}) method, url, _params, body = session.calls[0] ...
1,533
ed23772ec1d3beead0d672c6d389edd5
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=27-30/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
_FakeResponse::json(self)
function
def json(self): if self._json is None: raise ValueError("no json") return self._json
1,534
155b14340856fa0ad8e30345d9f8b207
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=32-36/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
_FakeResponse::raise_for_status(self)
function
def raise_for_status(self): if 400 <= self.status_code < 600: err = requests.HTTPError(f"HTTP {self.status_code}") err.response = self raise err
1,535
e30f3fca1ddd6d9375e0b7c3935d3d90
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=48-52/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
_FakeSession::request(self, method, url, *, params=None, json=None, timeout=None)
function
def request(self, method, url, *, params=None, json=None, timeout=None): self.calls.append((method, url, params, json)) if not self._responses: raise AssertionError(f"unexpected extra request: {method} {url}") return self._responses.pop(0)
1,536
80d97d25c22b27ffb54a8fb81377833f
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=42-46/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
_FakeSession::__init__(self, responses: Iterable[_FakeResponse])
function
def __init__(self, responses: Iterable[_FakeResponse]): self._responses = list(responses) self.calls: list[tuple[str, str, dict[str, Any] | None, dict[str, Any] | None]] = [] self.auth = None self.headers: dict[str, str] = {}
1,537
8fa6ee4d358d509dd5f65c9ef9d80cfd
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=54-55/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
_FakeSession::mount(self, prefix, adapter)
function
def mount(self, prefix, adapter): pass
1,538
26b0f64b57f119b3274e49d5c4606093
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=58-63/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
_client(session: _FakeSession)
function
def _client(session: _FakeSession) -> GrowthBookClient: return GrowthBookClient( base_url="https://gb.example/api/v1", api_key="secret", session=session, # type: ignore[arg-type] )
1,539
2fee364210b924d5d921a230a53825c5
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=87-112/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
TestPagination::test_multiple_pages(self)
function
def test_multiple_pages(self) -> None: session = _FakeSession( [ _FakeResponse( json_data={ "members": [{"id": str(i)} for i in range(100)], "count": 100, "total": 150, ...
1,540
b33d57d4f7c3419096381b2701f0703c
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=141-171/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
TestPagination::test_total_mutation_retries_then_succeeds(self)
function
def test_total_mutation_retries_then_succeeds(self) -> None: """Pass 1 mismatch, pass 2 matches → return pass 2 items only. The retry must replace (not append to) the first pass, otherwise records from both passes would be duplicated. """ session = _FakeSession( [ ...
1,541
8c0e3171dd09de07d3232724bc7220bd
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=173-189/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
TestPagination::test_malformed_metadata_aborts(self)
function
def test_malformed_metadata_aborts(self) -> None: """hasMore=true but nextOffset is unusable → abort.""" session = _FakeSession( [ _FakeResponse( json_data={ "members": [{"id": "1"}], "count": 1, ...
1,542
8302836235a9d994ec8420f58c0a43cf
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=192-199/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
test_auth_error_raised()
function
# ---- error handling ---- def test_auth_error_raised() -> None: """401 and 403 raise GrowthBookAuthError specifically (not wrapped as generic).""" session = _FakeSession([_FakeResponse(status_code=401)]) with pytest.raises(GrowthBookAuthError): _client(session).list_members()
1,543
68f4f9d5c48d8ad94495a47150cc4934
swh:1:cnt:2615d07d02cf7ad34c818a29df5554da47449754;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=210-219/
04205f1dd804152fc7490d03f37ef19728b57061
growthbook
analytics
ldap-sync/tests/test_growthbook_client.py
test_network_error_wrapped()
function
def test_network_error_wrapped() -> None: """Transport errors get wrapped as GrowthBookAPIError.""" session = _FakeSession([]) def raise_conn_error(*args: Any, **kwargs: Any) -> Any: raise requests.ConnectionError("simulated") session.request = raise_conn_error # type: ignore[method-assign] ...
1,544
79f70200c5af4845c04e05b77f38d21d
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=13-47/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestRoleStringMapping
type
# ---- role string mapping ---- class TestRoleStringMapping: def test_admin_lowercase(self) -> None: assert role_string_to_enum("admin", elevated_role_name="X") == Role.ADMIN def test_readonly_lowercase(self) -> None: assert role_string_to_enum("readonly", elevated_role_name="X") == Role.READ...
1,545
71763b19ba840ed5331d68df25cc1e3d
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=134-199/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestProjectRolesWithManagedSet
type
# ---- project_roles_with_managed_set ---- class TestProjectRolesWithManagedSet: def test_replaces_existing_managed_entry(self) -> None: member = { "projectRoles": [ {"project": "other", "role": "engineer"}, {"project": "prj1", "role": "admin"}, ] ...
1,546
f65fbb7448403dedaba2c30a52904ad9
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=50-131/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestMembersFromRaw
type
# ---- members_from_raw scope filter ---- class TestMembersFromRaw: def test_includes_only_in_scope(self) -> None: members: list[dict[str, Any]] = [ { # in our project — included "id": "m1", "email": "a@x", "projectRoles": [{"project": "prj1", "...
1,547
25e50e3b5f260d36a65fffae2b22b387
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=17-18/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestRoleStringMapping::test_admin_lowercase(self)
function
def test_admin_lowercase(self) -> None: assert role_string_to_enum("admin", elevated_role_name="X") == Role.ADMIN
1,548
d7ebb497464d6106c09d36204eb16bc2
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=29-33/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestRoleStringMapping::test_other_builtin_role_treated_as_no_access(self)
function
def test_other_builtin_role_treated_as_no_access(self) -> None: # GB has many builtin roles (engineer, designer, experimenter); none # are managed by us, so the sync sees them as "no managed access" for name in ("engineer", "designer", "analyst", "experimenter"): assert role_string_t...
1,549
809a597fafc490bd0a83452f65d191cf
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=54-86/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestMembersFromRaw::test_includes_only_in_scope(self)
function
def test_includes_only_in_scope(self) -> None: members: list[dict[str, Any]] = [ { # in our project — included "id": "m1", "email": "a@x", "projectRoles": [{"project": "prj1", "role": "admin"}], }, { # not in our project, not ...
1,550
81daf81ac29b31473fb972b1769dd5c6
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=138-153/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestProjectRolesWithManagedSet::test_replaces_existing_managed_entry(self)
function
def test_replaces_existing_managed_entry(self) -> None: member = { "projectRoles": [ {"project": "other", "role": "engineer"}, {"project": "prj1", "role": "admin"}, ] } out = project_roles_with_managed_set( existing_member=membe...
1,551
b6224d285abaf201f56672b6c4097c97
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=170-180/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestProjectRolesWithManagedSet::test_adds_managed_entry_when_absent(self)
function
def test_adds_managed_entry_when_absent(self) -> None: member = {"projectRoles": [{"project": "other", "role": "engineer"}]} out = project_roles_with_managed_set( existing_member=member, project_id="prj1", new_role_string="admin", ) # New managed entri...
1,552
961abcacff706ea1def202c515ee6a8d
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=23-27/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestRoleStringMapping::test_custom_elevated_exact_match(self)
function
def test_custom_elevated_exact_match(self) -> None: assert ( role_string_to_enum("CustomElevatedAccess", elevated_role_name="CustomElevatedAccess") == Role.CUSTOM_ELEVATED )
1,553
13fd4888a6874662fa976e1bda3a427d
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=35-37/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestRoleStringMapping::test_none_or_empty(self)
function
def test_none_or_empty(self) -> None: assert role_string_to_enum(None, elevated_role_name="X") == Role.NO_ACCESS assert role_string_to_enum("", elevated_role_name="X") == Role.NO_ACCESS
1,554
ddd6c9748dffe8be98fa61c05d9b21ed
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=20-21/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestRoleStringMapping::test_readonly_lowercase(self)
function
def test_readonly_lowercase(self) -> None: assert role_string_to_enum("readonly", elevated_role_name="X") == Role.READ_ONLY
1,555
6073336c126d4417ce77e1b6d1b4e3e9
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=39-47/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestRoleStringMapping::test_enum_to_string_roundtrip(self)
function
def test_enum_to_string_roundtrip(self) -> None: for r in (Role.ADMIN, Role.READ_ONLY): assert ( role_string_to_enum( role_enum_to_string(r, elevated_role_name="X"), elevated_role_name="X", ) == r )
1,556
18fc41f8a7b2e1ef09e22e93d03fb6f4
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=88-102/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestMembersFromRaw::test_lowercases_emails(self)
function
def test_lowercases_emails(self) -> None: members = [ { "id": "m1", "email": "Alice@X", "projectRoles": [{"project": "prj1", "role": "readonly"}], } ] out = members_from_raw( members, project_id="prj1...
1,557
639d9533b198601665609888e3ee81ac
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=104-115/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestMembersFromRaw::test_skips_members_without_email_or_id(self)
function
def test_skips_members_without_email_or_id(self) -> None: members = [ {"id": "m1", "email": "", "projectRoles": []}, {"id": "", "email": "a@x", "projectRoles": []}, ] out = members_from_raw( members, project_id="prj1", elevated_role_nam...
1,558
e46a31d2f5f6ab0f093b2cb094a560bf
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=117-131/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestMembersFromRaw::test_custom_elevated_recognized(self)
function
def test_custom_elevated_recognized(self) -> None: members = [ { "id": "m1", "email": "a@x", "projectRoles": [{"project": "prj1", "role": "CustomElevatedAccess"}], } ] out = members_from_raw( members, ...
1,559
95383eaa9b6e859b86b0b77b9873ff5d
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=155-168/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestProjectRolesWithManagedSet::test_removes_managed_entry_when_role_is_none(self)
function
def test_removes_managed_entry_when_role_is_none(self) -> None: member = { "projectRoles": [ {"project": "other", "role": "engineer"}, {"project": "prj1", "role": "admin"}, ] } out = project_roles_with_managed_set( existing_memb...
1,560
d1ea1138e0cc34308c179dfc54a9de4e
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=182-191/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestProjectRolesWithManagedSet::test_empty_existing_role_none_is_noop(self)
function
def test_empty_existing_role_none_is_noop(self) -> None: member = {"projectRoles": []} assert ( project_roles_with_managed_set( existing_member=member, project_id="prj1", new_role_string=None, ) == [] )
1,561
c2704904d2c468971170e2cb309cac74
swh:1:cnt:6f9a396bec368c19e51e7f35ce745474aab773a3;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=193-199/
3a93ddf4250fa700cc69f15e9bbe95b1f74738c7
growthbook
analytics
ldap-sync/tests/test_growthbook_collector.py
TestProjectRolesWithManagedSet::test_missing_projectRoles_treated_as_empty(self)
function
def test_missing_projectRoles_treated_as_empty(self) -> None: out = project_roles_with_managed_set( existing_member={}, project_id="prj1", new_role_string="admin", ) assert out == [{"project": "prj1", "role": "admin", "environments": []}]
1,562
a699f9f59d549ff2d8a1b5627108bb3a
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=16-25/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
_FakeAttr
type
# ---- helpers ---- class _FakeAttr: def __init__(self, value: Any) -> None: self.value = value self.values = value if isinstance(value, list) else [value] def __bool__(self) -> bool: return bool(self.values)
1,563
8a2514936869f337b2c53f1b4a2084d2
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=34-56/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
_FakeConnection
type
class _FakeConnection: """Scriptable LDAP connection. `.search()` consumes from `_responses`.""" def __init__(self, responses: list[list[_FakeEntry]]) -> None: self._responses = responses self.entries: list[_FakeEntry] = [] self.search_calls: list[dict[str, Any]] = [] def search(se...
1,564
94e6a3211c92b90f8ff420050e466085
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=93-102/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestDetectDuplicateEmails
type
# ---- duplicate email detection ---- class TestDetectDuplicateEmails: def test_no_dups_passes(self) -> None: _detect_duplicate_emails({"alice": "a@x", "bob": "b@x"}) def test_dup_raises(self) -> None: with pytest.raises(LDAPCollectorError, match="resolve to the same email"): _det...
1,565
afc2adef509349034b70b93da101d1f0
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=28-31/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
_FakeEntry
type
class _FakeEntry: def __init__(self, **attrs: Any) -> None: for k, v in attrs.items(): setattr(self, k, _FakeAttr(v))
1,566
a2141fdd4935e9bb76703c7f072c4c11
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=59-73/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestUidFromDn
type
# ---- DN parsing ---- class TestUidFromDn: def test_simple(self) -> None: assert _uid_from_dn("uid=jdoe,ou=people,dc=wikimedia,dc=org") == "jdoe" def test_capital_attribute(self) -> None: assert _uid_from_dn("UID=alice,ou=people,dc=wikimedia,dc=org") == "alice" def test_dn_without_uid_r...
1,567
d671948ab93159b8323c19e7ab47cb28
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=76-90/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestEscapeFilter
type
# ---- filter escaping ---- class TestEscapeFilter: @pytest.mark.parametrize( "raw, escaped", [ ("alice", "alice"), ("a(b)c", r"a\28b\29c"), ("a*b", r"a\2ab"), ("a\\b", r"a\5cb"), ], ) def test_escape(self, raw: str, escaped: str) -> ...
1,568
dabd2b4315c22dfd81e726a8af9e8d5f
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=105-200/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestFetchBituSnapshotE2E
type
# ---- end-to-end with a fake connection ---- class TestFetchBituSnapshotE2E: def test_happy_path(self) -> None: # Order of search calls: # 1. group GrowthBook-Admin # 2. group GrowthBook-CustomElevatedAccess # 3. group GrowthBook-ReadOnly # 4. people search for uni...
1,569
03b4693b32badaee0998d17200f4df04
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=20-22/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
_FakeAttr::__init__(self, value: Any)
function
def __init__(self, value: Any) -> None: self.value = value self.values = value if isinstance(value, list) else [value]
1,570
766d88440a7a481d841156a3e93a9610
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=29-31/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
_FakeEntry::__init__(self, **attrs: Any)
function
def __init__(self, **attrs: Any) -> None: for k, v in attrs.items(): setattr(self, k, _FakeAttr(v))
1,571
d81f99116b42ea60380c110e5dd7c209
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=42-50/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
_FakeConnection::search(self, *, search_base: str, search_filter: str, attributes: list[str])
function
def search(self, *, search_base: str, search_filter: str, attributes: list[str]) -> bool: self.search_calls.append( {"base": search_base, "filter": search_filter, "attrs": attributes} ) if not self._responses: self.entries = [] return True self.entries...
1,572
a206a4d5781bd2d4d7a49ad769ace019
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=63-64/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestUidFromDn::test_simple(self)
function
def test_simple(self) -> None: assert _uid_from_dn("uid=jdoe,ou=people,dc=wikimedia,dc=org") == "jdoe"
1,573
2e5c97f25560c00ce6b7b1669425d36d
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=97-98/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestDetectDuplicateEmails::test_no_dups_passes(self)
function
def test_no_dups_passes(self) -> None: _detect_duplicate_emails({"alice": "a@x", "bob": "b@x"})
1,574
27451855f6d0a511d602e74b44d34b7e
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=109-147/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestFetchBituSnapshotE2E::test_happy_path(self)
function
def test_happy_path(self) -> None: # Order of search calls: # 1. group GrowthBook-Admin # 2. group GrowthBook-CustomElevatedAccess # 3. group GrowthBook-ReadOnly # 4. people search for unique uids → mail responses = [ [ _FakeEntry( ...
1,575
4ce1544b531004f520dfed8af5c19bbf
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=187-200/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestFetchBituSnapshotE2E::test_emails_lowercased(self)
function
def test_emails_lowercased(self) -> None: responses = [ [_FakeEntry(member=["uid=alice,ou=people,dc=wikimedia,dc=org"])], [], [], [_FakeEntry(uid="alice", mail="ALICE@Wikimedia.Org")], ] snap = fetch_bitu_snapshot( primary_uri="ldaps://...
1,576
95811725fbb03f2b5c22a4c8c47170ab
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=173-185/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestFetchBituSnapshotE2E::test_empty_group_logs_but_does_not_raise(self)
function
def test_empty_group_logs_but_does_not_raise(self) -> None: # All three groups missing → empty memberships, empty resolution responses = [[], [], [], []] conn = _FakeConnection(responses) snap = fetch_bitu_snapshot( primary_uri="ldaps://x", fallback_uri=None, ...
1,577
06b5725ba153ee086ac40164b183dcfb
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=24-25/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
_FakeAttr::__bool__(self)
function
def __bool__(self) -> bool: return bool(self.values)
1,578
310ca25d3c66d0c0145501a07a3b827b
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=37-40/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
_FakeConnection::__init__(self, responses: list[list[_FakeEntry]])
function
def __init__(self, responses: list[list[_FakeEntry]]) -> None: self._responses = responses self.entries: list[_FakeEntry] = [] self.search_calls: list[dict[str, Any]] = []
1,579
2192b070ef19406e996b6c8a002d3b19
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=52-53/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
_FakeConnection::__enter__(self)
function
def __enter__(self) -> "_FakeConnection": return self
1,580
6c260ba33d89e948ab5317d3193041de
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=55-56/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
_FakeConnection::__exit__(self, *args: Any)
function
def __exit__(self, *args: Any) -> None: pass
1,581
170a700a87e5dc5585d540bd76118c0e
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=66-67/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestUidFromDn::test_capital_attribute(self)
function
def test_capital_attribute(self) -> None: assert _uid_from_dn("UID=alice,ou=people,dc=wikimedia,dc=org") == "alice"
1,582
49d63ef83f89438302fd992fedb0e660
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=69-70/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestUidFromDn::test_dn_without_uid_returns_none(self)
function
def test_dn_without_uid_returns_none(self) -> None: assert _uid_from_dn("cn=group,ou=groups,dc=wikimedia,dc=org") is None
1,583
80d9d79bdfcd9afa70709984f92e6e0a
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=72-73/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestUidFromDn::test_invalid_dn_returns_none(self)
function
def test_invalid_dn_returns_none(self) -> None: assert _uid_from_dn("not a dn") is None
1,584
7643c299a1bf0d06c42237f0655f4c64
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=89-90/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestEscapeFilter::test_escape(self, raw: str, escaped: str)
function
def test_escape(self, raw: str, escaped: str) -> None: assert _escape_filter(raw) == escaped
1,585
ff4d625f41200bf5a6cf36ab94a2a276
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=100-102/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestDetectDuplicateEmails::test_dup_raises(self)
function
def test_dup_raises(self) -> None: with pytest.raises(LDAPCollectorError, match="resolve to the same email"): _detect_duplicate_emails({"alice": "shared@x", "ali": "shared@x"})
1,586
f0d3d12b4e7f98d587fe20dccc49eaed
swh:1:cnt:90a90d66b441157f21c665a38dbb5b0a9818a65e;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=149-171/
11320bac78b05c8dd1a391bb899d8d527e9336e3
growthbook
analytics
ldap-sync/tests/test_ldap_collector.py
TestFetchBituSnapshotE2E::test_unresolved_uid_aborts(self)
function
def test_unresolved_uid_aborts(self) -> None: # Bob's uid won't resolve to a mail attribute responses = [ [ _FakeEntry( member=[ "uid=alice,ou=people,dc=wikimedia,dc=org", "uid=bob,ou=people,dc=wikimedia,dc=o...
1,587
552f2e45bbb1ec014e02efa32ae34ea8
swh:1:cnt:c69d84017378aeba3912c52a3a0f62c8715be44d;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=11-30/
b03a535eb2fc303a9ef35eb2ab019d1d20eaa117
growthbook
analytics
ldap-sync/tests/test_log.py
test_formatter_emits_structured_fields()
function
def test_formatter_emits_structured_fields() -> None: formatter = JsonFormatter(sync_run_id="run-1", dry_run=False) record = logging.LogRecord( name="ldap_sync", level=logging.INFO, pathname="x", lineno=1, msg="hello", args=(), exc_info=None, ) rec...
1,588
7a0c635b1f1eca67a17d31fbbf52aa29
swh:1:cnt:c69d84017378aeba3912c52a3a0f62c8715be44d;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=33-46/
b03a535eb2fc303a9ef35eb2ab019d1d20eaa117
growthbook
analytics
ldap-sync/tests/test_log.py
test_formatter_does_not_leak_internal_fields()
function
def test_formatter_does_not_leak_internal_fields() -> None: formatter = JsonFormatter(sync_run_id="r", dry_run=True) record = logging.LogRecord( name="x", level=logging.WARNING, pathname="x", lineno=1, msg="y", args=(), exc_info=None, ) out = json....
1,589
3e17c05e318b715e5359e0e6c04c0b33
swh:1:cnt:c69d84017378aeba3912c52a3a0f62c8715be44d;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=49-54/
b03a535eb2fc303a9ef35eb2ab019d1d20eaa117
growthbook
analytics
ldap-sync/tests/test_log.py
test_configure_logging_returns_uuid()
function
def test_configure_logging_returns_uuid() -> None: run_id = configure_logging(level="DEBUG", dry_run=True) assert len(run_id) == 36 # standard uuid4 string # The returned id should also appear in subsequent log lines. root = logging.getLogger() assert root.handlers
1,590
975eaac53eac890159b4495cc71b89f9
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=9-15/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
_member(email: str, role: Role, member_id: str = "mid")
function
def _member(email: str, role: Role, member_id: str = "mid") -> CurrentMember: return CurrentMember( email=email, member_id=member_id, project_role=role, user_uid=email.split("@")[0], )
1,591
29a12f34bd6c78c542005ab671fa6605
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=26-33/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff::test_noop_when_current_matches_target(self)
function
def test_noop_when_current_matches_target(self) -> None: plan = diff( current_members={"a@x": _member("a@x", Role.READ_ONLY)}, target_states={"a@x": _target(Role.READ_ONLY)}, skip_emails=set(), ) assert plan.counts()[ActionKind.NOOP] == 1 assert plan.c...
1,592
398a66079d61b8060384d4143065c07c
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=62-75/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff::test_add_when_existing_member_has_no_project_role(self)
function
def test_add_when_existing_member_has_no_project_role(self) -> None: """Existing GB member with NO_ACCESS for managed project, target is a real role -> ADD (not PENDING_SSO). Production scenario: user SSO-logs in, then gets added to a Bitu group; next sync should grant access. "...
1,593
81c9fdc25549e08d710c9e2ecf7334a1
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=91-97/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff::test_pending_sso_for_bitu_only_users(self)
function
def test_pending_sso_for_bitu_only_users(self) -> None: plan = diff( current_members={}, target_states={"newhire@x": _target(Role.READ_ONLY)}, skip_emails=set(), ) assert plan.counts()[ActionKind.PENDING_SSO] == 1
1,594
eb03a04beb3a1c9223b07de57de3b3d4
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=108-115/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff::test_no_pending_sso_when_target_is_no_access(self)
function
def test_no_pending_sso_when_target_is_no_access(self) -> None: plan = diff( current_members={}, target_states={"a@x": _target(Role.NO_ACCESS, rule=1)}, skip_emails=set(), ) assert plan.counts()[ActionKind.PENDING_SSO] == 0 assert plan.counts()[ActionK...
1,595
d995913836942eeaf820cacc316c4f9d
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=148-154/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiffEmailNormalization::test_uppercase_in_current_members_raises(self)
function
def test_uppercase_in_current_members_raises(self) -> None: with pytest.raises(ValueError, match="non-lowercase"): diff( current_members={"A@x": _member("A@x", Role.READ_ONLY)}, target_states={}, skip_emails=set(), )
1,596
985987513f27a49f43a0a23cfefc9403
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=177-197/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestSortOrder::test_outer_order_includes_all_six_kinds(self)
function
def test_outer_order_includes_all_six_kinds(self) -> None: """sorted_actions returns REMOVE -> UPDATE -> ADD -> NOOP -> SKIPPED -> PENDING_SSO.""" actions = ( Action("z@x", ActionKind.PENDING_SSO, Role.NO_ACCESS, Role.READ_ONLY, 0), Action("y@x", ActionKind.SKIPPED, Role....
1,597
d7f8f3d18d6e4af7834ecf5e55276a9e
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=35-45/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff::test_remove_when_target_absent_from_target_states(self)
function
def test_remove_when_target_absent_from_target_states(self) -> None: plan = diff( current_members={"a@x": _member("a@x", Role.ADMIN)}, target_states={}, skip_emails=set(), ) assert plan.counts()[ActionKind.REMOVE] == 1 action = plan.by_kind(ActionKind....
1,598
bf6e485634e8275559cd2eb7f24547af
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=47-60/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
TestDiff::test_update_for_role_change(self)
function
def test_update_for_role_change(self) -> None: """Both directions (admin->readonly, readonly->admin) are UPDATE.""" downgrade = diff( current_members={"a@x": _member("a@x", Role.ADMIN)}, target_states={"a@x": _target(Role.READ_ONLY)}, skip_emails=set(), ) ...
1,599
05a6683238fc2074531410e5e51713d5
swh:1:cnt:9e76ff7756fa606dbfd9e357d65ea6cafcf6eed2;origin=https://gitlab.wikimedia.org/repos/data-engineering/growthbook.git;lines=18-19/
51c05db9e2af7e2c98944d5cbc607947ba9c4108
growthbook
analytics
ldap-sync/tests/test_plan.py
_target(role: Role, rule: int = 4)
function
def _target(role: Role, rule: int = 4) -> TargetState: return TargetState(role=role, rule_number=rule)