def test_defaults_to_root(self): """ If a hostname doesn't map to anything, make sure to default to the root. That way we don't have to add every host under our control to zk. """ ev = threading.Event() hostname = '0.0.0.0' self.assertTrue(hostname not in fixture.ASSOCIATIONS.keys()) def cb(config): ev.set() client = JonesClient(self.client, self.service, cb, hostname) ev.wait(MAGIC_NUMBER) self.assertEquals(client.config, fixture.CONFIG['root']) self.assertTrue(ev.isSet()) ev.clear() self.jones.assoc_host(hostname, Env('parent')) ev.wait(MAGIC_NUMBER) self.assertEquals(client.config, fixture.PARENT) self.assertTrue(ev.isSet())
def setUp(self): super(TestJonesClient, self).setUp() self.config = None self.service = 'testservice' self.hostname = '127.0.0.2' self.ev = threading.Event() self.jones = Jones(self.service, self.client) fixture.init_tree(self.jones) self.jones_client = JonesClient(self.client, self.service, self.default_cb, self.hostname)