Skip to content

Commit fd7fdb0

Browse files
author
Dale Myers
committed
Split tests into multiple files
1 parent f2d1fdd commit fd7fdb0

File tree

9 files changed

+1020
-1141
lines changed

9 files changed

+1020
-1141
lines changed

tests/conftest.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"""Configuration for tests."""
22

3+
import json
34
import os
45
import subprocess
6+
import sys
57

68
import _pytest
9+
import pytest
10+
11+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..")))
12+
import asconnect # pylint: disable=wrong-import-order
713

814

915
def pytest_configure(config: _pytest.config.Config) -> None: # type: ignore
@@ -34,3 +40,38 @@ def pytest_configure(config: _pytest.config.Config) -> None: # type: ignore
3440
continue
3541
name, value = line.split("=")
3642
os.environ[name] = value
43+
44+
45+
def get_test_data() -> tuple[str, str, str]:
46+
"""Get the test data.
47+
48+
:returns: The test data
49+
"""
50+
tests_path = os.path.dirname(os.path.abspath(__file__))
51+
test_data_path = os.path.join(tests_path, "test_data.json")
52+
with open(test_data_path, "r", encoding="utf-8") as test_data_file:
53+
all_test_data = json.load(test_data_file)
54+
55+
test_data = all_test_data["base"]
56+
57+
return test_data["key_id"], test_data["key"], test_data["issuer_id"]
58+
59+
60+
@pytest.fixture(scope="session")
61+
def client() -> asconnect.Client:
62+
"""Get the test client.
63+
64+
:returns: The test client
65+
"""
66+
key_id, key, issuer_id = get_test_data()
67+
68+
return asconnect.Client(key_id=key_id, key_contents=key, issuer_id=issuer_id)
69+
70+
71+
@pytest.fixture(scope="session")
72+
def app_id() -> str:
73+
"""Get the test app ID.
74+
75+
:returns: The test app ID
76+
"""
77+
return ""

tests/test_apps.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT license.
3+
4+
"""Tests for the package."""
5+
6+
import os
7+
import re
8+
import sys
9+
10+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..")))
11+
import asconnect # pylint: disable=wrong-import-order
12+
13+
14+
# pylint: disable=too-many-lines
15+
16+
17+
def test_get_apps(client: asconnect.Client) -> None:
18+
"""Test get apps."""
19+
20+
apps = list(client.app.get_all())
21+
assert len(apps) != 0
22+
print(apps[0])
23+
24+
25+
def test_get_app(client: asconnect.Client, app_id: str) -> None:
26+
"""Test that we can get an app."""
27+
28+
app = client.app.get_from_bundle_id(app_id)
29+
assert app is not None
30+
31+
32+
def test_get_attached_build(client: asconnect.Client, app_id: str) -> None:
33+
"""Test get attached build."""
34+
35+
app = client.app.get_from_bundle_id(app_id)
36+
assert app is not None
37+
38+
version = client.version.get_version(app_id=app.identifier, version_string="1.2.3")
39+
assert version is not None
40+
41+
build = client.version.get_attached_build(version_id=version.identifier)
42+
assert build is not None
43+
44+
45+
def test_create_new_version(client: asconnect.Client, app_id: str) -> None:
46+
"""Test that we can create a new app store version."""
47+
48+
app = client.app.get_from_bundle_id(app_id)
49+
assert app is not None
50+
51+
client.app.create_new_version(version="1.2.3", app_id=app.identifier)

0 commit comments

Comments
 (0)