From 438aa792d953bffec5d75a621c92d92ef57c7546 Mon Sep 17 00:00:00 2001 From: Benedict Etzel Date: Wed, 31 Jan 2024 18:20:03 +0100 Subject: [PATCH] feat: expose affiliate links to chat bot --- tests/test_views.py | 10 +++++++--- twitch_hdt_ebs/views.py | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/test_views.py b/tests/test_views.py index b59355d..a1e4e35 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -358,6 +358,7 @@ def test_get_active_channels(client, mocker, requests_mock): "legend_rank": 0, "game_type": 1, "twitch_user_id": 123, + "affiliate": "TheLichKing", }) response = client.get( @@ -371,7 +372,8 @@ def test_get_active_channels(client, mocker, requests_mock): assert response.json() == [ { "channel_login": "foo_bar", - "deck_url": deck_url + "deck_url": deck_url, + "affiliate": "TheLichKing", } ] @@ -440,7 +442,8 @@ def test_get_active_channels_with_cached_deck(client, mocker, requests_mock): assert response.json() == [ { "channel_login": "foo_bar", - "deck_url": deck_url + "deck_url": deck_url, + "affiliate": None, } ] mock_get_shortid_from_deck_list.assert_not_called() @@ -493,7 +496,8 @@ def test_get_active_channels_for_bgs_game(client, mocker, requests_mock): assert response.json() == [ { "channel_login": "foo_bar", - "deck_url": None + "deck_url": None, + "affiliate": None, } ] diff --git a/twitch_hdt_ebs/views.py b/twitch_hdt_ebs/views.py index 582b406..7f76019 100644 --- a/twitch_hdt_ebs/views.py +++ b/twitch_hdt_ebs/views.py @@ -441,9 +441,12 @@ def get(self, request): sideboard=deck_sideboards ) if deck_cards else None + affiliate = details.get("affiliate") + data.append({ "channel_login": channel_login, - "deck_url": deck_url + "deck_url": deck_url, + "affiliate": affiliate, }) return Response(status=200, data=data)