id_translation.testing#
Test implementations.
Classes
|
Dummy |
|
Dummy |
- class TestFetcher(sources=None)[source]#
Bases:
Fetcher[SourceType,IdType]Dummy
Fetcherimplementation.A “happy path” fetcher implementation for testing purposes. Returns generated names for all IDs and placeholders, so translation retrieval will never fail when using this fetcher.
- property allow_fetch_all#
Flag indicating whether the
fetch_all()operation is permitted.
- fetch(ids_to_fetch, placeholders=(), *, required=(), task_id=None, enable_uuid_heuristics=False)[source]#
Return generated translations for all IDs and placeholders.
- fetch_all(placeholders=(), *, required=(), sources=None, task_id=None, enable_uuid_heuristics=False)[source]#
Fetch as much data as possible.
- Parameters:
placeholders – All desired placeholders in preferred order.
required – Placeholders that must be included in the response.
sources – A subset of sources to fetch. Unknown sources are ignored. Set to
Noneto fetch all sources.task_id – Used for logging.
enable_uuid_heuristics – Improves matching when
UUID-like IDs are in use.
- Returns:
A mapping
{source: PlaceholderTranslations}of translation elements.
See also
🔑 This is a key event method. See Key Event Records for details.
- Raises:
ForbiddenOperationError – If fetching all IDs is not possible or permitted.
UnknownPlaceholderError – For placeholder(s) that are unknown to the
Fetcher.ImplementationError – For errors made by the inheriting implementation.
- initialize_sources(task_id=None, *, force=False)[source]#
Perform source discovery.
- Parameters:
task_id – Used for logging.
force – If
True, perform full discovery even if sources are already known.
See also
🔑 This is a key event method. See Key Event Records for details.
Notes
This function is called implicitly before every translation task. Result should be cached.
- property online#
Return connectivity status. If
False, no new translations may be fetched.
- property placeholders#
Placeholders for all known Source names, such as
idorname.These are the (possibly unmapped) placeholders that may be used for translation.
- Returns:
A dict
{source: [placeholders, ...]}.
- class TestMapper(score_function='disabled', score_function_kwargs=None, filter_functions=(), min_score=0.9, overrides=None, on_unmapped='ignore', on_unknown_user_override='raise', cardinality=Cardinality.ManyToOne)[source]#
Bases:
Mapper[ValueType,ValueType,ContextType]Dummy
Mapperimplementation.