Skip to content

Commit e3e85bc

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

13 files changed

+1089
-1221
lines changed

poetry.lock

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pylintrc

Lines changed: 0 additions & 78 deletions
This file was deleted.

pyproject.toml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pytest = "^8.1.1"
4141
pytest-cov = "^4.1.0"
4242
pytest-dependency = "^0.5.1"
4343
types-requests = "^2.28.11.16"
44+
pylint-per-file-ignores = "^1.4.0"
4445

4546
[[tool.mypy.overrides]]
4647
module = ["deserialize"]
@@ -49,3 +50,57 @@ ignore_missing_imports = true
4950
[build-system]
5051
requires = ["poetry-core"]
5152
build-backend = "poetry.core.masonry.api"
53+
54+
55+
[tool.pylint.'MASTER']
56+
jobs = 1 # Needs to be 1 for the per_file_ignores plugin to work
57+
load-plugins = [
58+
"pylint.extensions.docparams",
59+
"pylint.extensions.overlapping_exceptions",
60+
"pylint.extensions.redefined_variable_type",
61+
"pylint.extensions.mccabe",
62+
"pylint_per_file_ignores",
63+
]
64+
per-file-ignores = ["tests/*: missing-param-doc"]
65+
66+
[tool.pylint.'MESSAGES CONTROL']
67+
disable = [
68+
"C0413", # wrong-import-position
69+
"C1801", # len-as-condition
70+
"R0801", # duplicate-code
71+
"W0511", # fixme
72+
"W0703", # broad-except
73+
"W1201", # logging-not-lazy
74+
"W1202", # logging-format-interpolation
75+
"W1203", # logging-fstring-interpolation
76+
"W3101", # missing-timeout
77+
]
78+
79+
per-file-ignores = ["tests/*:missing-param-doc"]
80+
81+
[tool.pylint.REPORTS]
82+
output-format = "parseable"
83+
84+
[tool.pylint.BASIC]
85+
good-names = ["f", "i", "j", "k", "ex", "log", "_", "exposed", "unit_test", "T"]
86+
include-naming-hint = true
87+
method-rgx = "[a-z_][a-z0-9_]{2,50}$"
88+
function-rgx = "[a-z_][a-z0-9_]{2,50}$"
89+
max-attributes = 15
90+
91+
[tool.pylint.DESIGN]
92+
min-public-methods = 0
93+
94+
[tool.pylint.FORMAT]
95+
max-line-length = 200
96+
max-statements = 75
97+
max-args = 8
98+
expected-line-ending-format = "LF"
99+
100+
[tool.pylint.'pylint.extensions.docparams']
101+
accept-no-param-doc = false
102+
accept-no-raise-doc = false
103+
accept-no-return-doc = false
104+
105+
[tool.pylint.'pylint.extensions.mccabe']
106+
max-complexity = 12

stylecheck.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22

3+
echo "==== black ===="
34
python -m black --line-length 100 asconnect tests
4-
python -m pylint --rcfile=pylintrc asconnect tests
5+
echo "==== pylint ===="
6+
python -m pylint asconnect tests
7+
echo "==== mypy ===="
58
python -m mypy --ignore-missing-imports asconnect/ tests/
69

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

0 commit comments

Comments
 (0)