summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2021-11-28 14:26:21 -0800
committerBob Halley <halley@dnspython.org>2021-11-28 14:26:21 -0800
commitc706e26e990856311e35f46cb58eaf333e80ed2f (patch)
tree748d2680e1dcc65b3221f51f61b4f1abfe49acc0 /tests
parentb4ac6b3dc7a50ad0193270f93ab4651e53d1e796 (diff)
downloaddnspython-c706e26e990856311e35f46cb58eaf333e80ed2f.tar.gz
Fix replacement txn bugs in non-versioned zones [#732].
Diffstat (limited to 'tests')
-rw-r--r--tests/test_transaction.py29
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)