benchling_sdk.apps.config.mock_dependencies module¶
- class MockBenchlingAppConfig¶
Bases:
object
Mock App Config.
A helper class for easily mocking app config in various permutations.
Easily mock all config items from a manifest model (which can be loaded from benchling_sdk.apps.helpers.manifest_helpers.manifest_from_file().
- __init__(config_items: List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, TextAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, benchling_api_client.v2.extensions.UnknownType]], decryption_provider: Optional[MockDecryptionProvider])¶
Init Mock Benchling App Config.
The class can be initialized by providing a list of AppConfigItem, but the recommended usage is to mock directly from a manifest, like MockBenchlingAppConfig.from_manifest()
- property config_items: List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶
List the config items in the mock app config, excluding any unknown types.
- property config_items_with_unknown: List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, TextAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, benchling_api_client.v2.extensions.UnknownType]]¶
List the config items in the mock app config, including any unknown types.
- classmethod from_manifest(manifest: benchling_api_client.v2.beta.models.benchling_app_manifest.BenchlingAppManifest, decryption_provider: Optional[MockDecryptionProvider] = None) MockBenchlingAppConfig ¶
From Manifest.
Reads a manifest amd mocks out all dependencies.
- to_dependencies(target_dependencies: Type[benchling_sdk.apps.config.mock_dependencies.D]) benchling_sdk.apps.config.mock_dependencies.D ¶
To Dependencies.
Convenience method for providing mocked app config to a target class extending BaseDependencies.
- with_replacement(replacement: Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, TextAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, benchling_api_client.v2.extensions.UnknownType]) MockBenchlingAppConfig ¶
With Replacement.
Returns a new MockBenchlingAppConfig with the app config item at the specified path replaced.
- with_replacements(replacements: List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, TextAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, benchling_api_client.v2.extensions.UnknownType]]) MockBenchlingAppConfig ¶
With Replacement.
Returns a new MockBenchlingAppConfig with the app config item at the specified path replaced.
- class MockDecryptionFunction¶
Bases:
typing_extensions.Protocol
Mock out a decryption function for use with secure text.
- __init__(*args, **kwargs)¶
- class MockDecryptionProvider¶
Bases:
benchling_sdk.apps.config.decryption_provider.BaseDecryptionProvider
Mock Decryption Provider.
A generic class mocking a BaseDecryptionProvider. Can be passed a function to mock arbitrary decryption.
Itâs recommended to extend this class or use a specific implementation instead of initializing an instance.
- __init__(mock_decryption_function: MockDecryptionFunction)¶
Init Mock Decryption Provider.
Pass a function that returns desired mocked plaintext given ciphertext.
- class MockDecryptionProviderMapped¶
Bases:
benchling_sdk.apps.config.mock_dependencies.MockDecryptionProvider
Mock Decryption Provider Mapped.
Returns a âdecryptedâ value based on the input ciphertext. Useful if you have multiple secrets to mock simultaneously.
- class MockDecryptionProviderStatic¶
Bases:
benchling_sdk.apps.config.mock_dependencies.MockDecryptionProvider
Mock Decryption Provider Static.
Always return the same âdecryptedâ value regardless of what ciphertext is passed. Useful if you only have a single secret value.
- mock_app_config_items_from_manifest(manifest: benchling_api_client.v2.beta.models.benchling_app_manifest.BenchlingAppManifest) List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, TextAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, benchling_api_client.v2.extensions.UnknownType]] ¶
Mock Benchling App Config Items.
This method accepts an app manifest model and creates mocked values for app the app config.
The concrete mocked out values, such as API Ids and schema names are nonsensical and random, but are valid.
Code should avoid relying on specific values or conventions (such as API prefixes). If specific dependency values need to be tested in isolation, the caller can selectively override the randomized values with replace_mocked_config_item_by_path().
- mock_bool_app_config_item(path: List[str], value: Optional[bool]) BooleanAppConfigItem ¶
Mock a bool app config item with a path and specified value.
- mock_date_app_config_item(path: List[str], value: Optional[date]) DateAppConfigItem ¶
Mock a date app config item with a path and specified value.
- mock_datetime_app_config_item(path: List[str], value: Optional[datetime]) DatetimeAppConfigItem ¶
Mock a datetime app config item with a path and specified value.
- mock_float_app_config_item(path: List[str], value: Optional[float]) FloatAppConfigItem ¶
Mock a float app config item with a path and specified value.
- mock_int_app_config_item(path: List[str], value: Optional[int]) IntegerAppConfigItem ¶
Mock an int app config item with a path and specified value.
- mock_json_app_config_item(path: List[str], value: Optional[Union[Dict[str, Any], List[Any], str, int, float, bool]]) JsonAppConfigItem ¶
Mock an int app config item with a path and specified value.
- mock_secure_text_app_config_item(path: List[str], value: Optional[str]) SecureTextAppConfigItem ¶
Mock a secure text app config item with a path and specified value.
- mock_text_app_config_item(path: List[str], value: Optional[str]) TextAppConfigItem ¶
Mock a text app config item with a path and specified value.
- replace_mocked_config_item_by_path(original_config: List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, TextAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, benchling_api_client.v2.extensions.UnknownType]], replacement_path: List[str], replacement_item: Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, TextAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, benchling_api_client.v2.extensions.UnknownType]) List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, TextAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, benchling_api_client.v2.extensions.UnknownType]] ¶
Return an updated list of app config items with a specific config item replaced with the provided mock.