Skip to content

Split tests into multiple files #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 0 additions & 78 deletions pylintrc

This file was deleted.

55 changes: 55 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pytest = "^8.1.1"
pytest-cov = "^4.1.0"
pytest-dependency = "^0.5.1"
types-requests = "^2.28.11.16"
pylint-per-file-ignores = "^1.4.0"

[[tool.mypy.overrides]]
module = ["deserialize"]
Expand All @@ -49,3 +50,57 @@ ignore_missing_imports = true
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"


[tool.pylint.'MASTER']
jobs = 1 # Needs to be 1 for the per_file_ignores plugin to work
load-plugins = [
"pylint.extensions.docparams",
"pylint.extensions.overlapping_exceptions",
"pylint.extensions.redefined_variable_type",
"pylint.extensions.mccabe",
"pylint_per_file_ignores",
]
per-file-ignores = ["tests/*: missing-param-doc"]

[tool.pylint.'MESSAGES CONTROL']
disable = [
"C0413", # wrong-import-position
"C1801", # len-as-condition
"R0801", # duplicate-code
"W0511", # fixme
"W0703", # broad-except
"W1201", # logging-not-lazy
"W1202", # logging-format-interpolation
"W1203", # logging-fstring-interpolation
"W3101", # missing-timeout
]

per-file-ignores = ["tests/*:missing-param-doc"]

[tool.pylint.REPORTS]
output-format = "parseable"

[tool.pylint.BASIC]
good-names = ["f", "i", "j", "k", "ex", "log", "_", "exposed", "unit_test", "T"]
include-naming-hint = true
method-rgx = "[a-z_][a-z0-9_]{2,50}$"
function-rgx = "[a-z_][a-z0-9_]{2,50}$"
max-attributes = 15

[tool.pylint.DESIGN]
min-public-methods = 0

[tool.pylint.FORMAT]
max-line-length = 200
max-statements = 75
max-args = 8
expected-line-ending-format = "LF"

[tool.pylint.'pylint.extensions.docparams']
accept-no-param-doc = false
accept-no-raise-doc = false
accept-no-return-doc = false

[tool.pylint.'pylint.extensions.mccabe']
max-complexity = 12
5 changes: 4 additions & 1 deletion stylecheck.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash

echo "==== black ===="
python -m black --line-length 100 asconnect tests
python -m pylint --rcfile=pylintrc asconnect tests
echo "==== pylint ===="
python -m pylint asconnect tests
echo "==== mypy ===="
python -m mypy --ignore-missing-imports asconnect/ tests/

41 changes: 41 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
"""Configuration for tests."""

import json
import os
import subprocess
import sys

import _pytest
import pytest

sys.path.insert(0, os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..")))
import asconnect # pylint: disable=wrong-import-order


def pytest_configure(config: _pytest.config.Config) -> None: # type: ignore
Expand Down Expand Up @@ -34,3 +40,38 @@ def pytest_configure(config: _pytest.config.Config) -> None: # type: ignore
continue
name, value = line.split("=")
os.environ[name] = value


def get_test_data() -> tuple[str, str, str]:
"""Get the test data.

:returns: The test data
"""
tests_path = os.path.dirname(os.path.abspath(__file__))
test_data_path = os.path.join(tests_path, "test_data.json")
with open(test_data_path, "r", encoding="utf-8") as test_data_file:
all_test_data = json.load(test_data_file)

test_data = all_test_data["base"]

return test_data["key_id"], test_data["key"], test_data["issuer_id"]


@pytest.fixture(scope="session")
def client() -> asconnect.Client:
"""Get the test client.

:returns: The test client
"""
key_id, key, issuer_id = get_test_data()

return asconnect.Client(key_id=key_id, key_contents=key, issuer_id=issuer_id)


@pytest.fixture(scope="session")
def app_id() -> str:
"""Get the test app ID.

:returns: The test app ID
"""
return ""
50 changes: 50 additions & 0 deletions tests/test_apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

"""Tests for the package."""

import os
import sys

sys.path.insert(0, os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..")))
import asconnect # pylint: disable=wrong-import-order


# pylint: disable=too-many-lines


def test_get_apps(client: asconnect.Client) -> None:
"""Test get apps."""

apps = list(client.app.get_all())
assert len(apps) != 0
print(apps[0])


def test_get_app(client: asconnect.Client, app_id: str) -> None:
"""Test that we can get an app."""

app = client.app.get_from_bundle_id(app_id)
assert app is not None


def test_get_attached_build(client: asconnect.Client, app_id: str) -> None:
"""Test get attached build."""

app = client.app.get_from_bundle_id(app_id)
assert app is not None

version = client.version.get_version(app_id=app.identifier, version_string="1.2.3")
assert version is not None

build = client.version.get_attached_build(version_id=version.identifier)
assert build is not None


def test_create_new_version(client: asconnect.Client, app_id: str) -> None:
"""Test that we can create a new app store version."""

app = client.app.get_from_bundle_id(app_id)
assert app is not None

client.app.create_new_version(version="1.2.3", app_id=app.identifier)
Loading