Skip to content

Commit

Permalink
add simple emulated frontend test for endpoint baseimagetags
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyBRoswell committed Nov 13, 2024
1 parent 81d8c63 commit ef180f8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions vreapis/tests/emulated-frontend/containerizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
session = requests.Session()


def test(endpoint: str, files: list[str]):
def test_post(endpoint: str, files: list[str]):
for file in files:
with open(f'{script_path}/dat/{file}') as f:
body: dict[str, any] = json.load(f)
Expand All @@ -40,13 +40,18 @@ def test(endpoint: str, files: list[str]):


for endpoint in args.in_def:
file_pattern = re.compile(fr'{endpoint}(\..+)?.json')
files: list[str] = os.listdir(f'{script_path}/dat')
request_body_files: list[str] = [file for file in files if file_pattern.match(file)]
test(endpoint, request_body_files)
match endpoint:
case 'baseimagetags':
response = session.get(f'{API_ENDPOINT}/{endpoint}', headers=headers, verify=False)
print(response.text)
case _:
file_pattern = re.compile(fr'{endpoint}(\..+)?.json')
files: list[str] = os.listdir(f'{script_path}/dat')
request_body_files: list[str] = [file for file in files if file_pattern.match(file)]
test_post(endpoint, request_body_files)

if args.in_id is not None:
for test_info in args.in_id:
endpoint: str = test_info[0]
files: list[str] = [f'{endpoint}.{id}.json' for id in test_info[1:]]
test(endpoint, files)
test_post(endpoint, files)

0 comments on commit ef180f8

Please sign in to comment.