Пример #1
0
    def test_rdf_updates_other_case(self):
        config = FileStorageConfiguration()
        config._rdf_storage = FileStoreConfiguration(dirs=[
            os.path.dirname(__file__) + os.sep + "data" + os.sep + "rdfs" +
            os.sep + "text"
        ],
                                                     extension="rdf",
                                                     subdirs=True,
                                                     format="text",
                                                     encoding="utf-8",
                                                     delete_on_start=False)
        tmpdir = os.path.dirname(__file__) + os.sep + "rdf_updates"
        config.rdf_updates_storage._dirs = [tmpdir, tmpdir]
        config.rdf_updates_storage._has_single_file = True
        engine = FileStorageEngine(config)
        engine.initialise()
        updates_store = FileRDFUpdatesStore(engine)
        filepath = updates_store._updates_filename(
            updates_store._get_storage_path())

        updates_store.empty()
        self.assertFalse(os.path.exists(filepath))

        self.assertEqual(updates_store.get_storage(),
                         config.rdf_updates_storage)
Пример #2
0
    def test_save_rdf_data(self):
        config = FileStorageConfiguration()
        config._rdf_storage = FileStoreConfiguration(dirs=[
            os.path.dirname(__file__) + os.sep + "data" + os.sep + "rdfs" +
            os.sep + "text"
        ],
                                                     extension="rdf",
                                                     subdirs=True,
                                                     format="text",
                                                     encoding="utf-8",
                                                     delete_on_start=False)
        tmpdir = os.path.dirname(__file__) + os.sep + "rdf_updates"
        config.rdf_updates_storage._dirs = [tmpdir]
        config.rdf_updates_storage._has_single_file = True

        engine = FileStorageEngine(config)
        engine.initialise()
        rdf_store = FileRDFStore(engine)
        updates_store = FileRDFUpdatesStore(engine)
        filepath = updates_store._save_filename(
            updates_store._get_storage_path())

        updates_store.empty()
        self.assertFalse(os.path.exists(filepath))

        updates_store.save_rdf_data(None)
        self.assertFalse(os.path.exists(updates_store._get_storage_path()))

        map_collection = RDFCollection()
        rdf_store.load_all(map_collection)

        self.assertTrue(map_collection.contains('ACTIVITY'))
        self.assertTrue(map_collection.contains('ANIMAL'))

        updates_store.save_rdf_data(map_collection)
        self.assertTrue(os.path.exists(filepath))

        updates_store.empty()
        self.assertFalse(os.path.exists(filepath))