def test_as_json(self): '''Test system as_json() exporter''' system = System() jdata = system.as_json() s_data = json.loads(jdata) self.assertTrue(s_data['name'] == system.name) self.assertTrue(s_data['hex'] == system.hex) self.assertTrue(s_data['bases'] == system.bases) self.assertTrue(s_data['allegiance'] == system.allegiance) self.assertTrue(s_data['worlds'] == system.num_worlds) self.assertTrue(s_data['Ix'] == str(system.importance_x)) self.assertTrue(s_data['Ex'] == str(system.economic_x)) self.assertTrue(s_data['Cx'] == str(system.cultural_x)) self.assertTrue(s_data['pbg'] == str(system.pbg))
def test_export_import(self): '''Test re-import of exported data''' for _ in range(SAMPLE_SIZE): syst = System() # System s_data = json.loads(syst.as_json()) LOGGER.debug('s_data type: %s', type(s_data)) LOGGER.debug('s_data: %s', s_data) self.compare_dict_to_system(s_data, syst) # Planet p_data = json.loads(syst.mainworld.as_json()) LOGGER.debug('p_data type: %s', type(p_data)) LOGGER.debug('p_data: %s', p_data) self.compare_dict_to_planet(p_data, syst.mainworld) # Star(s) st_data = json.loads(syst.stellar.as_json()) LOGGER.debug('st_data type: %s', type(st_data)) LOGGER.debug('st_data: %s', st_data) self.compare_dict_to_star(st_data, syst.stellar)