From 3728594b4e022e77846468d7f8e3260ed3b13029 Mon Sep 17 00:00:00 2001 From: olofvndrhr Date: Wed, 21 Feb 2024 14:59:19 +0100 Subject: [PATCH] add first test --- .gitea/workflows/check_code.yml | 2 +- .github/workflows/check_code.yml | 3 +++ dev/requirements.txt | 3 --- justfile | 3 +++ pyproject.toml | 2 ++ tests/test_source.py | 27 +++++++++++++++++++++++++++ 6 files changed, 36 insertions(+), 4 deletions(-) delete mode 100644 dev/requirements.txt create mode 100644 tests/test_source.py diff --git a/.gitea/workflows/check_code.yml b/.gitea/workflows/check_code.yml index 5fa5085..9412c69 100644 --- a/.gitea/workflows/check_code.yml +++ b/.gitea/workflows/check_code.yml @@ -11,4 +11,4 @@ jobs: check-code: uses: actions/workflows/.gitea/workflows/check_python_hatch.yml@master with: - run-tests: false + run-tests: true diff --git a/.github/workflows/check_code.yml b/.github/workflows/check_code.yml index fad3fce..24d6487 100644 --- a/.github/workflows/check_code.yml +++ b/.github/workflows/check_code.yml @@ -26,3 +26,6 @@ jobs: - name: test typing run: hatch run lint:typing + + - name: test typing + run: hatch run default:test diff --git a/dev/requirements.txt b/dev/requirements.txt deleted file mode 100644 index 0d5e557..0000000 --- a/dev/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -octodns==1.4.0 -octodns-spf==0.0.2 -octodns-netbox-dns==0.3.3 diff --git a/justfile b/justfile index 9d4e971..1e72f69 100644 --- a/justfile +++ b/justfile @@ -57,6 +57,9 @@ check: build: hatch build --clean +test: + hatch run default:test + up: docker compose -f dev/compose.yml up diff --git a/pyproject.toml b/pyproject.toml index e5bd305..6c51b5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,8 @@ python = "3.11" dependencies = [ "pytest==7.4.4", "coverage==7.4.2", + "octodns==1.4.0", + "octodns-spf==0.0.2", ] [tool.hatch.envs.default.scripts] diff --git a/tests/test_source.py b/tests/test_source.py new file mode 100644 index 0000000..7af384f --- /dev/null +++ b/tests/test_source.py @@ -0,0 +1,27 @@ +from octodns_netbox_dns import NetBoxDNSSource + + +DEFAULT_CONFIG = { + "id": 1, + "url": "https://localhost:8000", + "token": "", + "view": False, + "replace_duplicates": False, + "make_absolute": True, +} + + +def test_absolute1(): + nbdns = NetBoxDNSSource(**DEFAULT_CONFIG) + rcd = "example.com" + absolute = nbdns._make_absolute(rcd) + + assert absolute == "example.com." + + +def test_absolute2(): + nbdns = NetBoxDNSSource(**DEFAULT_CONFIG) + rcd = "example.com." + absolute = nbdns._make_absolute(rcd) + + assert absolute == "example.com."