-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a python script file for integration testing
- Loading branch information
1 parent
ba4c347
commit 2ce476e
Showing
2 changed files
with
51 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,50 @@ | ||
import json | ||
import re | ||
|
||
import pytest | ||
|
||
from conftest import run_cmd_and_assert_exit_code, reformat_cmd_output | ||
|
||
ENDPOINT = "172.17.63.166:5001" | ||
|
||
""" | ||
Test flow: | ||
- Create a session | ||
- Create a result | ||
- Upload data to result | ||
- Create a task and associate it with said result | ||
- Retrieve said task | ||
- Retrieve result | ||
""" | ||
|
||
# import debugpy | ||
# debugpy.listen(("localhost", 5679)) | ||
# debugpy.wait_for_client() | ||
|
||
ansi_codes = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') | ||
|
||
def remove_ansi_escapecodes(in_string: str) -> str: | ||
return ansi_codes.sub('', in_string) | ||
|
||
|
||
@pytest.mark.dependency(name="create_session") | ||
def test_create_session(): | ||
# Note: we're not testing the serialization here, but more so the interaction of the CLI with the ArmoniK API, hence the nature of this test | ||
create_result = run_cmd_and_assert_exit_code(f"session create --priority 1 --max-duration 01:00:0 --max-retries 2 --endpoint {ENDPOINT}") | ||
|
||
deserialized_created_session = json.loads(remove_ansi_escapecodes(create_result.output)) | ||
# Convert result to dict | ||
assert "SessionId" in deserialized_created_session | ||
get_result = run_cmd_and_assert_exit_code(f"session get --endpoint {ENDPOINT} {deserialized_created_session['SessionId']}") | ||
deserialized_get_session = json.loads(remove_ansi_escapecodes(get_result.output)) | ||
assert deserialized_created_session == deserialized_get_session | ||
|
||
@pytest.mark.dependency(name="create_result", depends=["create_session"]) | ||
def test_interm(): | ||
print("Setup") | ||
|
||
@pytest.mark.dependency(name="cleanup", depends=["interm"]) | ||
def test_cleanup(): | ||
print("Setup") | ||
|