Metaname Testing Guide¶
This page explains the sandbox helpers that ship with octodns_metaname so you
can exercise the provider without touching live Metaname credentials. It covers
the fake secret resolver used in the unit tests, shows how to run CLI dry-runs
in a credential-free mode, and points to the automated test suite you can extend.
Testing resolver¶
The package exposes a lightweight resolver at
octodns_metaname.testing_resolver.resolver. It returns deterministic values so
you can run OctoDNS locally without talking to 1Password or Metaname. When it
sees a reference named ref-env it returns the string resolved-from-env,
otherwise it reports that the secret is unresolved.
from octodns_metaname.secrets import set_secret_resolver
from octodns_metaname.testing_resolver import resolver
set_secret_resolver(resolver)
# Calls to get_secret now resolve predictable dummy values
The testing resolver honours both direct environment variables and *_REF
values, mirroring the production flow without reaching out to external systems.
You can adapt the resolver for custom scenarios by monkeypatching within a test, or by writing a small wrapper that returns purpose-built values.
Resetting state¶
After running a test, call octodns_metaname.secrets.clear_secret_resolver() to
avoid leaking resolver state between cases. Pytest fixtures in the repository
handle this automatically, but the helper is useful for ad-hoc scripts.
CLI dry-runs¶
To perform command-line tests without a real Metaname account:
export OCTODNS_METANAME_SECRET_RESOLVER="octodns_metaname.testing_resolver:resolver"
python -m octodns.cmds.sync --config-file configs/config.opstest.yaml --dry-run
Switch back to the 1Password-backed resolver when you are ready to validate real credentials:
export OCTODNS_METANAME_SECRET_RESOLVER="op_opsdevnz.octodns_hooks:resolve"
Unit tests¶
Automated coverage for the client, resolver, and provider lives under
modules/octodns_metaname/tests/. Run the suite from the repository root:
./venv/bin/python -m pytest modules/octodns_metaname/tests
The tests mock Metaname responses and exercise error handling, pagination, and
planner integration. Add new cases alongside test_client.py or
test_provider.py when you extend the provider.
See the Test Suite section on the OctoDNS Metaname reference page for
generated documentation of each test module.