Esempio n. 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)
Esempio n. 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)
 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])
Esempio n. 4
0
 def setUp(self):
     """
     Initialize the mock settings object
     """
     self.settings = MockSettings()
     self.sysfiles_root = os.path.join(TestYCSysfiles.BASE_DIR, "tests/sys")
     django_yamlconf.load(project="ycsysfiles", settings=self.settings)
 def setUp(self):
     """
     Initialize the mock settings object
     """
     self.settings = MockSettings()
     django_yamlconf.load(project="defattrs", settings=self.settings)
     self.defattrs = django_yamlconf.defined_attributes(self.settings)
Esempio n. 6
0
 def setUp(self):
     """
     Initialize the mock settings object
     """
     self.settings = MockSettings()
     os.environ['YAMLCONF_A'] = 'a'
     os.environ['YAMLCONF_B'] = '{A}b'
     django_yamlconf.load(project="testing", settings=self.settings)
 def test_no_defined_attrs(self):
     """
     Expect empty set for no attributes
     """
     settings = MockSettings()
     self.assertEqual(
         django_yamlconf.defined_attributes(settings),
         {}
     )
Esempio n. 8
0
 def setUp(self):
     """
     Initialize the mock settings object
     """
     self.settings = MockSettings()
     os.environ['YAMLCONF_A'] = '[1, 2]'
     os.environ['YAMLCONF_B'] = '{"a": 1, "b": 2}'
     os.environ['YAMLCONF_C'] = '[1, 2'
     django_yamlconf.load(project="jsonenv", settings=self.settings)
Esempio n. 9
0
 def setUp(self):
     """
     Initialize the mock settings object
     """
     self.settings = MockSettings()
     self.settings.XMPL = 'Locally defined'
     os.environ['YAMLCONF_CONFFILE'] = os.path.join(
         os.path.dirname(__file__),
         'env.yaml',
     )
     django_yamlconf.load(project="xmpl", settings=self.settings)
Esempio n. 10
0
 def test_yclist_no_settings(self):
     """
     Explain when YAMLCONF not initialized
     """
     if hasattr(self, "assertLogs"):
         with self.assertLogs('', level='ERROR') as logs:
             django_yamlconf.list_attrs(
                 settings=MockSettings(),
                 stream=StringIO(),
             )
             self.assertIn('No YAMLCONF attributes defined', logs.output[0])
Esempio n. 11
0
 def setUp(self):
     """
     Initialize the mock settings object
     """
     self.settings = MockSettings()
     self.settings.X = "x"
     django_yamlconf.load(project="testing", settings=self.settings)
     django_yamlconf.add_attributes(self.settings, {
         'A': 'a',
         'B': '{A}b',
         'ETC_DIR': '{TOP_DIR}/etc'
     }, "**TESTING**")
Esempio n. 12
0
 def setUp(self):
     """
     Initialize the mock settings object
     """
     self.settings = MockSettings()
     self.settings.DICT1 = {}
     self.settings.DICT3 = {'v1': 'value1'}
     self.settings.LIST3 = [1, 2]
     self.settings.LIST4 = [1, 2]
     self.settings.LIST5 = [1, 2]
     self.settings.SCALAR = 10
     django_yamlconf.load(project="simplesets", settings=self.settings)
Esempio n. 13
0
 def setUp(self):
     """
     Initialize the mock settings object
     """
     self.settings = MockSettings()
 def setUp(self):
     """
     Initialize the mock settings object
     """
     self.settings = MockSettings()
     django_yamlconf.load(project="ycexplain", settings=self.settings)