Skip to content

Commit

Permalink
Add missing reverse_zone constructor argument
Browse files Browse the repository at this point in the history
Add a simple unit test for script functions
  • Loading branch information
Ilja Bobkevic committed Nov 26, 2015
1 parent ddb6271 commit 364d2f7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
23 changes: 23 additions & 0 deletions tests/unit/test_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from tests import unittest
from tests import mock
from unbound_ec2 import script

class TestAbstractServer(unittest.TestCase):
def setUp(self):
self.id = mock.Mock()
self.cfg = mock.Mock()
script.EC2Connection = mock.MagicMock()

def tearDown(self):
self.id = None
self.cfg = None
script.EC2Connection = None

def test_init(self):
script.init(self.id, self.cfg)

def test_operate(self):
event = mock.Mock()
qstate = mock.MagicMock()
qdata = mock.Mock()
script.operate(self.id, event, qstate, qdata)
28 changes: 21 additions & 7 deletions unbound_ec2/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,27 @@ def init(id, cfg):

ec2 = EC2Connection(region=boto.ec2.get_region(conf.ec2['aws_region']))

_lookup = lookup.DirectLookup(ec2, conf.main['zone'], conf.lookup_filters, conf.lookup['tag_name_include_domain']) \
if conf.lookup['type'] == 'direct' else \
lookup.CacheLookup(ec2, conf.main['zone'], conf.lookup_filters, conf.lookup['tag_name_include_domain'])

_server = server.Authoritative(conf.main['zone'], conf.main['ttl'], _lookup, conf.main['ip_order']) \
if conf.server['type'] == 'authoritative' else \
server.Caching(conf.main['zone'], conf.main['ttl'], _lookup, conf.main['ip_order'])
_lookup = lookup.DirectLookup(ec2,
conf.main['zone'],
conf.lookup_filters,
conf.lookup['tag_name_include_domain']) \
if conf.lookup['type'] == 'direct' \
else lookup.CacheLookup(ec2,
conf.main['zone'],
conf.lookup_filters,
conf.lookup['tag_name_include_domain'])

_server = server.Authoritative(conf.main['zone'],
conf.main['reverse_zone'],
conf.main['ttl'],
_lookup,
conf.main['ip_order']) \
if conf.server['type'] == 'authoritative' \
else server.Caching(conf.main['zone'],
conf.main['reverse_zone'],
conf.main['ttl'],
_lookup,
conf.main['ip_order'])

if conf.lookup['type'] != 'direct':
_rr = repeater.RecursiveRepeater(conf.main['cache_ttl'], invalidator.CacheInvalidator(_server).invalidate)
Expand Down

0 comments on commit 364d2f7

Please sign in to comment.