SIENTIAPDE-1169
feat: add shutdown tests for Activities and Email classes - Implemented unit tests for the shutdown methods in the Activities and Email classes to ensure proper resource cleanup. - Verified that the shutdown processes for MongoDB, PostgreSQL, and Email are called as expected during the shutdown sequence.
This commit is contained in:
@@ -111,3 +111,40 @@ def test___init__(mock_postgres_init,
|
|||||||
logger=logger,
|
logger=logger,
|
||||||
notification_handler=notification_handler
|
notification_handler=notification_handler
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@patch('orchestrator.activities.mongo_db.MongoDB.__init__')
|
||||||
|
@patch('orchestrator.activities.temporal_manager.TemporalManager.__init__')
|
||||||
|
@patch('orchestrator.activities.slot_manager.SlotManager.__init__')
|
||||||
|
@patch('orchestrator.activities.formatters.Formatters.__init__')
|
||||||
|
@patch('orchestrator.activities.email.Email.__init__')
|
||||||
|
@patch('sientia_do.temporal.activities.postgres.Postgres.__init__')
|
||||||
|
@patch('orchestrator.activities.email.Email.shutdown')
|
||||||
|
@patch('sientia_do.temporal.activities.postgres.Postgres.close')
|
||||||
|
@patch('orchestrator.activities.mongo_db.MongoDB.shutdown')
|
||||||
|
def test_shutdown(mock_mongodb_close,
|
||||||
|
mock_postgres_shutdown,
|
||||||
|
mock_email_close,
|
||||||
|
mock_postgres_init,
|
||||||
|
mock_email_init,
|
||||||
|
mock_formatters_init,
|
||||||
|
mock_slot_manager_init,
|
||||||
|
mock_temporal_manager_init,
|
||||||
|
mock_mongodb_init,
|
||||||
|
):
|
||||||
|
|
||||||
|
activities = Activities(
|
||||||
|
temporal_config=MagicMock(),
|
||||||
|
redis_config=MagicMock(),
|
||||||
|
mongodb_config=MagicMock(),
|
||||||
|
email_config=MagicMock(),
|
||||||
|
postgres_config=MagicMock(),
|
||||||
|
logger=MagicMock(),
|
||||||
|
notification_handler=MagicMock()
|
||||||
|
)
|
||||||
|
|
||||||
|
activities.shutdown()
|
||||||
|
|
||||||
|
mock_mongodb_close.assert_called()
|
||||||
|
mock_postgres_shutdown.assert_called()
|
||||||
|
mock_email_close.assert_called()
|
||||||
|
|||||||
@@ -76,6 +76,12 @@ metadata = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_shutdown(email):
|
||||||
|
email.shutdown()
|
||||||
|
|
||||||
|
email.server.quit.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
@mark.asyncio
|
@mark.asyncio
|
||||||
async def test_build_email_html(email):
|
async def test_build_email_html(email):
|
||||||
email.email_builder.build_email = MagicMock(
|
email.email_builder.build_email = MagicMock(
|
||||||
|
|||||||
Reference in New Issue
Block a user