diff --git a/src/active_month_resolver.py b/src/active_month_resolver.py index 72d0c32..2f6c0c9 100644 --- a/src/active_month_resolver.py +++ b/src/active_month_resolver.py @@ -10,7 +10,8 @@ class ActiveMonthInfoByUser(t.NamedTuple): machine_name: str ''' - Treats two bussines cases as True: owning active month content AND not owning yet, but having the payment scheduled + Treats two bussines cases the same way: + having active month content AND not owning yet, but having payment scheduled https://support.humblebundle.com/hc/en-us/articles/217300487-Humble-Choice-Early-Unlock-Games ''' is_or_will_be_owned: bool @@ -24,12 +25,11 @@ class _CantFetchActiveMonthInfo(Exception): class ActiveMonthResolver(): - def __init__(self, has_active_subscription: bool) -> None: if has_active_subscription: fetch_strategy = _get_ami_from_subscriber_fallbacking_to_marketing else: - fetch_strategy = _get_ami_from_subscriber + fetch_strategy = _get_ami_from_marketing self._fetch_strategy: ActiveMonthInfoFetchStrategy = fetch_strategy async def resolve(self, api: AuthorizedHumbleAPI) -> ActiveMonthInfoByUser: diff --git a/tests/common/test_subscriptions.py b/tests/common/test_subscriptions.py index e99c08f..2d2f1aa 100644 --- a/tests/common/test_subscriptions.py +++ b/tests/common/test_subscriptions.py @@ -5,6 +5,8 @@ from conftest import aiter import pytest +from webservice import WebpackParseError + pytestmark = pytest.mark.asyncio @@ -49,6 +51,7 @@ async def test_get_subscriptions_never_subscribed(plugin, api_mock): """) api_mock.get_user_subscription_state.return_value = subscription_state api_mock.get_subscription_products_with_gamekeys = MagicMock(return_value=aiter([])) + api_mock.get_subscriber_hub_data.side_effect = WebpackParseError() res = await plugin.get_subscriptions() @@ -136,8 +139,8 @@ async def test_get_subscriptions_past_subscriber(api_mock, plugin): """ Testcase: Currently no subscription but user was subscriber in the past Expected: owned months and additionally not owned active month + Note: I didn't check how exactly real subscription state json looks like in that case """ - # TODO: check how real subscription state json looks like in that case subscription_state = json.loads(""" { "canResubscribe": true, @@ -154,6 +157,7 @@ async def test_get_subscriptions_past_subscriber(api_mock, plugin): ] api_mock.get_user_subscription_state.return_value = subscription_state api_mock.get_subscription_products_with_gamekeys = MagicMock(return_value=aiter(content_choice_options)) + api_mock.get_subscriber_hub_data.side_effect = WebpackParseError() res = await plugin.get_subscriptions()