def testBooleanProperties(self): config = Midgard.Config() boolean_properties = {"tablecreate", "tableupdate", "gdathreads"} for prop in boolean_properties: self.assertTrue(hasattr(config.props, prop)) config.set_property(prop, True) self.assertTrue(config.get_property(prop)) config.set_property(prop, False) self.assertFalse(config.get_property(prop))
def testSaveFile(self): filepath = "/tmp/midgard_gir_test.conf" config = Midgard.Config() try: self.assertTrue( config.save_file_at_path("/This/path/not/exists.conf")) except GObject.GError as e: self.assertEqual(e.domain, "g-file-error-quark") self.assertEqual(e.code, GLib.FileError.NOENT) dbname = "SaveDBName" config.set_property("database", dbname) blobdir = "SaveBlobDir" config.set_property("blobdir", blobdir) self.assertTrue(config.save_file_at_path(filepath)) # test values new_config = Midgard.Config() self.assertTrue(new_config.read_file_at_path(filepath)) self.assertEqual(new_config.get_property("database"), dbname) self.assertEqual(new_config.get_property("blobdir"), blobdir)
def testReadFileAtPath(self): config = Midgard.Config() self.assertTrue(config.read_file_at_path("./test_SQLITE.conf")) self.assertRaises(GObject.GError, config.read_file_at_path, "notexists")