mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Format code with black, autopep8 and isort
This commit fixes the style issues introduced indd50a9baccording to the output from black, autopep8 and isort. Details:4e472085-2e87-4f61-b7a1-ed208506962f/
This commit is contained in:
parent
dd50a9b13e
commit
af4ceef153
28 changed files with 1214 additions and 720 deletions
|
|
@ -3,25 +3,25 @@ import pytest
|
|||
from aiogram.utils.auth_widget import (check_integrity, check_token,
|
||||
generate_hash)
|
||||
|
||||
TOKEN = '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11'
|
||||
TOKEN = "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def data():
|
||||
return {
|
||||
'id': '42',
|
||||
'first_name': 'John',
|
||||
'last_name': 'Smith',
|
||||
'username': 'username',
|
||||
'photo_url': 'https://t.me/i/userpic/320/picname.jpg',
|
||||
'auth_date': '1565810688',
|
||||
'hash': 'c303db2b5a06fe41d23a9b14f7c545cfc11dcc7473c07c9c5034ae60062461ce',
|
||||
"id": "42",
|
||||
"first_name": "John",
|
||||
"last_name": "Smith",
|
||||
"username": "username",
|
||||
"photo_url": "https://t.me/i/userpic/320/picname.jpg",
|
||||
"auth_date": "1565810688",
|
||||
"hash": "c303db2b5a06fe41d23a9b14f7c545cfc11dcc7473c07c9c5034ae60062461ce",
|
||||
}
|
||||
|
||||
|
||||
def test_generate_hash(data):
|
||||
res = generate_hash(data, TOKEN)
|
||||
if res != data['hash']:
|
||||
if res != data["hash"]:
|
||||
raise AssertionError
|
||||
|
||||
|
||||
|
|
@ -29,23 +29,23 @@ class Test_check_token:
|
|||
"""
|
||||
This case gonna be deleted
|
||||
"""
|
||||
|
||||
def test_ok(self, data):
|
||||
if check_token(data, TOKEN) is not True:
|
||||
raise AssertionError
|
||||
|
||||
def test_fail(self, data):
|
||||
data.pop('username')
|
||||
data.pop("username")
|
||||
if check_token(data, TOKEN) is not False:
|
||||
raise AssertionError
|
||||
|
||||
|
||||
class Test_check_integrity:
|
||||
|
||||
def test_ok(self, data):
|
||||
if check_integrity(TOKEN, data) is not True:
|
||||
raise AssertionError
|
||||
|
||||
def test_fail(self, data):
|
||||
data.pop('username')
|
||||
data.pop("username")
|
||||
if check_integrity(TOKEN, data) is not False:
|
||||
raise AssertionError
|
||||
|
|
|
|||
|
|
@ -9,26 +9,26 @@ from tests.types import dataset
|
|||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
PAYLOADS = [
|
||||
'foo',
|
||||
'AAbbCCddEEff1122334455',
|
||||
'aaBBccDDeeFF5544332211',
|
||||
"foo",
|
||||
"AAbbCCddEEff1122334455",
|
||||
"aaBBccDDeeFF5544332211",
|
||||
-12345678901234567890,
|
||||
12345678901234567890,
|
||||
]
|
||||
|
||||
WRONG_PAYLOADS = [
|
||||
'@BotFather',
|
||||
'spaces spaces spaces',
|
||||
"@BotFather",
|
||||
"spaces spaces spaces",
|
||||
1234567890123456789.0,
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture(params=PAYLOADS, name='payload')
|
||||
@pytest.fixture(params=PAYLOADS, name="payload")
|
||||
def payload_fixture(request):
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(params=WRONG_PAYLOADS, name='wrong_payload')
|
||||
@pytest.fixture(params=WRONG_PAYLOADS, name="wrong_payload")
|
||||
def wrong_payload_fixture(request):
|
||||
return request.param
|
||||
|
||||
|
|
@ -40,9 +40,10 @@ def get_bot_user_fixture(monkeypatch):
|
|||
|
||||
async def get_bot_user_mock():
|
||||
from aiogram.types import User
|
||||
|
||||
return User(**dataset.USER)
|
||||
|
||||
monkeypatch.setattr(deep_linking, '_get_bot_user', get_bot_user_mock)
|
||||
monkeypatch.setattr(deep_linking, "_get_bot_user", get_bot_user_mock)
|
||||
|
||||
|
||||
class TestDeepLinking:
|
||||
|
|
|
|||
|
|
@ -4,13 +4,21 @@ from aiogram.utils.deprecated import DeprecatedReadOnlyClassVar
|
|||
|
||||
|
||||
def test_DeprecatedReadOnlyClassVarCD():
|
||||
if DeprecatedReadOnlyClassVar.__slots__ != ("_new_value_getter", "_warning_message"):
|
||||
if DeprecatedReadOnlyClassVar.__slots__ != (
|
||||
"_new_value_getter",
|
||||
"_warning_message",
|
||||
):
|
||||
raise AssertionError
|
||||
|
||||
new_value_of_deprecated_cls_cd = "mpa"
|
||||
deprecated_cd = DeprecatedReadOnlyClassVar("mopekaa", lambda owner: new_value_of_deprecated_cls_cd)
|
||||
deprecated_cd = DeprecatedReadOnlyClassVar(
|
||||
"mopekaa", lambda owner: new_value_of_deprecated_cls_cd
|
||||
)
|
||||
|
||||
with pytest.warns(DeprecationWarning):
|
||||
pseudo_owner_cls = type("OpekaCla$$", (), {})
|
||||
if deprecated_cd.__get__(None, pseudo_owner_cls) != new_value_of_deprecated_cls_cd:
|
||||
if (
|
||||
deprecated_cd.__get__(None, pseudo_owner_cls)
|
||||
!= new_value_of_deprecated_cls_cd
|
||||
):
|
||||
raise AssertionError
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from aiogram.utils.helper import Item, ListItem, OrderedHelper
|
|||
|
||||
|
||||
class TestOrderedHelper:
|
||||
|
||||
def test_items_are_ordered(self):
|
||||
class Helper(OrderedHelper):
|
||||
A = Item()
|
||||
|
|
@ -10,7 +9,7 @@ class TestOrderedHelper:
|
|||
C = Item()
|
||||
B = Item()
|
||||
|
||||
if Helper.all() != ['A', 'D', 'C', 'B']:
|
||||
if Helper.all() != ["A", "D", "C", "B"]:
|
||||
raise AssertionError
|
||||
|
||||
def test_list_items_are_ordered(self):
|
||||
|
|
@ -20,5 +19,5 @@ class TestOrderedHelper:
|
|||
C = ListItem()
|
||||
B = ListItem()
|
||||
|
||||
if Helper.all() != ['A', 'D', 'C', 'B']:
|
||||
if Helper.all() != ["A", "D", "C", "B"]:
|
||||
raise AssertionError
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ from aiogram.utils import markdown
|
|||
|
||||
|
||||
class TestMarkdownEscape:
|
||||
def test_equality_sign_is_escaped(self):
|
||||
if markdown.escape_md(r"e = mc2") != r"e \= mc2":
|
||||
raise AssertionError
|
||||
def test_equality_sign_is_escaped(self):
|
||||
if markdown.escape_md(r"e = mc2") != r"e \= mc2":
|
||||
raise AssertionError
|
||||
|
||||
def test_pre_escaped(self):
|
||||
if markdown.escape_md(r"hello\.") != r"hello\\\.":
|
||||
raise AssertionError
|
||||
def test_pre_escaped(self):
|
||||
if markdown.escape_md(r"hello\.") != r"hello\\\.":
|
||||
raise AssertionError
|
||||
|
|
|
|||
|
|
@ -3,25 +3,35 @@ from aiogram.utils import text_decorations
|
|||
|
||||
|
||||
class TestTextDecorations:
|
||||
def test_unparse_entities_normal_text(self):
|
||||
if text_decorations.markdown_decoration.unparse(
|
||||
"hi i'm bold and italic and still bold",
|
||||
entities=[
|
||||
MessageEntity(offset=3, length=34, type=MessageEntityType.BOLD),
|
||||
MessageEntity(offset=12, length=10, type=MessageEntityType.ITALIC),
|
||||
]
|
||||
) != "hi *i'm bold _\rand italic_\r and still bold*":
|
||||
raise AssertionError
|
||||
def test_unparse_entities_normal_text(self):
|
||||
if (
|
||||
text_decorations.markdown_decoration.unparse(
|
||||
"hi i'm bold and italic and still bold",
|
||||
entities=[
|
||||
MessageEntity(offset=3, length=34,
|
||||
type=MessageEntityType.BOLD),
|
||||
MessageEntity(offset=12, length=10,
|
||||
type=MessageEntityType.ITALIC),
|
||||
],
|
||||
)
|
||||
!= "hi *i'm bold _\rand italic_\r and still bold*"
|
||||
):
|
||||
raise AssertionError
|
||||
|
||||
def test_unparse_entities_emoji_text(self):
|
||||
"""
|
||||
emoji is encoded as two chars in json
|
||||
"""
|
||||
if text_decorations.markdown_decoration.unparse(
|
||||
"🚀 i'm bold and italic and still bold",
|
||||
entities=[
|
||||
MessageEntity(offset=3, length=34, type=MessageEntityType.BOLD),
|
||||
MessageEntity(offset=12, length=10, type=MessageEntityType.ITALIC),
|
||||
]
|
||||
) != "🚀 *i'm bold _\rand italic_\r and still bold*":
|
||||
raise AssertionError
|
||||
def test_unparse_entities_emoji_text(self):
|
||||
"""
|
||||
emoji is encoded as two chars in json
|
||||
"""
|
||||
if (
|
||||
text_decorations.markdown_decoration.unparse(
|
||||
"🚀 i'm bold and italic and still bold",
|
||||
entities=[
|
||||
MessageEntity(offset=3, length=34,
|
||||
type=MessageEntityType.BOLD),
|
||||
MessageEntity(offset=12, length=10,
|
||||
type=MessageEntityType.ITALIC),
|
||||
],
|
||||
)
|
||||
!= "🚀 *i'm bold _\rand italic_\r and still bold*"
|
||||
):
|
||||
raise AssertionError
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue