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.
This commit is contained in:
11
run_coverage.sh
Executable file
11
run_coverage.sh
Executable file
@@ -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
|
||||||
18
run_local.sh
Executable file
18
run_local.sh
Executable file
@@ -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
|
||||||
@@ -5,6 +5,7 @@ from pytest import fixture, mark
|
|||||||
from orchestrator.activities.mongo_db import clear_mongo_id
|
from orchestrator.activities.mongo_db import clear_mongo_id
|
||||||
from orchestrator.activities.mongo_db import MongoDB
|
from orchestrator.activities.mongo_db import MongoDB
|
||||||
from sientia_do.notifications.models import NotificationLevel
|
from sientia_do.notifications.models import NotificationLevel
|
||||||
|
from sientia_do.temporal.constants import DATETIME_FORMAT_MS_WITH_TZ
|
||||||
|
|
||||||
|
|
||||||
def test_clear_mongo_id():
|
def test_clear_mongo_id():
|
||||||
@@ -532,7 +533,7 @@ async def test_load_latest_data_none_last_data_timestamp(mongo_db):
|
|||||||
'name': 'test1',
|
'name': 'test1',
|
||||||
'value': 1,
|
'value': 1,
|
||||||
'timestamp': datetime.strptime(
|
'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 == [{
|
assert result == [{
|
||||||
'name': 'test1',
|
'name': 'test1',
|
||||||
'value': 1,
|
'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',
|
'name': 'test1',
|
||||||
'value': 1,
|
'value': 1,
|
||||||
'timestamp': datetime.strptime(
|
'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',
|
'level': 'ERROR',
|
||||||
'timestamp': {
|
'timestamp': {
|
||||||
'$gt': datetime.strptime(
|
'$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}
|
{"_id": 0}
|
||||||
|
|||||||
Reference in New Issue
Block a user