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 29, 2024
1 parent bba3aed commit edbe22a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/code-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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
- uses: actions/setup-python@v5
with:
python-version-file: python/understack-workflows/pyproject.toml
- run: pip install . pytest pytest-github-actions-annotate-failures
- run: pytest
11 changes: 11 additions & 0 deletions python/understack-workflows/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ 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 edbe22a

Please sign in to comment.