Ejemplo n.º 1
0
    def test_apply_rdf_updates_No_files(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._updates_filename(
            updates_store._get_storage_path())

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

        map_collection = RDFCollection()
        rdf_store.load_all(map_collection)

        updates_store.apply_rdf_updates(map_collection, None)

        updates_store.empty_updates()
        self.assertFalse(os.path.exists(filepath))
Ejemplo n.º 2
0
    def test_storage_path(self):
        config = FileStorageConfiguration()
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileRDFStore(engine)

        self.assertEquals(['/tmp/rdfs'], store._get_storage_path())
        self.assertIsInstance(store.get_storage(), FileStoreConfiguration)
Ejemplo n.º 3
0
    def test_load_from_test_dir_no_subdir(self):
        config = FileStorageConfiguration()
        config._rdf_storage = FileStoreConfiguration(dirs=[os.path.dirname(__file__) + os.sep + "data" + os.sep + "rdfs" + os.sep + "text"], extension="rdf", subdirs=False, format="text", encoding="utf-8", delete_on_start=False)
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileRDFStore(engine)

        map_collection = RDFCollection()
        store.load_all(map_collection)

        self.assertTrue(map_collection.contains('ACTIVITY'))
Ejemplo n.º 4
0
    def test_apply_rdf_updates_intime(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._updates_filename(
            updates_store._get_storage_path())

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

        map_collection = RDFCollection()
        rdf_store.load_all(map_collection)

        updates_store.add_entry("subject1", "predicate1", "object1")
        updates_store.add_entry("subject2", "predicate2", "object2")

        lastDate = datetime.now()
        sleep(1)

        updates_store.add_entry("subject3", "predicate3", "object3")
        updates_store.delete_entry("subject2", None, None)

        updates_store.apply_rdf_updates(map_collection, lastDate)

        self.assertFalse(map_collection.has_subject('SUBJECT1'))
        self.assertFalse(map_collection.has_subject('SUBJECT2'))
        self.assertTrue(map_collection.has_subject('SUBJECT3'))

        updates_store.empty_updates()
        self.assertFalse(os.path.exists(filepath))
Ejemplo n.º 5
0
 def rdf_store(self):
     return FileRDFStore(self)
Ejemplo n.º 6
0
 def test_initialise(self):
     config = FileStorageConfiguration()
     engine = FileStorageEngine(config)
     engine.initialise()
     store = FileRDFStore(engine)
     self.assertEqual(store.storage_engine, engine)