platform/ shadowed Python's stdlib platform module, breaking aiogram/aiohttp/multidict at import time. Renamed to sdk/ and updated all imports across core/, tests/, and adapter/telegram/.
38 lines
1 KiB
Python
38 lines
1 KiB
Python
# tests/core/test_auth.py
|
|
import pytest
|
|
from core.auth import AuthManager
|
|
from core.store import InMemoryStore
|
|
from sdk.mock import MockPlatformClient
|
|
|
|
|
|
@pytest.fixture
|
|
def mgr():
|
|
return AuthManager(MockPlatformClient(), InMemoryStore())
|
|
|
|
|
|
async def test_not_authenticated_initially(mgr):
|
|
assert await mgr.is_authenticated("u1") is False
|
|
|
|
|
|
async def test_start_flow_returns_pending(mgr):
|
|
flow = await mgr.start_flow("u1", "telegram")
|
|
assert flow.state == "pending"
|
|
assert flow.user_id == "u1"
|
|
|
|
|
|
async def test_confirm_sets_confirmed(mgr):
|
|
await mgr.start_flow("u1", "telegram")
|
|
flow = await mgr.confirm("u1")
|
|
assert flow.state == "confirmed"
|
|
|
|
|
|
async def test_is_authenticated_after_confirm(mgr):
|
|
await mgr.start_flow("u1", "telegram")
|
|
await mgr.confirm("u1")
|
|
assert await mgr.is_authenticated("u1") is True
|
|
|
|
|
|
async def test_confirm_without_start_flow(mgr):
|
|
flow = await mgr.confirm("new_user")
|
|
assert flow.state == "confirmed"
|
|
assert await mgr.is_authenticated("new_user") is True
|