updated and added tests

This commit is contained in:
Brian Bjarke Jensen
2024-02-21 20:05:56 +01:00
parent 68417a7afc
commit 3b0fbaa851
2 changed files with 39 additions and 5 deletions
+27
View File
@@ -0,0 +1,27 @@
from pathlib import Path
from dotenv import load_dotenv
from pymongo import MongoClient
from typing import List
import os
from src.database import VisualCommunication, connect
if __name__ == "__main__":
# prepare env vars
env_path = Path(__file__).parent.parent / "local.env"
assert env_path.exists()
load_dotenv(env_path)
os.environ["MONGO_HOST"] = "localhost"
# connect to database
collection, db, client = connect()
print(client.server_info())
# download images
data = None
for data in collection.find().limit(3):
if data is None:
print("no document found")
break
vis_com: VisualCommunication = VisualCommunication.model_validate(data)
print(repr(vis_com))
if data is not None:
print(vis_com.image)