This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define request response mappings and use them to run tests on the end…
…points
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import json | ||
import os | ||
import subprocess | ||
|
||
import pytest | ||
|
||
from test.constants import API_URL | ||
|
||
os.environ['AUDIO_REQ_TOKEN'] = '' | ||
os.environ['AUDIO_REQ_ORIGIN'] = API_URL | ||
os.environ['AUDIO_REQ_IDX'] = '440a0240-8b20-49e2-a4e6-6fee550fcc41' | ||
|
||
from catalog.api.examples import ( # noqa | Set env vars before import | ||
audio_mappings, | ||
image_mappings, | ||
) | ||
|
||
|
||
def execute_request(request): | ||
proc = subprocess.run(request, check=True, capture_output=True, shell=True) | ||
return json.loads(proc.stdout) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'in_val, out_val', | ||
list(audio_mappings.items()) | ||
) | ||
def test_audio_success_examples(in_val, out_val): | ||
res = execute_request(in_val) | ||
assert res == out_val['application/json'] | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'in_val, out_val', | ||
list(image_mappings.items()) | ||
) | ||
def test_image_success_examples(in_val, out_val): | ||
res = execute_request(in_val) | ||
assert res == out_val['application/json'] |