# pyright: reportCallIssue=false

from __future__ import annotations

from behave import then, when

from Subscribe_to_bundle.testdata.subscribe_bundle_test_data import SubscribeBundleTestData


@when("prepare two places bundle tariff subscription and services")  # pyright: ignore[reportGeneralTypeIssues]
def step_prepare_bundle_flow(context) -> None:
    td = SubscribeBundleTestData.from_behave_context(context)
    td.kvs.access_token = getattr(context, "access_token", None) or td.kvs.access_token
    td.prepare_two_places_three_services_plans_subscription()
    context.bundle_place_a_id = td.place_a_id
    context.bundle_place_b_id = td.place_b_id
    context.bundle_subscriber_id = td.subscriber_id


@then("members and place services show only services for subscriber place")  # pyright: ignore[reportGeneralTypeIssues]
def step_assert_bundle_scope(context) -> None:
    td = SubscribeBundleTestData.from_behave_context(context)
    td.assert_user_sees_only_place_services_via_members_and_place()
