mex.common.testing package

Submodules

mex.common.testing.joker module

class mex.common.testing.joker.Joker

Bases: object

Testing utility that pretends to be equal to anything.

Useful for tests that assert partially predictable dictionaries.

Example

assert value == {“predictable”: 42, “timestamp”: Joker()}

mex.common.testing.mocked_ldap module

mex.common.testing.mocked_ldap._actor_matches(actor: LDAPActor, **kwargs: str) bool

Check whether an actor matches all non-wildcard search filters.

mex.common.testing.mocked_ldap._attribute_values(actor: LDAPActor, attribute: str) list[str]

Return an actor’s attribute values as a list of strings.

mex.common.testing.mocked_ldap.contact_point(ldap_contact_point: LDAPFunctionalAccount, extracted_primary_source_ids: dict[str, MergedPrimarySourceIdentifier]) ExtractedContactPoint

Return an ExtractedContactPoint for a dummy contact point.

mex.common.testing.mocked_ldap.frieda_fictitious(ldap_frieda_fictitious: LDAPPerson, mocked_units_by_identifier_in_primary_source: dict[str, ExtractedOrganizationalUnit], extracted_organization_rki: ExtractedOrganization, extracted_primary_source_ids: dict[str, MergedPrimarySourceIdentifier]) ExtractedPerson

Return an LDAPPerson for Frieda Fictitious.

mex.common.testing.mocked_ldap.juturna_felicitas(ldap_juturna_felicitas: LDAPPerson, mocked_units_by_identifier_in_primary_source: dict[str, ExtractedOrganizationalUnit], extracted_organization_rki: ExtractedOrganization, extracted_primary_source_ids: dict[str, MergedPrimarySourceIdentifier]) ExtractedPerson

Return an ExtractedPerson for Juturna Felicitás.

mex.common.testing.mocked_ldap.ldap_contact_point() LDAPFunctionalAccount

Return an LDAPFunctionalAccount for a dummy contact point.

mex.common.testing.mocked_ldap.ldap_frieda_fictitious() LDAPPerson

Return an LDAPPerson for Frieda Fictitious.

mex.common.testing.mocked_ldap.ldap_juturna_felicitas() LDAPPerson

Return an LDAPPerson for Juturna Felicitás.

mex.common.testing.mocked_ldap.ldap_mock_query_searcher(actors: list[LDAPActor]) Callable[[...], Any]

Create a mocked query search over display names and functional account mails.

mex.common.testing.mocked_ldap.ldap_mock_searcher(actors: list[LDAPActor]) Callable[[...], Any]

Create a mocked attribute search that faithfully filters the given actors.

mex.common.testing.mocked_ldap.ldap_roland_resolved() LDAPPerson

Return an LDAPPerson for Roland Resolved.

mex.common.testing.mocked_ldap.mocked_ldap(request: FixtureRequest, monkeypatch: MonkeyPatch, ldap_contact_point: LDAPFunctionalAccount, ldap_roland_resolved: LDAPPerson, ldap_juturna_felicitas: LDAPPerson, ldap_frieda_fictitious: LDAPPerson) None

Run each test with patched connector and/or against a mock server.

mex.common.testing.mocked_ldap.roland_resolved(ldap_roland_resolved: LDAPPerson, mocked_units_by_identifier_in_primary_source: dict[str, ExtractedOrganizationalUnit], extracted_organization_rki: ExtractedOrganization, extracted_primary_source_ids: dict[str, MergedPrimarySourceIdentifier]) ExtractedPerson

Return an ExtractedPerson for Roland Resolved.

mex.common.testing.plugin module

Pytest plugin with common MEx-specific fixtures.

Activate by adding pytest_plugins = (“mex.common.testing.plugin”,) to the conftest.py in your root test folder.

class mex.common.testing.plugin.NoOpPytest

Bases: object

No-op pytest drop-in for when dev dependencies are not installed.

FixtureRequest

alias of Any

MonkeyPatch

alias of Any

fixture = <MagicMock id='140120391850976'>
mex.common.testing.plugin.extracted_primary_source_ids() dict[str, MergedPrimarySourceIdentifier]

Return a mapping from identifierInPrimarySource to ExtractedPrimarySources.

mex.common.testing.plugin.faker_session_locale() list[str]

Configure the default locales used for localizing fake data.

mex.common.testing.plugin.in_continuous_integration() bool

Check the environment variable CI to determine whether we are in CI.

mex.common.testing.plugin.is_integration_test(request: FixtureRequest) bool

Check the markers of a test to see if this is an integration test.

mex.common.testing.plugin.isolate_assets_and_ops_dir(is_integration_test: bool, monkeypatch: MonkeyPatch) None

Disable assets and ops dir environment variables for unit testing.

mex.common.testing.plugin.isolate_connectors() Generator[None, None, None]

Automatically close all connectors and remove from singleton store.

mex.common.testing.plugin.isolate_langdetect() None

Automatically set the language detection seed to a stable value during tests.

mex.common.testing.plugin.isolate_settings(isolate_assets_and_ops_dir: None, isolate_work_dir: None) Generator[None, None, None]

Automatically reset the settings singleton store.

mex.common.testing.plugin.isolate_work_dir(tmp_path: Path, monkeypatch: MonkeyPatch) None

Set the MEX_WORK_DIR environment variable to a temp path for all tests.

mex.common.testing.plugin.mocked_orcid(monkeypatch: MonkeyPatch, orcid_person_raw: dict[str, Any], orcid_multiple_matches: dict[str, Any], orcid_person_jayne_raw: dict[str, Any]) None

Mock orcid connector.

mex.common.testing.plugin.mocked_wikidata(monkeypatch: MonkeyPatch, wikidata_organization_raw: dict[str, Any]) None

Mock wikidata connector.

mex.common.testing.plugin.orcid_multiple_matches() dict[str, Any]

Return a raw orcid person.

mex.common.testing.plugin.orcid_person_jayne_raw() dict[str, Any]

Return a raw orcid person.

mex.common.testing.plugin.orcid_person_raw() dict[str, Any]

Return a raw orcid person.

mex.common.testing.plugin.patch_reprs(monkeypatch: MonkeyPatch) None

Allow for easier copying of expected output by patching __repr__ methods.

mex.common.testing.plugin.settings() BaseSettings

Load the settings for this pytest session.

mex.common.testing.plugin.wikidata_organization(wikidata_organization_raw: dict[str, Any]) WikidataOrganization

Return a wikidata organization instance.

mex.common.testing.plugin.wikidata_organization_raw() dict[str, Any]

Return a raw wikidata organization.

Module contents

class mex.common.testing.Joker

Bases: object

Testing utility that pretends to be equal to anything.

Useful for tests that assert partially predictable dictionaries.

Example

assert value == {“predictable”: 42, “timestamp”: Joker()}