diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/meson.build | 2 | ||||
-rw-r--r-- | tests/test_client_zen.py | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/tests/meson.build b/tests/meson.build index 801b30d..c15bbab 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,4 +1,4 @@ -tests = files('test_server.py', 'test_sqlite_storage.py') +tests = files('test_client_zen.py', 'test_server.py', 'test_sqlite_storage.py') foreach test : tests name = fs.stem(test) diff --git a/tests/test_client_zen.py b/tests/test_client_zen.py new file mode 100644 index 0000000..df3b03f --- /dev/null +++ b/tests/test_client_zen.py @@ -0,0 +1,34 @@ +import sys +import tempfile +import subprocess +import requests + + +def test_upload_file() -> None: + with tempfile.NamedTemporaryFile() as f: + f.write(b"hello world") + f.flush() + + proc = subprocess.run( + ["python", "-m", "pypaste.client", "zen", "--file", f.name], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + ) + + assert proc.returncode == 0 + + url = proc.stdout.decode().strip() + + req = requests.get(url, params={"raw": "true"}) + + assert "hello world" in req.text + + +def main() -> int: + test_upload_file() + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) |