Files
netbox-plugin-dns-bridge/netbox_dns_bridge/tests/test_smoke.py
T
sven 9f5e40ae48 Replace global IntegerKeyValueSetting with per-view CatalogZone model
Track the catalog zone SOA serial per view instead of a single global value.
The new CatalogZone model has a 1:1 FK to netbox_dns.models.View and its own
soa_serial field; each view's catalog zone now increments independently. The
existing global serial is preserved during migration by copying it into every
view's new CatalogZone row.

Change CatalogZoneMemberIdentifier.name from globally unique to unique per
catalog zone (UniqueConstraint(name, catalog_zone)) and add a catalog_zone FK
to enforce it.

Remove the dns-settings management command, which was a generic interface over
the now-removed IntegerKeyValueSetting model.

Increment both catalog zone serials when a zone moves between views: the old
view's catalog zone loses a member and the new view's gains one, so both must
be bumped. Also refresh the member identifier's catalog_zone FK on a view move
so it does not go stale. The pre_save handler now captures _old_view_id and the
post_save handler detects view changes, increments the old view's serial inside
on_commit (before the new view's), and re-creates the identifier.

AI generated, code manually verified.
2026-08-17 10:02:59 +02:00

41 lines
1.1 KiB
Python

"""Smoke test: verify the harness loads under the full NetBox stack."""
import django
def test_django_loaded():
assert django.VERSION[0] >= 5
def test_plugin_importable():
import netbox_dns_bridge # noqa: F401
assert netbox_dns_bridge.__version__
def test_models_importable():
from netbox_dns_bridge.models import (
CatalogZone,
CatalogZoneMemberIdentifier,
SeenTransferClients,
)
assert CatalogZone._meta.model_name
assert CatalogZoneMemberIdentifier._meta.model_name
assert SeenTransferClients._meta.model_name
def test_request_handler_importable():
from netbox_dns_bridge.management.commands.dns_transfer_endpoint import ( # noqa: F401
request_handler,
catalog_zone_manager,
dns_server,
)
def test_helpers_build_dns_zone():
from netbox_dns_bridge.tests._helpers import make_dns_zone
zone = make_dns_zone("example.test", soa_serial=42)
import dns.rdatatype
rds = zone.get_rdataset(zone.origin, dns.rdatatype.SOA)
assert rds is not None
assert rds[0].serial == 42