diff options
| author | Bob Halley <halley@dnspython.org> | 2021-11-28 14:26:21 -0800 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2021-11-28 14:26:21 -0800 |
| commit | c706e26e990856311e35f46cb58eaf333e80ed2f (patch) | |
| tree | 748d2680e1dcc65b3221f51f61b4f1abfe49acc0 /tests | |
| parent | b4ac6b3dc7a50ad0193270f93ab4651e53d1e796 (diff) | |
| download | dnspython-c706e26e990856311e35f46cb58eaf333e80ed2f.tar.gz | |
Fix replacement txn bugs in non-versioned zones [#732].
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_transaction.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_transaction.py b/tests/test_transaction.py index 85aa986..ce533c5 100644 --- a/tests/test_transaction.py +++ b/tests/test_transaction.py @@ -497,6 +497,35 @@ def test_zone_iteration(zone): actual[(name, rdataset.rdtype, rdataset.covers)] = rdataset assert actual == expected +def test_iteration_in_replacement_txn(zone): + rds = dns.rdataset.from_text('in', 'a', 300, '1.2.3.4', '5.6.7.8') + expected = {} + expected[(dns.name.empty, rds.rdtype, rds.covers)] = rds + with zone.writer(True) as txn: + txn.replace(dns.name.empty, rds) + actual = {} + for (name, rdataset) in txn: + actual[(name, rdataset.rdtype, rdataset.covers)] = rdataset + assert actual == expected + +def test_replacement_commit(zone): + rds = dns.rdataset.from_text('in', 'a', 300, '1.2.3.4', '5.6.7.8') + expected = {} + expected[(dns.name.empty, rds.rdtype, rds.covers)] = rds + with zone.writer(True) as txn: + txn.replace(dns.name.empty, rds) + with zone.reader() as txn: + actual = {} + for (name, rdataset) in txn: + actual[(name, rdataset.rdtype, rdataset.covers)] = rdataset + assert actual == expected + +def test_replacement_get(zone): + with zone.writer(True) as txn: + rds = txn.get(dns.name.empty, 'soa') + assert rds is None + + @pytest.fixture def vzone(): return dns.zone.from_text(example_text, zone_factory=dns.versioned.Zone) |
