# pyright: reportCallIssue=false

import os
from typing import Any, Final
from behave import given, when, then
from worklib.QueryData import  query_data, query_data_place_id_variables
from worklib import admin_data
from worklib.auth_as_employer import get_access_token
from worklib.findplaceinfo.find_place_data import fetch_place_members



  # pyright: ignore[reportGeneralTypeIssues]



@when("get access token")  # pyright: ignore[reportGeneralTypeIssues]
def step_get_access_token(context):
    if not getattr(context, "access_token", None):
        token = admin_data.get_access_token_from_env()
        context.access_token = token
        admin_data.get_or_create_user("tester").access_token = token


@then("access token is valid")  # pyright: ignore[reportGeneralTypeIssues]
def step_token_is_valid(context):
    token = getattr(context, "access_token", None)
    assert isinstance(token, str) and token.strip(), f"access_token пустой/не строка: {token}"
    


