Strengthen players_refactor tests to assert on actual cog method calls #39

Closed
opened 2026-02-20 06:52:44 +00:00 by cal · 1 comment
Owner

tests/players_refactor/test_team_management.py:500-524 — Tests patch api_calls.db_get, call the mock directly, catch the exception, and pass. The actual cog method is never invoked. Tests pass even if the cog code is deleted.

`tests/players_refactor/test_team_management.py:500-524` — Tests patch `api_calls.db_get`, call the mock directly, catch the exception, and pass. The actual cog method is never invoked. Tests pass even if the cog code is deleted.
cal added the
tech-debt
label 2026-02-20 06:52:44 +00:00
cal added the
ai-working
label 2026-03-05 08:31:02 +00:00
cal removed the
ai-working
label 2026-03-05 08:35:17 +00:00
Author
Owner

Opened PR #54 to fix this.

Approach: The no-op test body (which called mocks directly and swallowed exceptions without ever touching the cog) was replaced with a test that:

  1. Fetches pull_roster_command.callback from the real cog instance
  2. Patches get_context_user, get_team_by_owner, and get_rosters at cogs.players_new.team_management.*
  3. Configures get_rosters to raise Exception("Connection error")
  4. Calls the callback and asserts ctx.send received 'Could not retrieve rosters from your sheet.'

The test skips gracefully if TeamManagement can't be imported. It will fail if the method body or exception handler is deleted.

Opened PR #54 to fix this. **Approach:** The no-op test body (which called mocks directly and swallowed exceptions without ever touching the cog) was replaced with a test that: 1. Fetches `pull_roster_command.callback` from the real cog instance 2. Patches `get_context_user`, `get_team_by_owner`, and `get_rosters` at `cogs.players_new.team_management.*` 3. Configures `get_rosters` to raise `Exception("Connection error")` 4. Calls the callback and asserts `ctx.send` received `'Could not retrieve rosters from your sheet.'` The test skips gracefully if `TeamManagement` can't be imported. It will fail if the method body or exception handler is deleted.
cal added the
ai-pr-opened
label 2026-03-05 08:35:24 +00:00
cal closed this issue 2026-03-07 07:41:29 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-discord#39
No description provided.