Skip to content

Commit 7cd530f

Browse files
committed
fix: address Copilot review feedback
- test_base_flag.py: rewrite test_correct_chain_length to actually call await BaseFlag.is_operation_successful() with mocked data_svc and a mock operation, asserting it returns True when chain length and traits match expectations
1 parent b686f4d commit 7cd530f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

tests/app/test_base_flag.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ async def test_start_operation_calls_rest_svc(self):
4848
class TestIsOperationSuccessful:
4949
@pytest.mark.asyncio
5050
async def test_correct_chain_length(self):
51-
"""Verifies the chain-length check independently."""
51+
"""Returns True when chain length matches num_links and all traits present."""
5252
op = MagicMock()
5353
op.chain = [MagicMock()]
54+
mock_fact = MagicMock()
55+
mock_fact.trait = 'host.user.name'
56+
op.all_facts = AsyncMock(return_value=[mock_fact])
5457
services = {'data_svc': AsyncMock()}
5558
services['data_svc'].locate = AsyncMock(return_value=[op])
56-
# Patch the function to isolate the chain-length logic
57-
with patch.object(BaseFlag, 'is_operation_successful', wraps=None) as mock_fn:
58-
# Just test the underlying logic: chain length == num_links
59-
assert len(op.chain) == 1
59+
result = await BaseFlag.is_operation_successful(services, 'op1', traits=['host.user.name'], num_links=1)
60+
assert result is True
6061

6162
@pytest.mark.asyncio
6263
async def test_not_enough_links(self):

0 commit comments

Comments
 (0)