Skip to content

test: port TS tests for 4 low-coverage modules#23

Merged
patrick-chinchill merged 1 commit into
mainfrom
test/port-ts-coverage-tests
Apr 7, 2026
Merged

test: port TS tests for 4 low-coverage modules#23
patrick-chinchill merged 1 commit into
mainfrom
test/port-ts-coverage-tests

Conversation

@patrick-chinchill
Copy link
Copy Markdown
Collaborator

Summary

  • Port TypeScript tests to Python for 4 low-coverage modules (117 new tests total)
  • GChat format_converter (36% -> 80%+ target): 37 tests covering to_ast, from_ast, render_postable, extract_plain_text -- ported from markdown.test.ts
  • GChat workspace_events (47% -> 80%+ target): 19 tests covering create_space_subscription, list_space_subscriptions, delete_space_subscription, decode_pub_sub_message, _get_access_token -- ported from workspace-events.test.ts
  • Teams adapter (51% -> 70%+ target): 42 tests covering fetch_messages, fetch_channel_messages, open_dm, _cache_user_context, _get_access_token, _get_graph_token, _validate_service_url, HTTP helpers, Graph message mapping -- ported from index.test.ts
  • shared/buffer_utils (27% -> 80%+ target): 19 tests covering to_buffer, to_buffer_sync, buffer_to_data_uri -- ported from buffer-utils.test.ts

Test plan

  • All 117 new tests pass
  • Full suite (2767 tests) passes with no regressions
  • Ruff format + lint clean

🤖 Generated with Claude Code

Port TypeScript tests to Python for coverage improvement:
- GChat format_converter: 37 tests covering to_ast, from_ast,
  render_postable, extract_plain_text (36% -> 80%+ target)
- GChat workspace_events: 19 tests covering CRUD subscriptions,
  decode_pub_sub_message, auth token flows (47% -> 80%+ target)
- Teams adapter: 42 tests covering fetch_messages, open_dm,
  _cache_user_context, _get_access_token, _get_graph_token,
  _validate_service_url, HTTP helpers (51% -> 70%+ target)
- shared/buffer_utils: 19 tests covering to_buffer, to_buffer_sync,
  buffer_to_data_uri (27% -> 80%+ target)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread tests/test_gchat_format_extended.py Dismissed
Comment thread tests/test_gchat_workspace_events.py Dismissed
Comment thread tests/test_teams_coverage.py Dismissed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several new test files to increase code coverage across the SDK, specifically targeting buffer utilities, Google Chat format conversion, Google Chat workspace events, and the Teams adapter. The feedback focuses on improving the robustness of exception testing in test_buffer_utils.py by replacing try...except blocks with pytest.raises to avoid silent passes, and removing a redundant variable assignment in test_teams_coverage.py.

Comment on lines +67 to +70
try:
await to_buffer("invalid", "slack")
except ValidationError as e:
assert e.adapter == "slack"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This test uses a try...except block to verify that an exception is raised, but it lacks a failure condition if the exception is not raised. If to_buffer were to return normally (e.g., due to a regression where throw_on_unsupported defaults to False), the test would silently pass. Using pytest.raises is more idiomatic and ensures the test fails if the expected exception is missing.

        with pytest.raises(ValidationError) as excinfo:
            await to_buffer("invalid", "slack")
        assert excinfo.value.adapter == "slack"

Comment on lines +107 to +110
try:
to_buffer_sync("invalid", "teams")
except ValidationError as e:
assert e.adapter == "teams"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similar to the async version, this try...except pattern for testing exceptions is prone to silent passes if the function fails to raise the expected ValidationError. Refactoring to use pytest.raises makes the test more robust and readable.

        with pytest.raises(ValidationError) as excinfo:
            to_buffer_sync("invalid", "teams")
        assert excinfo.value.adapter == "teams"

Comment on lines +837 to +839
tid = "teams:abc:def"
# Encode a proper thread ID
tid = adapter.encode_thread_id(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The assignment tid = "teams:abc:def" is redundant because the variable is immediately overwritten by the result of adapter.encode_thread_id on the following lines.

        # Encode a proper thread ID
        tid = adapter.encode_thread_id(

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96c8b41b7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +67 to +70
try:
await to_buffer("invalid", "slack")
except ValidationError as e:
assert e.adapter == "slack"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Assert the expected exception is raised

test_includes_platform_in_error uses a try/except without any failure path when no exception is raised, so the test will pass even if to_buffer stops raising ValidationError. That makes this regression check ineffective and can hide breakages in error handling (the same pattern is repeated in the sync variant); use pytest.raises(...) and assert on the captured exception instead.

Useful? React with 👍 / 👎.

@patrick-chinchill patrick-chinchill merged commit 34b75cb into main Apr 7, 2026
2 of 6 checks passed
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.

2 participants