summaryrefslogtreecommitdiff
path: root/tests/test_storage.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_storage.py')
-rwxr-xr-xtests/test_storage.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_storage.py b/tests/test_storage.py
index f2b8912..62dd7b2 100755
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -5,6 +5,7 @@ import os
import asyncio
import tempfile
import aiosqlite
+import zstandard
from pypaste.server import Paste, Storage, keygen
from pypaste.server.sqlite import Sqlite
from pypaste.server.s3 import S3
@@ -17,6 +18,29 @@ def truncate(path: Path) -> None:
f.truncate(0)
+async def test_storage_use(storage: Storage) -> None:
+ content = "hello pypaste"
+ length = len(zstandard.compress(content.encode()))
+
+ for x in range(5):
+ paste = Paste(datetime.now(), None, content)
+ key = keygen(6)
+ await storage.insert(paste, key)
+
+ assert (use := await storage.storage_use()) is not None and use == length * 5
+
+
+async def test_oldest(storage: Storage) -> None:
+ pastes = []
+ for x in range(5):
+ paste = Paste(datetime.now(), None, "hello pypaste")
+ key = keygen(6)
+ pastes.append(key)
+ await storage.insert(paste, key)
+
+ assert (oldest := await storage.oldest()) is not None and oldest == pastes[0]
+
+
async def test_exists_but_not_in_our_table(storage: Storage) -> None:
key = keygen(6)
@@ -125,6 +149,8 @@ async def main() -> int:
test_delete,
test_exists,
test_exists_but_not_in_our_table,
+ test_oldest,
+ test_storage_use,
]
await test_sqlite(tests)