def test_settings_dict_getsection(self): settings = SettingsDict({ "a.one": 1, "a.two": 2, "b.three": 3, "four": 4, }) self.assertEquals(settings.getsection("a"), {"one": 1, "two": 2}) self.assertEquals(settings.getsection("b"), {"three": 3}) self.assertEquals(settings.getsection("c"), {}) self.assertEquals(settings.getsection(""), {"four": 4})
def test_settings_dict_setdefaults(self): settings = SettingsDict({ "a.one": 1, "a.two": 2, "b.three": 3, "four": 4, }) settings.setdefaults({"a.two": "TWO", "a.five": 5, "new": "key"}) self.assertEquals(settings.getsection("a"), {"one": 1, "two": 2, "five": 5}) self.assertEquals(settings.getsection("b"), {"three": 3}) self.assertEquals(settings.getsection("c"), {}) self.assertEquals(settings.getsection(""), {"four": 4, "new": "key"})
def test_settings_dict_setdefaults(self): settings = SettingsDict({ "a.one": 1, "a.two": 2, "b.three": 3, "four": 4, }) settings.setdefaults({"a.two": "TWO", "a.five": 5, "new": "key"}) self.assertEquals(settings.getsection("a"), { "one": 1, "two": 2, "five": 5 }) self.assertEquals(settings.getsection("b"), {"three": 3}) self.assertEquals(settings.getsection("c"), {}) self.assertEquals(settings.getsection(""), {"four": 4, "new": "key"})
def includeme(config): config.include("cornice") config.include("mozsvc") prefix = "/{api:1.0|1|1.1}/{username:[a-zA-Z0-9._-]{1,100}}" config.add_route("collections", prefix + "/info/collections") config.add_route("metaglobal", prefix + "/storage/meta/global") config.add_route("metafxa", prefix + "/storage/meta/fxa_credentials") config.add_route("cryptokeys", prefix + "/storage/crypto/keys") config.add_route("storage", prefix + "/storage") config.add_route("other", prefix + "*other") config.scan('sync11eol') settings = config.registry.settings if not isinstance(settings, SettingsDict): settings = SettingsDict(settings) mc = MemcachedClient(**settings.getsection("memcached")) config.registry["sync11eol.mcclient"] = mc