Skip to content

Commit

Permalink
chore: wire up some basic python unit tests
Browse files Browse the repository at this point in the history
Hook up pytest to run tests for the package
  • Loading branch information
cardoe committed Jul 30, 2024
1 parent 9d90bb9 commit a42c08b
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/code-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: code tests

on:
push:
branches:
- main
paths:
- "python/**"
- ".github/workflows/code-test.yaml"
pull_request:
paths:
- "python/**"
- ".github/workflows/code-test.yaml"
workflow_dispatch:

jobs:
understack-workflows:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./python/understack-workflows

steps:
- uses: actions/checkout@v4
- run: pipx install poetry==1.7.1 && poetry self add 'poetry-dynamic-versioning[plugin]'
- uses: actions/setup-python@v5
with:
python-version-file: python/understack-workflows/pyproject.toml
cache: "poetry"
- run: poetry install --with test
- run: poetry build
- run: poetry run pytest
73 changes: 72 additions & 1 deletion python/understack-workflows/poetry.lock

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

18 changes: 18 additions & 0 deletions python/understack-workflows/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,30 @@ python-ironicclient = "^5"
requests = "^2"
sushy = "^5"

[tool.peotry.group.test]
optional = true

[tool.poetry.group.test.dependencies]
pytest = "^7"
pytest-github-actions-annotate-failures = "*"

[tool.poetry.scripts]
synchronize-interfaces = "understack_workflows.main.synchronize_interfaces:main"
synchronize-obm-creds = "understack_workflows.main.synchronize_obm_creds:main"
synchronize-server = "understack_workflows.main.synchronize_server:main"
sync-nautobot-interfaces = "understack_workflows.main.sync_nautobot_interfaces:main"

[tool.setuptools.packages.find]
# avoid packaging up our tests
exclude = ["tests*"]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
testpaths = [
"tests",
]

[tool.ruff]
target-version = "py311"
fix = true
Expand Down
10 changes: 10 additions & 0 deletions python/understack-workflows/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from understack_workflows.models import NIC


def test_nic():
value = "test"
a = NIC(name=value, location=value, interfaces=[], model=value)

assert a.name == value
assert a.location == value
assert a.model == value

0 comments on commit a42c08b

Please sign in to comment.