diff options
author | John Turner <jturner.usa@gmail.com> | 2025-09-20 13:23:44 -0400 |
---|---|---|
committer | John Turner <jturner.usa@gmail.com> | 2025-09-20 13:23:44 -0400 |
commit | da239df77ea1aaee8dac08a8dac2d65a9bfee342 (patch) | |
tree | 18156214799f444fcbac211a9b16ba3b954fce0e | |
parent | 63b070473448ad5c7fdcdc3e42befb4792b177a7 (diff) | |
download | pypaste-da239df77ea1aaee8dac08a8dac2d65a9bfee342.tar.gz |
add test_client_zen.py
-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()) |