Browse Source

Flesh out UT for new Plan.exists messaging

pull/175/head
Ross McFarland 8 years ago
parent
commit
876c09dcc0
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
1 changed files with 33 additions and 12 deletions
  1. +33
    -12
      tests/test_octodns_plan.py

+ 33
- 12
tests/test_octodns_plan.py View File

@ -16,15 +16,6 @@ from octodns.zone import Zone
from helpers import SimpleProvider from helpers import SimpleProvider
class TestPlanLogger(TestCase):
def test_invalid_level(self):
with self.assertRaises(Exception) as ctx:
PlanLogger('invalid', 'not-a-level')
self.assertEquals('Unsupported level: not-a-level',
ctx.exception.message)
simple = SimpleProvider() simple = SimpleProvider()
zone = Zone('unit.tests.', []) zone = Zone('unit.tests.', [])
existing = Record.new(zone, 'a', { existing = Record.new(zone, 'a', {
@ -48,15 +39,45 @@ create = Create(Record.new(zone, 'b', {
'type': 'CNAME', 'type': 'CNAME',
'value': 'foo.unit.tests.' 'value': 'foo.unit.tests.'
}, simple)) }, simple))
create2 = Create(Record.new(zone, 'c', {
'ttl': 60,
'type': 'CNAME',
'value': 'foo.unit.tests.'
}))
update = Update(existing, new) update = Update(existing, new)
delete = Delete(new) delete = Delete(new)
changes = [create, delete, update]
changes = [create, create2, delete, update]
plans = [ plans = [
(simple, Plan(zone, zone, changes, True)), (simple, Plan(zone, zone, changes, True)),
(simple, Plan(zone, zone, changes, True)),
(simple, Plan(zone, zone, changes, False)),
] ]
class TestPlanLogger(TestCase):
def test_invalid_level(self):
with self.assertRaises(Exception) as ctx:
PlanLogger('invalid', 'not-a-level')
self.assertEquals('Unsupported level: not-a-level',
ctx.exception.message)
def test_create(self):
class MockLogger(object):
def __init__(self):
self.out = StringIO()
def log(self, level, msg):
self.out.write(msg)
log = MockLogger()
PlanLogger('logger').run(log, plans)
out = log.out.getvalue()
self.assertTrue('Summary: Creates=2, Updates=1, '
'Deletes=1, Existing Records=0' in out)
class TestPlanHtml(TestCase): class TestPlanHtml(TestCase):
log = getLogger('TestPlanHtml') log = getLogger('TestPlanHtml')
@ -69,7 +90,7 @@ class TestPlanHtml(TestCase):
out = StringIO() out = StringIO()
PlanHtml('html').run(plans, fh=out) PlanHtml('html').run(plans, fh=out)
out = out.getvalue() out = out.getvalue()
self.assertTrue(' <td colspan=6>Summary: Creates=1, Updates=1, '
self.assertTrue(' <td colspan=6>Summary: Creates=2, Updates=1, '
'Deletes=1, Existing Records=0</td>' in out) 'Deletes=1, Existing Records=0</td>' in out)


Loading…
Cancel
Save