Skip to content

Commit bfac119

Browse files
committed
backed mode unittest added
1 parent 500e37d commit bfac119

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/testDatabase.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,28 @@ def setUp(self):
1313
self.db_file = os.path.join(self.db_path, f"{self.db_name}.asql")
1414

1515
def test_build_database(self):
16-
if os.path.exists(self.db_file): #tearDown here. We need this file
16+
if os.path.exists(self.db_file): #tearDown
1717
os.remove(self.db_file)
1818
MakeDb(adata=self.adata, db_name=self.db_name, db_path=self.db_path)
1919
self.assertTrue(os.path.exists(self.db_file))
2020

2121
def test_query_database(self):
2222
adata_sql = AnnSQL.AnnSQL(db=self.db_file)
2323
result = adata_sql.query("SELECT * FROM X")
24-
if os.path.exists(self.db_file): #tearDown here. We need this file
24+
if os.path.exists(self.db_file): #tearDown
25+
os.remove(self.db_file)
26+
self.assertEqual(len(result), self.adata.shape[0])
27+
28+
def test_backed_mode(self):
29+
self.adata = sc.datasets.pbmc3k_processed()
30+
self.adata = sc.read_h5ad("data/pbmc3k_processed.h5ad", backed="r+")
31+
MakeDb(adata=self.adata, db_name=self.db_name, db_path=self.db_path)
32+
adata_sql = AnnSQL.AnnSQL(db=self.db_file)
33+
result = adata_sql.query("SELECT * FROM X")
34+
if os.path.exists("data"): #tearDown here.
35+
os.remove("data/pbmc3k_processed.h5ad")
36+
os.rmdir("data")
37+
if os.path.exists(self.db_file): #tearDown here.
2538
os.remove(self.db_file)
2639
self.assertEqual(len(result), self.adata.shape[0])
2740

0 commit comments

Comments
 (0)