From 8f49745b0ae1f9c1637b23aac0eb821be4f54d0c Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Thu, 28 Aug 2025 09:00:39 -0300 Subject: [PATCH] SIENTIAPDE-1205 SIENTIAPDE-1205: Update timestamp formatting in MongoDB tests - Modified timestamp handling in test_mongo_db.py to utilize DATETIME_FORMAT_MS_WITH_TZ for consistent formatting across test cases. - Ensured all timestamp strings include UTC timezone information for improved accuracy in datetime comparisons. --- run_coverage.sh | 11 +++++++++++ run_local.sh | 18 ++++++++++++++++++ tests/orchestrator/activities/test_mongo_db.py | 9 +++++---- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100755 run_coverage.sh create mode 100755 run_local.sh diff --git a/run_coverage.sh b/run_coverage.sh new file mode 100755 index 0000000..dcd534e --- /dev/null +++ b/run_coverage.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Exit on any error +set -e + +echo "Activating virtual environment..." +source ./venv/bin/activate + +pytest --cov=orchestrator --cov-report=html + +xdg-open htmlcov/index.html \ No newline at end of file diff --git a/run_local.sh b/run_local.sh new file mode 100755 index 0000000..9aaa688 --- /dev/null +++ b/run_local.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Exit on any error +set -e + +echo "Activating virtual environment..." +source ./venv/bin/activate + +echo "Loading environment variables from .env..." +if [ -f .env ]; then + export $(cat .env | grep -v '^#' | xargs) + echo "Environment variables loaded from .env" +else + echo "Warning: .env file not found. Continuing without environment variables." +fi + +echo "Starting orchestrator application..." +python -m orchestrator.app diff --git a/tests/orchestrator/activities/test_mongo_db.py b/tests/orchestrator/activities/test_mongo_db.py index 2ae912d..7dedc60 100644 --- a/tests/orchestrator/activities/test_mongo_db.py +++ b/tests/orchestrator/activities/test_mongo_db.py @@ -5,6 +5,7 @@ from pytest import fixture, mark from orchestrator.activities.mongo_db import clear_mongo_id from orchestrator.activities.mongo_db import MongoDB from sientia_do.notifications.models import NotificationLevel +from sientia_do.temporal.constants import DATETIME_FORMAT_MS_WITH_TZ def test_clear_mongo_id(): @@ -532,7 +533,7 @@ async def test_load_latest_data_none_last_data_timestamp(mongo_db): 'name': 'test1', 'value': 1, 'timestamp': datetime.strptime( - '2023-01-01 12:00:00.000000', '%Y-%m-%d %H:%M:%S.%f') + '2023-01-01 12:00:00.000000+0000', DATETIME_FORMAT_MS_WITH_TZ) } ] @@ -558,7 +559,7 @@ async def test_load_latest_data_none_last_data_timestamp(mongo_db): assert result == [{ 'name': 'test1', 'value': 1, - 'timestamp': '2023-01-01 12:00:00.000000' + 'timestamp': '2023-01-01 12:00:00.000000+0000' }] @@ -573,7 +574,7 @@ async def test_load_latest_data_not_none_last_data_timestamp(mongo_db): 'name': 'test1', 'value': 1, 'timestamp': datetime.strptime( - '2023-01-01 12:00:00.000000+0000', '%Y-%m-%d %H:%M:%S.%f%z') + '2023-01-01 12:00:00.000000+0000', DATETIME_FORMAT_MS_WITH_TZ) } ] @@ -594,7 +595,7 @@ async def test_load_latest_data_not_none_last_data_timestamp(mongo_db): 'level': 'ERROR', 'timestamp': { '$gt': datetime.strptime( - '2023-01-01 12:00:00.000000+0000', '%Y-%m-%d %H:%M:%S.%f%z') + '2023-01-01 12:00:00.000000+0000', DATETIME_FORMAT_MS_WITH_TZ) } }, {"_id": 0}