MCPcopy Create free account
hub / github.com/rthalley/dnspython / test_explicit_rollback_and_commit

Function test_explicit_rollback_and_commit

tests/test_transaction.py:303–358  ·  view source on GitHub ↗
(zone)

Source from the content-addressed store, hash-verified

301
302
303def test_explicit_rollback_and_commit(zone):
304 with zone.writer() as txn:
305 assert not txn.changed()
306 txn.delete(dns.name.from_text("bar.foo", None))
307 txn.rollback()
308 assert zone.get_node("bar.foo") is not None
309 with zone.writer() as txn:
310 assert not txn.changed()
311 txn.delete(dns.name.from_text("bar.foo", None))
312 txn.commit()
313 assert zone.get_node("bar.foo") is None
314 with pytest.raises(dns.transaction.AlreadyEnded):
315 with zone.writer() as txn:
316 txn.rollback()
317 txn.delete(dns.name.from_text("bar.foo", None))
318 with pytest.raises(dns.transaction.AlreadyEnded):
319 with zone.writer() as txn:
320 txn.rollback()
321 txn.add("bar.foo", 300, dns.rdata.from_text("in", "txt", "hi"))
322 with pytest.raises(dns.transaction.AlreadyEnded):
323 with zone.writer() as txn:
324 txn.rollback()
325 txn.replace("bar.foo", 300, dns.rdata.from_text("in", "txt", "hi"))
326 with pytest.raises(dns.transaction.AlreadyEnded):
327 with zone.reader() as txn:
328 txn.rollback()
329 txn.get("bar.foo", "in", "mx")
330 with pytest.raises(dns.transaction.AlreadyEnded):
331 with zone.writer() as txn:
332 txn.rollback()
333 txn.delete_exact("bar.foo")
334 with pytest.raises(dns.transaction.AlreadyEnded):
335 with zone.writer() as txn:
336 txn.rollback()
337 txn.name_exists("bar.foo")
338 with pytest.raises(dns.transaction.AlreadyEnded):
339 with zone.writer() as txn:
340 txn.rollback()
341 txn.update_serial()
342 with pytest.raises(dns.transaction.AlreadyEnded):
343 with zone.writer() as txn:
344 txn.rollback()
345 txn.changed()
346 with pytest.raises(dns.transaction.AlreadyEnded):
347 with zone.writer() as txn:
348 txn.rollback()
349 txn.rollback()
350 with pytest.raises(dns.transaction.AlreadyEnded):
351 with zone.writer() as txn:
352 txn.rollback()
353 txn.commit()
354 with pytest.raises(dns.transaction.AlreadyEnded):
355 with zone.writer() as txn:
356 txn.rollback()
357 for rdataset in txn:
358 pass
359
360

Callers

nothing calls this directly

Calls 14

changedMethod · 0.80
rollbackMethod · 0.80
commitMethod · 0.80
name_existsMethod · 0.80
update_serialMethod · 0.80
writerMethod · 0.45
deleteMethod · 0.45
from_textMethod · 0.45
get_nodeMethod · 0.45
addMethod · 0.45
replaceMethod · 0.45
readerMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…