Exemplo n.º 1
0
 def test_get_default_options(self):
     foo = ConfigMapper('/tmp')
     my_config = {'db_port':1234}
     foo.set_default_options(my_config)
     defaults = foo.get_default_options()
     actual = defaults['db_port']
     expected = 1234
     self.assertEqual(actual, expected) 
Exemplo n.º 2
0
    def test_access_mapped_configs_empty_dict(self):
        foo = ConfigMapper('/tmp/guachi')
        foo.set_ini_options(self.mapped_options)
        foo.set_default_options(self.mapped_defaults)
        foo.set_config({})

        # try as much operations as we can and assert them
        self.assertEqual(foo(), {})
        self.assertEqual(foo.path, '/tmp/guachi/guachi.db')
        self.assertEqual(foo.get_ini_options(), {})
        self.assertEqual(foo.get_default_options(), {})
        self.assertEqual(foo.get_dict_config(), self.mapped_defaults)
        self.assertEqual(foo.stored_config(), {})
        self.assertTrue(foo.integrity_check())
Exemplo n.º 3
0
    def test_access_mapped_configs_dict(self):
        foo = ConfigMapper('/tmp/guachi')
        foo.set_ini_options(self.mapped_options)
        foo.set_default_options(self.mapped_defaults)
        foo.set_config({'db_host':'example.com', 'db_port':0})

        # try as much operations as we can and assert them
        self.assertEqual(foo(), {})
        self.assertEqual(foo.path, '/tmp/guachi/guachi.db')
        self.assertEqual(foo.get_ini_options(), {})
        self.assertEqual(foo.get_default_options(), {})
        self.assertEqual(foo.get_dict_config(), 
                {u'web_port': u'8080', 
                 u'web_host': u'localhost', 
                 u'db_host': u'example.com', 
                 u'db_port': 0})
        self.assertEqual(foo.stored_config(), {})
        self.assertTrue(foo.integrity_check())