From 2ff699856c9834b04a7293c58dcfa1b038b39c87 Mon Sep 17 00:00:00 2001 From: Brian Bjarke Jensen Date: Fri, 23 Feb 2024 23:29:59 +0100 Subject: [PATCH] updated and added tests --- tests/test_get_visual_communication.py | 21 +++++++++++++++++++++ tests/test_image_download.py | 1 + tests/test_total_annotated.py | 20 ++++++++++++++++++++ tests/test_total_documents.py | 20 ++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 tests/test_get_visual_communication.py create mode 100644 tests/test_total_annotated.py create mode 100644 tests/test_total_documents.py diff --git a/tests/test_get_visual_communication.py b/tests/test_get_visual_communication.py new file mode 100644 index 0000000..57e7c0b --- /dev/null +++ b/tests/test_get_visual_communication.py @@ -0,0 +1,21 @@ +from pathlib import Path +from dotenv import load_dotenv +import os + +from src.database import ( + connect, + get_visual_communication +) + +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()) + # get visual communication + vis_com = get_visual_communication(collection) + print(vis_com.image) \ No newline at end of file diff --git a/tests/test_image_download.py b/tests/test_image_download.py index d45196c..bbb6ac6 100644 --- a/tests/test_image_download.py +++ b/tests/test_image_download.py @@ -23,3 +23,4 @@ if __name__ == "__main__": print(repr(vis_com)) if data is not None: print(vis_com.image) + print(vis_com.model_dump()) diff --git a/tests/test_total_annotated.py b/tests/test_total_annotated.py new file mode 100644 index 0000000..3726870 --- /dev/null +++ b/tests/test_total_annotated.py @@ -0,0 +1,20 @@ +from pathlib import Path +from dotenv import load_dotenv +import os + +from src.database import ( + connect, + total_annotated +) + +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() + # get visual communication + num_docs = total_annotated(collection) + print(f"number of annotated documents in database: {num_docs}") \ No newline at end of file diff --git a/tests/test_total_documents.py b/tests/test_total_documents.py new file mode 100644 index 0000000..73e92c5 --- /dev/null +++ b/tests/test_total_documents.py @@ -0,0 +1,20 @@ +from pathlib import Path +from dotenv import load_dotenv +import os + +from src.database import ( + connect, + total_documents +) + +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() + # get visual communication + num_docs = total_documents(collection) + print(f"total number of documents in database: {num_docs}") \ No newline at end of file