def test_open_existing(self): db = sqlite.SQLitePartialExpandDatabase(self.db_path) self.addCleanup(db.close) doc = db.create_doc_from_json(tests.simple_doc) # Even though create=True, we shouldn't wipe the db db2 = u1db_open(self.db_path, create=True) self.addCleanup(db2.close) doc2 = db2.get_doc(doc.doc_id) self.assertEqual(doc, doc2)
def test_open_existing_no_create(self): db = sqlite.SQLitePartialExpandDatabase(self.db_path) self.addCleanup(db.close) db2 = u1db_open(self.db_path, create=False) self.addCleanup(db2.close) self.assertIsInstance(db2, sqlite.SQLitePartialExpandDatabase)
def test_open_with_factory(self): db = u1db_open(self.db_path, create=True, document_factory=TestAlternativeDocument) self.addCleanup(db.close) self.assertEqual(TestAlternativeDocument, db._factory)
def test_open_create(self): db = u1db_open(self.db_path, create=True) self.addCleanup(db.close) self.assertTrue(os.path.exists(self.db_path)) self.assertIsInstance(db, sqlite.SQLiteDatabase)