diff --git a/.gitignore b/.gitignore index a598c9b..c2f8b0e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ venv/ appconfig* # Python build artifacts +.eggs/ *.egg-info/ build/ dist/ diff --git a/requirements.txt b/requirements.txt index 74d0796..589560e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,8 @@ pydantic httpx aiortc construct -dpkt \ No newline at end of file +dpkt + +wheel +pytest-runner +pytest \ No newline at end of file diff --git a/setup.py b/setup.py index 05a2c60..045adc6 100644 --- a/setup.py +++ b/setup.py @@ -24,5 +24,10 @@ "aiortc", "construct", "dpkt" - ] + ], + setup_requires=[ + "wheel", + "pytest-runner" + ], + tests_require=["pytest"] ) diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..0d71f77 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,13 @@ +from typing import Dict +import os +import pytest + +@pytest.fixture(scope='session') +def test_data() -> Dict[str, bytes]: + data = {} + data_path = os.path.join(os.path.dirname(__file__), 'data') + for f in os.listdir(data_path): + with open(os.path.join(data_path, f), 'rb') as fh: + data[f] = fh.read() + + return data \ No newline at end of file diff --git a/tests/data/.keep b/tests/data/.keep new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_appconfig.py b/tests/test_appconfig.py new file mode 100644 index 0000000..9801a84 --- /dev/null +++ b/tests/test_appconfig.py @@ -0,0 +1,15 @@ +import uuid +import json +from xcloud.common import AppConfiguration + +def test_appconfig(test_data: dict): + appconfig = test_data["appconfig_no_tokens.json"].decode('utf-8') + appconfig = json.loads(appconfig) + + config = AppConfiguration(**appconfig) + + assert config.SigningKey.startswith("-----BEGIN EC PRIVATE KEY-----\nMH") + assert config.WindowsLiveTokens is None + assert config.XalParameters is not None + assert config.ClientUUID == uuid.UUID("78af29d1-7572-4861-9ce2-1cd99830b9e7") + assert config.XalParameters.AppId == "000000004415494b" \ No newline at end of file