-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapi_test.py
More file actions
38 lines (29 loc) · 1.13 KB
/
api_test.py
File metadata and controls
38 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os.path
import shutil
import subprocess
import sys
import validators
if __name__ == "__main__":
if not shutil.which("git"):
sys.exit("'git' command not found. Please install 'git' before proceeding.")
if not shutil.which("npm"):
sys.exit("'npm' command not found. Please install 'Node.js' before proceeding.")
subprocess.run("npm install --global newman", shell=True, check=True)
APIURL = os.getenv("APIURL")
if not APIURL:
APIURL = input("Please input the APIURL: ")
if not validators.url(APIURL):
raise ValueError(f"APIURL must be a valid url. Received {APIURL}")
this_script_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
run_api_tests_executable_path = os.path.join(
this_script_dir, "realworld", "api", "run-api-tests.sh"
)
if not os.path.isfile(run_api_tests_executable_path):
subprocess.run(
["git", "submodule", "update", "--init", "--recursive"],
check=True,
cwd=this_script_dir,
)
subprocess.run(
f"APIURL={APIURL} {run_api_tests_executable_path}", shell=True, check=True
)