Skip to content

Commit

Permalink
Add a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
minhtule committed Nov 11, 2018
1 parent 0d2e566 commit 86cb33e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/ut/backends/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ async def test_set_no_ttl_no_handle(self, memory):
await memory._set(pytest.KEY, "value")
assert pytest.KEY not in memory._handlers

@pytest.mark.asyncio
async def test_set_cancel_previous_ttl_handle(self, memory, mocker):
fake_timer_handle_cancel = mocker.patch("asyncio.TimerHandle.cancel")
await memory._set(pytest.KEY, "value", ttl=0.1)
fake_timer_handle_cancel.assert_not_called()

await memory._set(pytest.KEY, "new_value", ttl=0.1)
fake_timer_handle_cancel.assert_called_once_with()

@pytest.mark.asyncio
async def test_set_ttl_handle(self, memory):
await memory._set(pytest.KEY, "value", ttl=100)
Expand Down

0 comments on commit 86cb33e

Please sign in to comment.