Skip to content

Commit 5506436

Browse files
gridfs tests
1 parent 82fdfa5 commit 5506436

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@
99
def mongomv_client():
1010
cl = MongoMVClient(uri=TEST_MONGO_URI)
1111
yield cl
12+
13+
14+
@pytest.fixture(scope="module")
15+
def model():
16+
client = MongoMVClient(uri=TEST_MONGO_URI)
17+
md = client.create_model(name="test_model", tags=["testing", "pytest"])
18+
yield md
19+
md.delete()

tests/test_gridfs.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import os
2+
from pathlib import Path
3+
from mongomv.schemas import ModelEntity
4+
import pytest
5+
6+
7+
@pytest.mark.usefixtures("model")
8+
class TestGridFS:
9+
10+
def test_dump_model(self, model: ModelEntity):
11+
path = Path(os.getcwd()).joinpath("text.txt")
12+
with open(path, "w") as file:
13+
file.write("This is test case for GridFS")
14+
result = model.dump_model(model_path=path, filename="text.txt")
15+
assert type(result) == str
16+
assert model.serialized_model is not None
17+
os.remove(path=path)
18+
19+
20+
def test_load_model(self, model: ModelEntity):
21+
path = Path(os.getcwd()).joinpath("text.txt")
22+
result = model.load_model(model_path=path)
23+
assert type(result) == str
24+
assert path.exists()
25+
os.remove(path=path)
26+
27+
28+
def test_delete_serialized_model(self, model: ModelEntity):
29+
result = model.delete_model()
30+
assert type(result) == str

0 commit comments

Comments
 (0)