File: test_context.py

package info (click to toggle)
python-localzone 0.9.8-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 228 kB
  • sloc: python: 521; makefile: 11
file content (29 lines) | stat: -rw-r--r-- 673 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pytest
import localzone
try:
    from dns.zonefile import UnknownOrigin
except ImportError:
    from dns.zone import UnknownOrigin

ZONEFILE = "tests/zonefiles/db.example.com"
ORIGIN = "example.com."
TTL = 3600


def test_load():
    z = localzone.load(ZONEFILE, ORIGIN)
    assert z.filename == ZONEFILE
    assert z.ttl == TTL
    assert len(z.records) == 16


def test_load_missing_origin():
    with pytest.raises(UnknownOrigin):
        localzone.load("tests/zonefiles/db.no-origin.com")


def test_manage():
    with localzone.manage(ZONEFILE, ORIGIN) as z:
        assert z.filename == ZONEFILE
        assert z.ttl == TTL
        assert len(z.records) == 16