|
|
|
@ -16,15 +16,6 @@ from octodns.zone import Zone |
|
|
|
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() |
|
|
|
zone = Zone('unit.tests.', []) |
|
|
|
existing = Record.new(zone, 'a', { |
|
|
|
@ -48,15 +39,45 @@ create = Create(Record.new(zone, 'b', { |
|
|
|
'type': 'CNAME', |
|
|
|
'value': 'foo.unit.tests.' |
|
|
|
}, simple)) |
|
|
|
create2 = Create(Record.new(zone, 'c', { |
|
|
|
'ttl': 60, |
|
|
|
'type': 'CNAME', |
|
|
|
'value': 'foo.unit.tests.' |
|
|
|
})) |
|
|
|
update = Update(existing, new) |
|
|
|
delete = Delete(new) |
|
|
|
changes = [create, delete, update] |
|
|
|
changes = [create, create2, delete, update] |
|
|
|
plans = [ |
|
|
|
(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): |
|
|
|
log = getLogger('TestPlanHtml') |
|
|
|
|
|
|
|
@ -69,7 +90,7 @@ class TestPlanHtml(TestCase): |
|
|
|
out = StringIO() |
|
|
|
PlanHtml('html').run(plans, fh=out) |
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
|