Skip to content

test: restore clean test_send_status_update_async_success coverage#849

Draft
Copilot wants to merge 2 commits intobugfix/codeQL-suggestionsfrom
copilot/sub-pr-847
Draft

test: restore clean test_send_status_update_async_success coverage#849
Copilot wants to merge 2 commits intobugfix/codeQL-suggestionsfrom
copilot/sub-pr-847

Conversation

Copy link
Contributor

Copilot AI commented Mar 12, 2026

PR #847 removed test_send_status_update_async_success to eliminate a fragile if 'MagicMock' not in type_val conditional assertion, but this left the plain-string message success path of send_status_update_async (the else: message_data = str(message) branch with a live connection) without any passing test.

Changes

  • test_settings.py: Restores test_send_status_update_async_success as a clean, assertion-stable test — verifies send_text is called once and the data field matches the input string, without conditional mock-type guards:
async def test_send_status_update_async_success(self):
    config = ConnectionConfig()
    connection = AsyncMock()
    config.add_connection(process_id, connection, user_id)

    await config.send_status_update_async(message, user_id)

    connection.send_text.assert_called_once()
    sent_data = json.loads(connection.send_text.call_args[0][0])
    self.assertIn('type', sent_data)
    self.assertEqual(sent_data['data'], message)

Note: The isinstance(sys.modules['v4'], (Mock, MagicMock)) change in test_app.py and test_plan_to_mplan_converter.py is technically redundant (MagicMock is a subclass of Mock), but is harmless and left as-is.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Ayaz-Microsoft <234034413+Ayaz-Microsoft@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix implemented codeQL and copilot suggestions test: restore clean test_send_status_update_async_success coverage Mar 12, 2026
@Ayaz-Microsoft Ayaz-Microsoft requested a review from Copilot March 12, 2026 07:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores a stable unit test for the “plain string message” success path in ConnectionConfig.send_status_update_async, ensuring the else: message_data = str(message) branch is exercised when a user has an active WebSocket connection.

Changes:

  • Reintroduces test_send_status_update_async_success to validate sending a plain-string status update.
  • Asserts a single send_text call and verifies the serialized payload’s data matches the input message.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants