def test_dot_dict(self): key = "fake" val = utils.random_unicode() dct = {key: val} dd = utils.DotDict(dct) self.assertEqual(dd.fake, val) self.assertRaises(AttributeError, getattr, dd, "bogus")
def __init__(self, identity=None, *args, **kwargs): self.identity = identity or FakeIdentity() self.name = "fake" self.prefix = "" self.service_type = "fake" self.clients = {} self.endpoints = utils.DotDict()
def test_svc_ep_for_region_not_found(self): svc = self.service region = utils.random_unicode().upper() good_url = utils.random_unicode() bad_url = utils.random_unicode() good_ep = fakes.FakeEndpoint({"public_url": good_url}, svc.service_type, region, self.identity) bad_ep = fakes.FakeEndpoint({"public_url": bad_url}, svc.service_type, region, self.identity) svc.endpoints = utils.DotDict({region: good_ep, "other": bad_ep}) ep = svc._ep_for_region("notthere") self.assertIsNone(ep)
def test_svc_ep_for_region(self): svc = self.service region = utils.random_unicode().upper() bad_region = utils.random_unicode().upper() good_url = utils.random_unicode() bad_url = utils.random_unicode() good_ep = fakes.FakeEndpoint({"public_url": good_url}, svc.service_type, region, self.identity) bad_ep = fakes.FakeEndpoint({"public_url": bad_url}, svc.service_type, bad_region, self.identity) svc.endpoints = utils.DotDict({region: good_ep, bad_region: bad_ep}) ep = svc._ep_for_region(region) self.assertEqual(ep, good_ep)