def testSaveLoadReload(self): """Make sure that loading and reloading the config is a no-op.""" site_config_str = self.site_config.SaveConfigToString() loaded = config_lib.LoadConfigFromString(site_config_str) self.longMessage = True for name in self.site_config: self.assertDictEqual(loaded[name], self.site_config[name], name) # This includes templates and the default build config. self.assertEqual(self.site_config, loaded) loaded_str = loaded.SaveConfigToString() self.assertEqual(site_config_str, loaded_str) # Cycle through save load again, just for completeness. loaded2 = config_lib.LoadConfigFromString(loaded_str) loaded2_str = loaded2.SaveConfigToString() self.assertEqual(loaded_str, loaded2_str)
def _verifyLoadSave(self, site_config): """Make sure that we can save and re-load a site.""" config_str = site_config.SaveConfigToString() loaded = config_lib.LoadConfigFromString(config_str) # # BUG ALERT ON TEST FAILURE # # assertDictEqual can correctly compare these structs for equivalence, but # has a bug when displaying differences on failure. The embedded # HWTestConfig values are correctly compared, but ALWAYS display as # different, if something else triggers a failure. # # This for loop is to make differences easier to find/read. self.longMessage = True for name in site_config: self.assertDictEqual(loaded[name], site_config[name], name) # This includes templates and the default build config. self.assertEqual(site_config, loaded) loaded_str = loaded.SaveConfigToString() self.assertEqual(config_str, loaded_str) # Cycle through save load again, just for completeness. loaded2 = config_lib.LoadConfigFromString(loaded_str) loaded2_str = loaded2.SaveConfigToString() self.assertEqual(loaded_str, loaded2_str) # Make sure we can dump long content without crashing. self.assertNotEqual(site_config.DumpExpandedConfigToString(), '') self.assertNotEqual(loaded.DumpExpandedConfigToString(), '') self.assertNotEqual(loaded.DumpConfigCsv(), '') return loaded