Skip to content

Commit 1b99aa2

Browse files
committed
add tests
1 parent 4393931 commit 1b99aa2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/test_gridfs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ def test_it_saves_files(self):
3030
gridfs = GridFS(self.mongo.db)
3131
assert gridfs.exists({"filename": "my-file"})
3232

33+
def test_it_saves_files_to_another_db(self):
34+
fileobj = BytesIO(b"these are the bytes")
35+
36+
self.mongo.save_file("my-file", fileobj, db="other")
37+
assert self.mongo.db is not None
38+
gridfs = GridFS(self.mongo.db)
39+
assert gridfs.exists({"filename": "my-file"})
40+
3341
def test_it_saves_files_with_props(self):
3442
fileobj = BytesIO(b"these are the bytes")
3543

@@ -65,6 +73,10 @@ def test_it_sets_content_type(self):
6573
resp = self.mongo.send_file("myfile.txt")
6674
assert resp.content_type.startswith("text/plain")
6775

76+
def test_it_sends_file_to_another_db(self):
77+
resp = self.mongo.send_file("myfile.txt", db="other")
78+
assert resp.content_type.startswith("text/plain")
79+
6880
def test_it_sets_content_length(self):
6981
resp = self.mongo.send_file("myfile.txt")
7082
assert resp.content_length == len(self.myfile.getvalue())

0 commit comments

Comments
 (0)