mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-10-27 11:53:43 +00:00
Correct way to allow setting context with existing
This reverts commit 5c4d3eeffd.
Original solution has introduced special workaround (strict flag) which
contradicts the concept of immutable context. Moreover, it introduces
possible side-effects, because child process will use the one set by
parent instead of having own one.
The correct solution is to re-create context in process entry point
Sorry, it was Jan 1 and I was drunk :(
This commit is contained in:
@ -32,11 +32,11 @@ def test_set_context(configuration: Configuration, database: SQLite, mocker: Moc
|
||||
|
||||
instance = Repository.load("x86_64", configuration, database, report=False, unsafe=False)
|
||||
set_mock.assert_has_calls([
|
||||
MockCall(ContextKey("database", SQLite), instance.database, strict=False),
|
||||
MockCall(ContextKey("configuration", Configuration), instance.configuration, strict=False),
|
||||
MockCall(ContextKey("pacman", Pacman), instance.pacman, strict=False),
|
||||
MockCall(ContextKey("sign", GPG), instance.sign, strict=False),
|
||||
MockCall(ContextKey("repository", Repository), instance, strict=False),
|
||||
MockCall(ContextKey("database", SQLite), instance.database),
|
||||
MockCall(ContextKey("configuration", Configuration), instance.configuration),
|
||||
MockCall(ContextKey("pacman", Pacman), instance.pacman),
|
||||
MockCall(ContextKey("sign", GPG), instance.sign),
|
||||
MockCall(ContextKey("repository", Repository), instance),
|
||||
])
|
||||
|
||||
|
||||
|
||||
@ -57,17 +57,6 @@ def test_set_value_exception() -> None:
|
||||
ctx.set(ContextKey("key", str), 42)
|
||||
|
||||
|
||||
def test_set_value_exists() -> None:
|
||||
"""
|
||||
must skip key set in case if key already exists and strict check is disabled
|
||||
"""
|
||||
key, value = ContextKey("key", int), 42
|
||||
ctx = _Context()
|
||||
ctx.set(key, value)
|
||||
|
||||
ctx.set(key, value, strict=False)
|
||||
|
||||
|
||||
def test_contains() -> None:
|
||||
"""
|
||||
must correctly check if element is in list
|
||||
|
||||
Reference in New Issue
Block a user