Skip to content

Commit e4e6d92

Browse files
committed
Test Added: database
1 parent 4b9cfd6 commit e4e6d92

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/test_database.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from filexdb import FileXdb
2+
3+
4+
# Create an instance of Database
5+
db = FileXdb("test_DB", "test_data/db")
6+
db_2 = FileXdb("NewDb", "test_data/db")
7+
8+
# Create a Collection
9+
student_info = db.collection("student_info")
10+
player_info = db.collection("student_info")
11+
12+
student_info.insert_all([
13+
{"name": "Addy", "roll": "ME/57/19", "dept": "ME", "cgpa": 9.05},
14+
{"name": "Roman", "roll": "ECE/80/13", "dept": "ECE", "skill": ["game design"], "spc": ["Blinder"]},
15+
{"name": "Sam"}])
16+
17+
player_info.insert({"name": "Rana", "sport": "Cricket"})
18+
19+
20+
def test_show_collections():
21+
assert db.show_collections()
22+
db_2.show_collections()
23+
24+
25+
def test_show():
26+
assert db.show()
27+
db_2.show()
28+
29+
# prettify json object
30+
assert db.show().prettify()
31+
assert db_2.show().prettify()
32+
33+
34+
def test_export():
35+
db.export("test-db-exp", "test_data/export")
36+
db_2.export("test-db-2-exp", "test_data/export")
37+
38+

0 commit comments

Comments
 (0)