Exemplo n.º 1
0
 def test_settings_dict_copy(self):
     settings = SettingsDict({
       "a.one": 1,
       "a.two": 2,
       "b.three": 3,
       "four": 4,
     })
     new_settings = settings.copy()
     self.assertEqual(settings, new_settings)
     self.failUnless(isinstance(new_settings, SettingsDict))
Exemplo n.º 2
0
 def test_settings_dict_copy(self):
     settings = SettingsDict({
         "a.one": 1,
         "a.two": 2,
         "b.three": 3,
         "four": 4,
     })
     new_settings = settings.copy()
     self.assertEqual(settings, new_settings)
     self.failUnless(isinstance(new_settings, SettingsDict))
Exemplo n.º 3
0
 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})
Exemplo n.º 4
0
 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})
Exemplo n.º 5
0
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
Exemplo n.º 6
0
 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"})
Exemplo n.º 7
0
 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"})