From 92e87530b8ba88b14de75c5208a0e5a11a07dda5 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Mon, 10 Nov 2025 09:51:06 -0300 Subject: [PATCH] SIENTIAPDE-1325 SIENTIAPDE-1325 Update release workflow to trigger only on merged pull requests and adjust timestamp formatting in tests for consistency. --- .github/workflows/release.yml | 1 + orchestrator/activities/mongo_db.py | 6 ++++- .../orchestrator/activities/test_mongo_db.py | 22 +++++++------------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8ac1e1..438b6fb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,7 @@ on: jobs: release: + if: github.event.pull_request.merged == true uses: Aignosi/github_workflow_templates/.github/workflows/dataops-module-release.yml@main permissions: write-all with: diff --git a/orchestrator/activities/mongo_db.py b/orchestrator/activities/mongo_db.py index c831dec..16dbb2d 100644 --- a/orchestrator/activities/mongo_db.py +++ b/orchestrator/activities/mongo_db.py @@ -10,7 +10,11 @@ with workflow.unsafe.imports_passed_through(): from sientia_do.notifications.models import NotificationLevel from sientia_do.observability.sientia_monitoring import MetricsController, SientiaMonitoring from sientia_do.repository.mongodb_repository import MongoDBRepository - from sientia_do.temporal.constants import DATETIME_FORMAT_WITH_TZ, DATETIME_FORMAT_MS_WITH_TZ, now + from sientia_do.temporal.constants import ( + DATETIME_FORMAT_MS_WITH_TZ, + DATETIME_FORMAT_WITH_TZ, + now, + ) class MongoDB(SientiaMonitoring): diff --git a/tests/orchestrator/activities/test_mongo_db.py b/tests/orchestrator/activities/test_mongo_db.py index 02f2d2b..a24d5c3 100644 --- a/tests/orchestrator/activities/test_mongo_db.py +++ b/tests/orchestrator/activities/test_mongo_db.py @@ -3,7 +3,7 @@ from unittest.mock import ANY, AsyncMock, MagicMock, patch from pytest import fixture, mark from sientia_do.notifications.models import NotificationLevel -from sientia_do.temporal.constants import DATETIME_FORMAT_MS_WITH_TZ +from sientia_do.temporal.constants import DATETIME_FORMAT_MS_WITH_TZ, DATETIME_FORMAT_WITH_TZ from orchestrator.activities.mongo_db import MongoDB @@ -479,9 +479,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+0000', DATETIME_FORMAT_MS_WITH_TZ - ), + 'timestamp': '2023-01-01 12:00:00+0000', } ] ) @@ -501,7 +499,7 @@ async def test_load_latest_data_none_last_data_timestamp(mongo_db): {'workflow_name': 'test_pipeline', 'schedule_name': 'test_schedule'}, ) - assert result == [{'name': 'test1', 'value': 1, 'timestamp': '2023-01-01 12:00:00.000000+0000'}] + assert result == [{'name': 'test1', 'value': 1, 'timestamp': '2023-01-01 12:00:00+0000'}] @mark.asyncio @@ -513,9 +511,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', DATETIME_FORMAT_MS_WITH_TZ - ), + 'timestamp': '2023-01-01 12:00:00+0000', } ] ) @@ -524,7 +520,7 @@ async def test_load_latest_data_not_none_last_data_timestamp(mongo_db): { 'metadata': {'workflow_name': 'test_pipeline', 'schedule_name': 'test_schedule'}, 'collection_name': 'test_collection', - 'last_data_timestamp': '2023-01-01 12:00:00.000000+0000', + 'last_data_timestamp': '2023-01-01 12:00:00+0000', 'base_data_filter': {'level': 'ERROR'}, } ) @@ -534,15 +530,13 @@ 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', DATETIME_FORMAT_MS_WITH_TZ - ) + '$gt': datetime.strptime('2023-01-01 12:00:00+0000', DATETIME_FORMAT_WITH_TZ) }, }, {'workflow_name': 'test_pipeline', 'schedule_name': 'test_schedule'}, ) - assert result == [{'name': 'test1', 'value': 1, 'timestamp': '2023-01-01 12:00:00.000000+0000'}] + assert result == [{'name': 'test1', 'value': 1, 'timestamp': '2023-01-01 12:00:00+0000'}] @mark.asyncio @@ -555,7 +549,7 @@ async def test_load_latest_data_error(mongo_db): { 'metadata': {'workflow_name': 'test_pipeline', 'schedule_name': 'test_schedule'}, 'collection_name': 'test_collection', - 'last_data_timestamp': '2023-01-01 12:00:00.000000+0000', + 'last_data_timestamp': '2023-01-01 12:00:00+0000', 'base_data_filter': {'level': 'ERROR'}, } )