pvl/hosts/tests.py
changeset 513 3b45b4fd5102
parent 511 99043eab9140
child 518 cd152d6bad32
equal deleted inserted replaced
512:dafac309813e 513:3b45b4fd5102
   128                 ('foo@asdf.test', dict(ip=ipaddr.IPAddress('127.0.0.1'))),
   128                 ('foo@asdf.test', dict(ip=ipaddr.IPAddress('127.0.0.1'))),
   129                 ('bar@quux.test', dict(ip=ipaddr.IPAddress('127.0.0.2'))),
   129                 ('bar@quux.test', dict(ip=ipaddr.IPAddress('127.0.0.2'))),
   130         ])
   130         ])
   131 
   131 
   132     def testApplyIncludes(self):
   132     def testApplyIncludes(self):
   133         self.assertHostsEqual(config.apply_hosts_files(self.options, ['etc/hosts/includes.test']), [
   133         self.assertHostsEqual(config.apply_hosts_files(self.options, ['etc/hosts/test/test']), [
   134                 ('foo@includes.test', dict(
   134                 ('foo@test', dict(
   135                     ip          = ipaddr.IPAddress('192.0.2.1'),
   135                     ip          = ipaddr.IPAddress('192.0.2.1'),
   136                 )),
   136                 )),
   137                 ('bar@includes.test', dict(
   137                 ('bar@test', dict(
   138                     ip          = ipaddr.IPAddress('192.0.2.2'),
   138                     ip          = ipaddr.IPAddress('192.0.2.2'),
   139                 )),
   139                 )),
   140                 ('quux@includes.test', dict(
       
   141                     ip          = ipaddr.IPAddress('192.0.2.3'),
       
   142                 )),
       
   143         ])
   140         ])
   144 
   141 
   145     def testApplyDirectory(self):
   142     def testApplyDirectory(self):
   146         self.assertHostsEqual(config.apply_hosts_files(self.options, ['etc/hosts/included.test/']), [
   143         self.assertHostsEqual(config.apply_hosts_files(self.options, ['etc/hosts/test/']), [
   147                 ('quux@asdf.included.test', dict(
   144                 ('quux@asdf.test', dict(
   148                     ip          = ipaddr.IPAddress('192.0.2.5'),
   145                     ip          = ipaddr.IPAddress('192.0.2.5'),
   149                 )),
   146                 )),
   150                 ('foo@included.test', dict(
   147                 ('foo@test', dict(
   151                     ip          = ipaddr.IPAddress('192.0.2.1'),
   148                     ip          = ipaddr.IPAddress('192.0.2.1'),
   152                 )),
   149                 )),
   153                 ('bar@included.test', dict(
   150                 ('bar@test', dict(
   154                     ip          = ipaddr.IPAddress('192.0.2.2'),
   151                     ip          = ipaddr.IPAddress('192.0.2.2'),
   155                 )),
   152                 )),
   156         ])
   153         ])
   157 
   154 
   158     def testApply(self):
   155     def testApply(self):
   159         self.assertHostsEqual(config.apply(self.options, ['etc/hosts/test']), [
   156         self.assertHostsEqual(config.apply(self.options, ['etc/hosts/example.com']), [
   160                 ('foo@test', dict(
   157                 ('foo@example.com', dict(
   161                     ip          = ipaddr.IPAddress('127.0.0.1'),
   158                     ip          = ipaddr.IPAddress('192.0.2.1'),
   162                     ethernet    = {None: '00:11:22:33:44:55'},
   159                     ethernet    = {None: '00:11:22:33:44:55'},
   163                 )),
   160                 )),
   164                 ('bar@test', dict(
   161                 ('bar@example.com', dict(
   165                     ip          = ipaddr.IPAddress('127.0.0.2'),
   162                     ip          = ipaddr.IPAddress('192.0.2.2'),
   166                     ethernet    = {None: '01:23:45:67:89:ab'},
   163                     ethernet    = {None: '01:23:45:67:89:ab'},
   167                 )),
   164                 )),
   168         ])
   165         ])
   169 
   166 
   170 class TestZoneMixin(object):
   167 class TestZoneMixin(object):