Refactor GameFeed and GameDetailView to use 'owners' instead of 'owner'; update related tests
All checks were successful
Deploy to Server / deploy (push) Successful in 10s
All checks were successful
Deploy to Server / deploy (push) Successful in 10s
This commit is contained in:
parent
6b936f4cf7
commit
77d9d448d7
4 changed files with 65 additions and 13 deletions
|
|
@ -930,6 +930,36 @@ class TestChannelListView:
|
|||
assert response.status_code == 200
|
||||
assert "game" in response.context
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_game_detail_view_serializes_owners_field(
|
||||
self,
|
||||
client: Client,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Game detail JSON payload should use `owners` (M2M), not stale `owner`."""
|
||||
org: Organization = Organization.objects.create(
|
||||
twitch_id="org-game-detail",
|
||||
name="Org Game Detail",
|
||||
)
|
||||
game: Game = Game.objects.create(
|
||||
twitch_id="g2-owners",
|
||||
name="Game2 Owners",
|
||||
display_name="Game2 Owners",
|
||||
)
|
||||
game.owners.add(org)
|
||||
|
||||
monkeypatch.setattr("twitch.views.format_and_color_json", lambda data: data)
|
||||
|
||||
url: str = reverse("twitch:game_detail", args=[game.twitch_id])
|
||||
response: _MonkeyPatchedWSGIResponse = client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
game_data: dict[str, Any] = response.context["game_data"]
|
||||
fields: dict[str, Any] = game_data["fields"]
|
||||
assert "owners" in fields
|
||||
assert fields["owners"] == [org.pk]
|
||||
assert "owner" not in fields
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_org_list_view(self, client: Client) -> None:
|
||||
"""Test org list view returns 200 and has orgs in context."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue