fix: add missing week field to scout reward POST
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m22s

The rewards API requires a week field. The scout claim callback was
posting without it, causing a 422 validation error when a user
selected a card from a scout opportunity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-03-09 10:18:28 -05:00
parent 1c3ef0935e
commit c875cee9ee
2 changed files with 5 additions and 1 deletions

View File

@ -11,7 +11,7 @@ import logging
import discord
from api_calls import db_post
from api_calls import db_get, db_post
from helpers.main import get_team_by_owner, get_card_embeds
from helpers.scouting import (
SCOUT_TOKENS_PER_DAY,
@ -207,12 +207,14 @@ class ScoutButton(discord.ui.Button):
)
# Consume a scout token
current = await db_get("current")
await db_post(
"rewards",
payload={
"name": "Scout Token",
"team_id": scouter_team["id"],
"season": PD_SEASON,
"week": current["week"],
"created": int_timestamp(),
},
)

View File

@ -210,12 +210,14 @@ class TestScoutButtonSuccess:
@pytest.mark.asyncio
@patch("discord_ui.scout_view.get_card_embeds", new_callable=AsyncMock)
@patch("discord_ui.scout_view.db_post", new_callable=AsyncMock)
@patch("discord_ui.scout_view.db_get", new_callable=AsyncMock)
@patch("discord_ui.scout_view.get_scout_tokens_used", new_callable=AsyncMock)
@patch("discord_ui.scout_view.get_team_by_owner", new_callable=AsyncMock)
async def test_successful_scout_creates_card_copy(
self,
mock_get_team,
mock_get_tokens,
mock_db_get,
mock_db_post,
mock_card_embeds,
sample_cards,