mex.common.testing package¶
Submodules¶
mex.common.testing.joker module¶
- class mex.common.testing.joker.Joker¶
Bases:
objectTesting 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.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:
objectNo-op pytest drop-in for when dev dependencies are not installed.
- FixtureRequest¶
alias of
Any
- MonkeyPatch¶
alias of
Any
- fixture = <MagicMock id='139891331094992'>¶
- 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_dir(is_integration_test: bool, monkeypatch: MonkeyPatch) None¶
Disable the MEX_ASSETS_DIR environment variable 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_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:
objectTesting utility that pretends to be equal to anything.
Useful for tests that assert partially predictable dictionaries.
Example
assert value == {“predictable”: 42, “timestamp”: Joker()}