forked from p15670423/monkey
Common: Add release_convention()
This commit is contained in:
parent
8fb97fc8c0
commit
c53864cdd7
|
@ -171,6 +171,16 @@ class DIContainer:
|
|||
DIContainer._del_key(self._type_registry, interface)
|
||||
DIContainer._del_key(self._instance_registry, interface)
|
||||
|
||||
def release_convention(self, type_: Type[T], name: str):
|
||||
"""
|
||||
Deregister a convention
|
||||
|
||||
:param **type_**: The `type` (class) of the dependency
|
||||
:param name: The name of the dependency parameter
|
||||
"""
|
||||
convention_identifier = (type_, name)
|
||||
DIContainer._del_key(self._convention_registry, convention_identifier)
|
||||
|
||||
@staticmethod
|
||||
def _del_key(mapping: MutableMapping[T, Any], key: T):
|
||||
"""
|
||||
|
|
|
@ -366,3 +366,12 @@ def test_register_convention__instance_properly_resolved(container):
|
|||
|
||||
assert id(service_a_instance) == id(test_9.service_a)
|
||||
assert test_9.my_str == my_str
|
||||
|
||||
|
||||
def test_release_convention(container):
|
||||
my_str = "test_string"
|
||||
container.register_convention(str, "my_str", my_str)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
container.release_convention(str, "my_str")
|
||||
container.resolve(TestClass6)
|
||||
|
|
|
@ -182,6 +182,7 @@ GCPHandler # unused function (envs/monkey_zoo/blackbox/test_blackbox.py:57)
|
|||
architecture # unused variable (monkey/infection_monkey/exploit/caching_agent_repository.py:25)
|
||||
|
||||
response_code # unused variable (monkey/monkey_island/cc/services/aws/aws_command_runner.py:26)
|
||||
release_convention # unused method (monkey/common/di_container.py:174)
|
||||
|
||||
# TODO DELETE AFTER RESOURCE REFACTORING
|
||||
NetworkMap
|
||||
|
|
Loading…
Reference in New Issue