Esempio n. 1
0
 def test_get_entries(self):
     fileObject = TempFile(contents=b"<SettingList><Setting name='a'>1</Setting><Setting name='b'>2</Setting></SettingList>", extension=".xml")
     configuration = settings.Settings( fileObject.pathToFile() )
     entries = configuration.get_all_entries()
     self.assertEqual(len(entries), 2)
     self.assertEqual(int(entries['a']), 1)
     self.assertEqual(int(entries['b']), 2)
Esempio n. 2
0
 def test_get_named_setting(self):
     fileObject = TempFile(
         contents=
         b"<SettingList><Setting name='a'>1</Setting></SettingList>",
         extension=".xml")
     configuration = settings.Settings(fileObject.pathToFile())
     self.assertEqual(configuration.get_named_setting('a'), '1')
     self.assertRaises(KeyError, configuration.get_named_setting, 'b')
Esempio n. 3
0
 def test_avalid_file(self):
     fileObject = TempFile(
         contents=
         b"<SettingList><Setting name='test_setting'>test</Setting></SettingList>",
         extension=".xml")
     configuration = settings.Settings(fileObject.pathToFile())
     entries = configuration.get_all_entries()
     self.assertEqual(len(entries), 1,
                      "There is only one setting entry")  # Quick check
Esempio n. 4
0
 def test_get_filename(self):
     fileObject = TempFile(contents=b"<SettingList></SettingList>",
                           extension=".xml")
     configuration = settings.Settings(fileObject.pathToFile())
     self.assertEqual(configuration.get_contents_file(),
                      fileObject.pathToFile())