Skip to content

Commit

Permalink
Update agent_persist_mock to patch _exists method
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Nasser committed Feb 23, 2025
1 parent 776043e commit c710b37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ostorlab/testing/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _get(key):
def _add(key: Union[str, bytes], value: bytes):
"""Check values are present in the storage dict."""
if isinstance(value, bytes) is False:
storage[key] = str(value).encode()
value = str(value).encode()
storage[key] = value

def _exists(key: str) -> bool:
Expand Down
3 changes: 3 additions & 0 deletions tests/testing/agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ def testMockPersistAgent_whensetMethodsAreCalled_stateIsPersistedByMock(
assert test_agent.set_add("test", "1") is True
assert test_agent.set_is_member("test", "1") is True
assert agent_persist_mock == {"test": {"1"}}
assert test_agent.exists("akey") is False
test_agent.add("akey", b"aval")
assert test_agent.exists("akey") is True

0 comments on commit c710b37

Please sign in to comment.