Skip to content

Commit

Permalink
Added a python script file for integration testing
Browse files Browse the repository at this point in the history
  • Loading branch information
AncientPatata committed Jan 23, 2025
1 parent ba4c347 commit 2ce476e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tests = [
'pytest-cov',
'pytest-mock',
'pytest-benchmark[histogram]',
'pytest-dependency',
]
dev = [
'mypy',
Expand Down
50 changes: 50 additions & 0 deletions tests/integration.py
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")

0 comments on commit 2ce476e

Please sign in to comment.