Example #1
0
    def test_load_from_test_dir_with_subdir(self):
        config = FileStorageConfiguration()
        config._maps_storage = FileStoreConfiguration(dirs=[
            os.path.dirname(__file__) + os.sep + "data" + os.sep + "maps" +
            os.sep + "text"
        ],
                                                      extension="txt",
                                                      subdirs=True,
                                                      format="text",
                                                      encoding="utf-8",
                                                      delete_on_start=False)
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileMapsStore(engine)

        map_collection = MapCollection()
        store.load_all(map_collection)

        self.assertTrue(map_collection.contains('TESTMAP'))
        the_map = map_collection.map('TESTMAP')
        self.assertIsNotNone(the_map)
        self.assertEqual("6", the_map['ANT'])

        self.assertTrue(map_collection.contains('TESTMAP2'))
        the_map = map_collection.map('TESTMAP2')
        self.assertIsNotNone(the_map)
        self.assertEqual("grrrrr", the_map['BEAR'])
Example #2
0
    def test_storage_path(self):
        config = FileStorageConfiguration()
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileMapsStore(engine)

        self.assertEquals(['/tmp/maps'], store._get_storage_path())
        self.assertIsInstance(store.get_storage(), FileStoreConfiguration)
Example #3
0
    def test_load_with_exception(self):
        config = FileStorageConfiguration()
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileMapsStore(engine)

        map_collection = MapCollection()
        store.load(
            map_collection,
            os.path.dirname(__file__) + os.sep + "data" + os.sep + "maps" +
            os.sep + "text" + os.sep + "testmap.txt")

        self.assertFalse(map_collection.contains('TESTMAP'))
Example #4
0
 def test_initialise(self):
     config = FileStorageConfiguration()
     engine = FileStorageEngine(config)
     engine.initialise()
     store = FileMapsStore(engine)
     self.assertEqual(store.storage_engine, engine)