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:
vitor-aignosi
2025-08-28 09:00:39 -03:00
parent fbf006bb99
commit 8f49745b0a
3 changed files with 34 additions and 4 deletions

View File

@@ -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}