Пример #1
0
 def test_save_objects(self):
     objs = [self.obj1, self.obj2]
     storage.save_objects(self.path, self.extension, objs)
     for obj, data in zip(objs, [self.d1, self.d2]):
         # TODO Ideally the below would work without calling convert.
         path = "%s/%s%s" % (self.path, convert.uuid_to_base32(obj.uuid), self.extension)
         self.assertTrue(os.path.exists(path))
         loaded_data = storage.load(path)
         self.assertDictEqual(data, loaded_data)
Пример #2
0
def save_celestials(path, universe):
    """
    Save all Celestial data to files under the given path.
    """
    return storage.save_objects(path, ".celestial.json", universe.celestials.values())
Пример #3
0
def save_star_systems(path, universe):
    """
    Save all StarSystem data to files under the given path.
    """
    return storage.save_objects(path, ".star_system.json", universe.star_systems.values())