Пример #1
0
 def test_create_nested_dict(self):
     """
     Verify nested dict's are created
     """
     settings = MockSettings()
     settings.X = {}
     django_yamlconf.add_attributes(settings, {'X.Y.Z': 20}, "**TESTING**")
     self.assertEqual(settings.X["Y"]["Z"], 20)
Пример #2
0
 def test_nested_dict(self):
     """
     Verify setting a value within nested dicts
     """
     settings = MockSettings()
     settings.X = {"Y": {"Z": 10}}
     django_yamlconf.add_attributes(settings, {'X.Y.Z': 20}, "**TESTING**")
     self.assertEqual(settings.X["Y"]["Z"], 20)
Пример #3
0
 def test_set_non_key(self):
     """
     Check error when setting non dictionaries
     """
     if hasattr(self, "assertLogs"):
         settings = MockSettings()
         settings.X = "x"
         django_yamlconf.load(project="nosuchfile", settings=settings)
         with self.assertLogs('', level='ERROR') as logs:
             django_yamlconf.add_attributes(settings, {'X.not_there': 'a'},
                                            "**TESTING**")
             self.assertIn('Not a dictionary', logs.output[0])