Esempio n. 1
0
 def test_dict_dict(self):
     config = _root({
         'foo': {
             'first': {
                 'bar': 1,
                 'baz': 2
             },
             'second': {
                 'bar': 3,
                 'baz': 4
             }
         }
     })
     valid = config['foo'].get(
         confuse.MappingValues({
             'bar': int,
             'baz': int
         }))
     self.assertEqual(valid, {
         'first': {
             'bar': 1,
             'baz': 2
         },
         'second': {
             'bar': 3,
             'baz': 4
         },
     })
Esempio n. 2
0
 def test_invalid_item(self):
     config = _root({
         'foo': {
             'first': {
                 'bar': 1,
                 'baz': 2
             },
             'second': {
                 'bar': 3,
                 'bak': 4
             }
         }
     })
     with self.assertRaises(confuse.NotFoundError):
         config['foo'].get(confuse.MappingValues({'bar': int, 'baz': int}))
Esempio n. 3
0
 def test_missing(self):
     config = _root({'foo': {'one': 1, 'two': 2, 'three': 3}})
     valid = config['bar'].get(confuse.MappingValues(int))
     self.assertEqual(valid, {})
Esempio n. 4
0
 def test_wrong_type(self):
     config = _root({'foo': [1, 2, 3]})
     with self.assertRaises(confuse.ConfigTypeError):
         config['foo'].get(confuse.MappingValues(int))