def test_open_database_with_factory(self): temp_dir = self.createTempDir(prefix='u1db-test-') path = temp_dir + '/existing.sqlite' SQLCipherDatabase(path, PASSWORD) db2 = SQLCipherDatabase.open_database( path, PASSWORD, create=False, document_factory=TestAlternativeDocument) doc = db2.create_doc({}) self.assertTrue(isinstance(doc, SoledadDocument))
def test_open_database_create(self): temp_dir = self.createTempDir(prefix='u1db-test-') path = temp_dir + '/new.sqlite' SQLCipherDatabase.open_database(path, PASSWORD, create=True) db2 = SQLCipherDatabase.open_database(path, PASSWORD, create=False) self.assertIsInstance(db2, SQLCipherDatabase)
def ensure_database(self, path): """Ensure database at the given location.""" from leap.soledad.client.sqlcipher import SQLCipherDatabase full_path = self._relpath(path) db = SQLCipherDatabase.open_database(full_path, '123', False) return db, db._replica_uid
def create_database(self, path): """Create a database at the given location.""" from leap.soledad.client.sqlcipher import SQLCipherDatabase return SQLCipherDatabase.open_database(path, '123', True)
def open_database(self, path): """Open a database at the given location.""" from leap.soledad.client.sqlcipher import SQLCipherDatabase return SQLCipherDatabase.open_database(path, '123', False)