Skip to content

Commit

Permalink
update sync storage tests to use float TTL's with millisecond precision
Browse files Browse the repository at this point in the history
  • Loading branch information
parkerhancock committed Nov 21, 2023
1 parent a6b4c65 commit b4cac7a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/_sync/test_storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_sqlitestorage():


def test_filestorage_expired():
storage = FileStorage(ttl=1)
storage = FileStorage(ttl=0.001)
first_request = Request(b"GET", "https://example.com")
second_request = Request(b"GET", "https://anotherexample.com")

Expand All @@ -106,7 +106,7 @@ def test_filestorage_expired():

storage.store(first_key, response=response, request=first_request, metadata=dummy_metadata)

sleep(2)
sleep(0.002)
storage.store(second_key, response=response, request=second_request, metadata=dummy_metadata)

assert storage.retreive(first_key) is None
Expand All @@ -116,7 +116,7 @@ def test_filestorage_expired():
def test_redisstorage_expired():
if is_redis_down(): # pragma: no cover
pytest.fail("Redis server was not found")
storage = RedisStorage(ttl=1)
storage = RedisStorage(ttl=0.001)
first_request = Request(b"GET", "https://example.com")
second_request = Request(b"GET", "https://anotherexample.com")

Expand All @@ -128,15 +128,15 @@ def test_redisstorage_expired():

storage.store(first_key, response=response, request=first_request, metadata=dummy_metadata)

sleep(2)
sleep(0.002)
storage.store(second_key, response=response, request=second_request, metadata=dummy_metadata)

assert storage.retreive(first_key) is None



def test_sqlite_expired():
storage = SQLiteStorage(ttl=1, connection=sqlite3.connect(":memory:"))
storage = SQLiteStorage(ttl=0.001, connection=sqlite3.connect("test.sqlite"))
first_request = Request(b"GET", "https://example.com")
second_request = Request(b"GET", "https://anotherexample.com")

Expand All @@ -148,7 +148,7 @@ def test_sqlite_expired():

storage.store(first_key, response=response, request=first_request, metadata=dummy_metadata)

sleep(2)
sleep(0.002)
storage.store(second_key, response=response, request=second_request, metadata=dummy_metadata)

assert storage.retreive(first_key) is None

0 comments on commit b4cac7a

Please sign in to comment.