Пример #1
0
 def setUp(self):
     # If a Survol agent does not run on this machine with this port, this script starts a local one.
     _supervisor_reset()
     lib_kbase.clear_all_events()
     self._rdf_test_agent, self._agent_url = start_cgiserver(RemoteRdf2TestServerPort)
     print("AgentUrl=", self._agent_url)
     lib_kbase.set_storage_style("IOMemory",)
Пример #2
0
    def setUp(self):
        """
        https://www.sqlite.org/inmemorydb.html
        The most common way to force an SQLite database to exist purely in memory is to open the database
        using the special filename ":memory:". In other words, instead of passing the name of a real disk file,
        pass in the string ":memory:".

        When this is done, no disk file is opened. Instead, a new database is created purely in memory.
        The database ceases to exist as soon as the database connection is closed.
        Every :memory: database is distinct from every other.
        So, opening two database connections each with the filename ":memory:"
        will create two independent in-memory databases.

        In-memory databases are allowed to use shared cache if they are opened using a URI filename.
        If the unadorned ":memory:" name is used to specify the in-memory database,
        then that database always has a private cache and is this only visible to the database connection
        that originally opened it.
        However, the same in-memory database can be opened by two or more database connections as follows:

        rc = sqlite3_open("file::memory:?cache=shared", &db);

        If two or more distinct but shareable in-memory databases are needed in a single process,
        then the mode=memory query parameter can be used with a URI filename to create a named in-memory database:

        rc = sqlite3_open("file:memdb1?mode=memory&cache=shared", &db);

        https://stackoverflow.com/questions/27910829/sqlalchemy-and-sqlite-shared-cache

        """
        lib_kbase.set_storage_style("SQLAlchemy", self.sqlite_path)
Пример #3
0
    def tearDown(self):
        lib_kbase.set_storage_style(None, )

        # This destroys the database file so all tests are completely isolated.
        # TODO: Does not work with multiprocessing.
        assert os.path.exists(self.database_path)
        os.unlink(self.database_path)
        assert not os.path.exists(self.database_path)
Пример #4
0
def set_events_credentials():
    """This sets the global parameter telling where the events are stored."""
    storage_credential = lib_credentials.GetCredentials("Storage", "Events")
    if not storage_credential:
        credentials_filename = lib_credentials.credentials_filename()
        raise Exception("No storage credential in:%s" % credentials_filename)

    storage_style, storage_url = storage_credential
    lib_kbase.set_storage_style(storage_style, storage_url)
Пример #5
0
 def tearDown(self):
     stop_cgiserver(self._rdf_test_agent)
     lib_kbase.clear_all_events()
     lib_kbase.set_storage_style(None,)
Пример #6
0
    def setUp(self):
        self.database_path = create_temporary_sqlite_filename()

        self.sqlite_path = r"sqlite:///%s" % self.database_path
        lib_kbase.set_storage_style("SQLAlchemy", self.sqlite_path)
Пример #7
0
 def tearDown(self):
     lib_kbase.set_storage_style(None, )
Пример #8
0
def _connect_then_read_all_events_from_graph(expected_triple_numbers, pqueue,
                                             sqlite_path):
    lib_kbase.set_storage_style("SQLAlchemy", sqlite_path)
    _read_all_events_from_graph(expected_triple_numbers, pqueue)
Пример #9
0
 def setUp(self):
     lib_kbase.set_storage_style("IOMemory", )