2019-08-16 22:33:19 +03:00
|
|
|
import pytest
|
|
|
|
|
|
2019-11-15 12:17:57 +02:00
|
|
|
from aiogram.bot.api import check_token
|
2019-08-16 22:33:19 +03:00
|
|
|
from aiogram.utils.exceptions import ValidationError
|
|
|
|
|
|
2019-11-15 12:17:57 +02:00
|
|
|
VALID_TOKEN = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
|
|
|
|
|
INVALID_TOKEN = "123456789:AABBCCDDEEFFaabbccddeeff 123456789" # Space in token and wrong length
|
2019-08-16 22:33:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Test_check_token:
|
|
|
|
|
def test_valid(self):
|
|
|
|
|
assert check_token(VALID_TOKEN) is True
|
|
|
|
|
|
|
|
|
|
def test_invalid_token(self):
|
|
|
|
|
with pytest.raises(ValidationError):
|
|
|
|
|
check_token(INVALID_TOKEN)
|