Skip to content

Commit

Permalink
Improve smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
cidrblock committed Aug 14, 2023
1 parent f0294d5 commit 267c6d0
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 16 deletions.
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"ms-python.black-formatter",
"ms-python.pylint",
"charliermarsh.ruff",
"matangover.mypy",
"esbenp.prettier-vscode"
]
}
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
// Override the pyproject.toml and disable xdist to enable test debugging
"python.testing.pytestArgs": ["-n0", "--dist", "no"],
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
}
},
"mypy.runUsingActiveInterpreter": true,
"mypy.targets": ["src", "tests"],
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
30 changes: 16 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ repository = "https://github.com/ansible-community/ansible-cdk"

[tool.mypy]
strict = true
files = ["src", "tests"]


[tool.pydoclint]
allow-init-docstring = true
Expand Down Expand Up @@ -73,8 +75,8 @@ disable = [
"C0123", # unidiomatic-typecheck / ruff E721
"C0131", # typevar-double-variance / ruff PLC0131
"C0132", # typevar-name-mismatch / ruff PLC0132
"C0198", # bad-docstring-quotes / ruff Q002
"C0199", # docstring-first-line-empty / ruff D210
# "C0198", # bad-docstring-quotes / ruff Q002
# "C0199", # docstring-first-line-empty / ruff D210
"C0201", # consider-iterating-dictionary / ruff SIM118
"C0202", # bad-classmethod-argument / ruff PLC0202
"C0205", # single-string-used-for-slots / ruff PLC0205
Expand All @@ -88,9 +90,9 @@ disable = [
"C0412", # ungrouped-imports / ruff I001
"C0413", # wrong-import-position / ruff E402
"C0414", # useless-import-alias / ruff PLC0414
"C0501", # consider-using-any-or-all / ruff PLC0501
"C1901", # compare-to-empty-string / ruff PLC1901
"C2201", # misplaced-comparison-constant / ruff SIM300
# "C0501", # consider-using-any-or-all / ruff PLC0501
# "C1901", # compare-to-empty-string / ruff PLC1901
# "C2201", # misplaced-comparison-constant / ruff SIM300
"C3001", # unnecessary-lambda-assignment / ruff PLC3001
"C3002", # unnecessary-direct-lambda-call / ruff PLC3002
"E0001", # syntax-error / ruff E999
Expand Down Expand Up @@ -140,7 +142,7 @@ disable = [
"R0912", # too-many-branches / ruff PLR0912
"R0913", # too-many-arguments / ruff PLR0913
"R0915", # too-many-statements / ruff PLR0915
"R1260", # too-complex / ruff C901
# "R1260", # too-complex / ruff C901
"R1701", # consider-merging-isinstance / ruff PLR1701
"R1705", # no-else-return / ruff RET505
"R1706", # consider-using-ternary / ruff SIM108
Expand All @@ -161,10 +163,10 @@ disable = [
"R1729", # use-a-generator / ruff C417
"R1734", # use-list-literal / ruff C405
"R1735", # use-dict-literal / ruff C406
"R2004", # magic-value-comparison / ruff PLR2004
"R5501", # else-if-used / ruff PLR5501
"R6002", # consider-using-alias / ruff UP006
"R6003", # consider-alternative-union-syntax / ruff UP007
# "R2004", # magic-value-comparison / ruff PLR2004
# "R5501", # else-if-used / ruff PLR5501
# "R6002", # consider-using-alias / ruff UP006
# "R6003", # consider-alternative-union-syntax / ruff UP007
"W0102", # dangerous-default-value / ruff B006
"W0104", # pointless-statement / ruff B018
"W0106", # expression-not-assigned / ruff B018
Expand All @@ -178,7 +180,7 @@ disable = [
"W0130", # duplicate-value / ruff PLW0130
"W0131", # named-expr-without-context / ruff PLW0131
"W0150", # lost-exception / ruff B012
"W0160", # consider-ternary-expression / ruff SIM108
# "W0160", # consider-ternary-expression / ruff SIM108
"W0199", # assert-on-tuple / ruff F631
"W0301", # unnecessary-semicolon / ruff E703
"W0401", # wildcard-import / ruff F403
Expand Down Expand Up @@ -218,9 +220,9 @@ disable = [
"W1509", # subprocess-popen-preexec-fn / ruff PLW1509
"W1510", # subprocess-run-check / ruff PLW1510
"W1515", # forgotten-debug-statement / ruff T100
"W1641", # eq-without-hash / ruff PLW1641
"W2901", # redefined-loop-name / ruff PLW2901
"W3201", # bad-dunder-name / ruff PLW3201
# "W1641", # eq-without-hash / ruff PLW1641
# "W2901", # redefined-loop-name / ruff PLW2901
# "W3201", # bad-dunder-name / ruff PLW3201
"W3301", # nested-min-max / ruff PLW3301
"duplicate-code",
"fixme",
Expand Down
12 changes: 12 additions & 0 deletions src/ansible_cdk/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

"""A runpy entry point for ansible-cdk.
This makes it possible to invoke CLI
via :command:`python -m ansible_cdk`.
"""

from .cli import main


if __name__ == "__main__":
main()
19 changes: 17 additions & 2 deletions tests/integration/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
"""Basic smoke tests."""

from ansible_cdk.version_builder import PKGS
import pytest
import subprocess
import sys

def test_run() -> None:

@pytest.mark.parametrize("package", PKGS)
def test_version(package: str) -> None:
"""Placeholder."""
assert True
command = f"{sys.executable} -m ansible_cdk --version"
proc = subprocess.run(
args=command,
shell=True,
text=True,
check=True,
capture_output=True,
)
assert proc.returncode == 0
assert package in proc.stdout

0 comments on commit 267c6d0

Please sign in to comment.