aboutsummaryrefslogtreecommitdiff
path: root/tools/aio/modules/test.py
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-05-31 22:56:15 +0800
committerYuqian Yang <crupest@crupest.life>2024-12-18 18:31:27 +0800
commit723c9a963a96b25a7498f3e0417307e89c8bb684 (patch)
tree3eff901a5b96eb4ff88d272bed4bb964c6397f1f /tools/aio/modules/test.py
parent6e60bb06bd7a5052a7d6c2b5b8df0ab084697fdd (diff)
downloadcrupest-723c9a963a96b25a7498f3e0417307e89c8bb684.tar.gz
crupest-723c9a963a96b25a7498f3e0417307e89c8bb684.tar.bz2
crupest-723c9a963a96b25a7498f3e0417307e89c8bb684.zip
HALF WORK: for sync.
Diffstat (limited to 'tools/aio/modules/test.py')
-rw-r--r--tools/aio/modules/test.py31
1 files changed, 0 insertions, 31 deletions
diff --git a/tools/aio/modules/test.py b/tools/aio/modules/test.py
deleted file mode 100644
index d6eb778..0000000
--- a/tools/aio/modules/test.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import json
-from http.client import *
-from urllib.request import urlopen
-
-
-def test_crupest_api(console):
- def do_the_test():
- res: HTTPResponse = urlopen("http://localhost:5188/api/todos")
- body = res.read()
-
- if res.status != 200:
- raise Exception("Status code is not 200.")
- result = json.loads(body)
- if not isinstance(result, list):
- raise Exception("Result is not an array.")
- if len(result) == 0:
- raise Exception("Result is an empty array.")
- if not isinstance(result[0], dict):
- raise Exception("Result[0] is not an object.")
- if not isinstance(result[0].get("title"), str):
- raise Exception("Result[0].title is not a string.")
- if not isinstance(result[0].get("status"), str):
- raise Exception("Result[0].status is not a string.")
-
- try:
- do_the_test()
- console.print("Test passed!", style="green")
- exit(0)
- except Exception as e:
- console.print(e)
- console.print("Test failed!", style="red")