summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-09-26 03:00:32 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-09-26 03:00:32 -0400
commitd2ea83e3f1177bc2f1eff97c0f2ca14e3aa32d00 (patch)
treeafac0de14ec91f4af6fcdcde1527439ba04374ea /tests
parentdda674ad1c489bb47fb130aea2d9698a60c94b86 (diff)
downloadpypaste-d2ea83e3f1177bc2f1eff97c0f2ca14e3aa32d00.tar.gz
add test for s3 backend in test_server.py
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_server.py45
1 files changed, 38 insertions, 7 deletions
diff --git a/tests/test_server.py b/tests/test_server.py
index cd25069..e02a8e6 100755
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import sys
+import os
import asyncio
import tempfile
import string
@@ -29,9 +30,8 @@ async def tee_pipe(proc: asyncio.subprocess.Process, queue: Queue[str]) -> None:
await queue.put(line.decode())
-async def main() -> int:
- with tempfile.TemporaryDirectory(delete=False) as tmpdir:
- print(tmpdir, file=sys.stderr)
+async def test(*args: str) -> None:
+ with tempfile.TemporaryDirectory() as tmpdir:
socket = Path(tmpdir) / (generate_name() + ".sock")
database = Path(tmpdir) / generate_name()
@@ -59,15 +59,14 @@ async def main() -> int:
"/paste/{key}",
"--post-route",
"/paste",
- "sqlite",
+ *args,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.STDOUT,
)
asyncio.create_task(tee_pipe(proc, queue))
- if "starting" not in await queue.get():
- return 1
+ assert "starting" in await queue.get()
connection = aiohttp.UnixConnector(path=str(socket))
@@ -82,7 +81,39 @@ async def main() -> int:
assert get.status == 200
assert b"hello pypaste" in await get.read()
- return 0
+
+async def main() -> int:
+ tests = []
+
+ tests.append(test("sqlite"))
+
+ try:
+ os.environ["PYPASTE_TEST_S3"]
+ test_s3 = True
+ except KeyError:
+ test_s3 = False
+ pass
+
+ if test_s3:
+ tests.append(
+ test(
+ "s3",
+ "--endpoint",
+ os.environ["PYPASTE_TEST_ENDPOINT"],
+ "--region",
+ os.environ["PYPASTE_TEST_REGION"],
+ "--bucket",
+ os.environ["PYPASTE_TEST_BUCKET"],
+ "--access-key",
+ os.environ["PYPASTE_TEST_ACCESS_KEY"],
+ "--secret-key",
+ "PYPASTE_TEST_SECRET_KEY",
+ )
+ )
+
+ await asyncio.gather(*tests)
+
+ return 0
if __name__ == "__main__":