Skip to content

Commit 6b2bf85

Browse files
committed
Refactor verify_graph.py and update test_verify_graph.py
- Removed unused imports from verify_graph.py to streamline the code. - Updated mock setups in test_verify_graph.py to improve clarity by replacing mock variable names with underscores, enhancing readability without changing functionality.
1 parent 45cb95d commit 6b2bf85

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

state-manager/app/tasks/verify_graph.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22
import croniter
33

4-
from datetime import datetime, timedelta
4+
from datetime import datetime
55
from beanie.operators import In
66
from json_schema_to_pydantic import create_model
77

@@ -11,7 +11,6 @@
1111
from app.singletons.logs_manager import LogsManager
1212
from app.models.trigger_models import Trigger, CronTrigger, TriggerStatusEnum, TriggerTypeEnum
1313
from app.models.db.trigger import DatabaseTriggers
14-
from app.config.settings import get_settings
1514

1615
logger = LogsManager().get_logger()
1716

state-manager/tests/unit/tasks/test_verify_graph.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ async def test_verify_graph_success(self):
385385
with patch('app.tasks.verify_graph.verify_node_exists', new_callable=AsyncMock) as mock_verify_nodes:
386386
with patch('app.tasks.verify_graph.verify_secrets', new_callable=AsyncMock) as mock_verify_secrets:
387387
with patch('app.tasks.verify_graph.verify_inputs', new_callable=AsyncMock) as mock_verify_inputs:
388-
with patch('app.tasks.verify_graph.cancel_crons', new_callable=AsyncMock) as mock_cancel_crons:
389-
with patch('app.tasks.verify_graph.create_crons', new_callable=AsyncMock) as mock_create_crons:
388+
with patch('app.tasks.verify_graph.cancel_crons', new_callable=AsyncMock) as _:
389+
with patch('app.tasks.verify_graph.create_crons', new_callable=AsyncMock) as _:
390390
mock_verify_nodes.return_value = []
391391
mock_verify_secrets.return_value = []
392392
mock_verify_inputs.return_value = []
@@ -499,8 +499,8 @@ async def test_verify_graph_with_validation_errors():
499499
patch('app.tasks.verify_graph.verify_node_exists') as mock_verify_nodes, \
500500
patch('app.tasks.verify_graph.verify_secrets') as mock_verify_secrets, \
501501
patch('app.tasks.verify_graph.verify_inputs') as mock_verify_inputs, \
502-
patch('app.tasks.verify_graph.cancel_crons', new_callable=AsyncMock) as mock_cancel_crons, \
503-
patch('app.tasks.verify_graph.create_crons', new_callable=AsyncMock) as mock_create_crons:
502+
patch('app.tasks.verify_graph.cancel_crons', new_callable=AsyncMock) as _, \
503+
patch('app.tasks.verify_graph.create_crons', new_callable=AsyncMock) as _:
504504

505505
# Mock registered nodes to return empty list
506506
mock_registered_node_cls.list_nodes_by_templates = AsyncMock(return_value=[])
@@ -539,8 +539,8 @@ async def test_verify_graph_with_valid_graph():
539539
patch('app.tasks.verify_graph.verify_node_exists') as mock_verify_nodes, \
540540
patch('app.tasks.verify_graph.verify_secrets') as mock_verify_secrets, \
541541
patch('app.tasks.verify_graph.verify_inputs') as mock_verify_inputs, \
542-
patch('app.tasks.verify_graph.cancel_crons', new_callable=AsyncMock) as mock_cancel_crons, \
543-
patch('app.tasks.verify_graph.create_crons', new_callable=AsyncMock) as mock_create_crons:
542+
patch('app.tasks.verify_graph.cancel_crons', new_callable=AsyncMock) as _, \
543+
patch('app.tasks.verify_graph.create_crons', new_callable=AsyncMock) as _:
544544

545545
# Mock registered nodes to return a valid node
546546
mock_registered_node = MagicMock()

0 commit comments

Comments
 (0)