Add Black and Flake8

This commit is contained in:
Alex RootJunior 2019-06-29 19:53:18 +03:00
parent 5b9d82f1ca
commit 7c51b1a7d7
124 changed files with 5841 additions and 3772 deletions

View file

@ -8,7 +8,7 @@ USER = {
"first_name": "FirstName",
"last_name": "LastName",
"username": "username",
"language_code": "ru"
"language_code": "ru",
}
CHAT = {
@ -16,14 +16,14 @@ CHAT = {
"first_name": "FirstName",
"last_name": "LastName",
"username": "username",
"type": "private"
"type": "private",
}
PHOTO = {
"file_id": "AgADBAADFak0G88YZAf8OAug7bHyS9x2ZxkABHVfpJywcloRAAGAAQABAg",
"file_size": 1101,
"width": 90,
"height": 51
"height": 51,
}
AUDIO = {
@ -32,7 +32,7 @@ AUDIO = {
"title": "The Best Song",
"performer": "The Best Singer",
"file_id": "CQADAgADbQEAAsnrIUpNoRRNsH7_hAI",
"file_size": 9507774
"file_size": 9507774,
}
CHAT_MEMBER = {
@ -44,20 +44,16 @@ CHAT_MEMBER = {
"can_invite_users": True,
"can_restrict_members": True,
"can_pin_messages": True,
"can_promote_members": False
"can_promote_members": False,
}
CONTACT = {
"phone_number": "88005553535",
"first_name": "John",
"last_name": "Smith",
}
CONTACT = {"phone_number": "88005553535", "first_name": "John", "last_name": "Smith"}
DOCUMENT = {
"file_name": "test.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"file_id": "BQADAgADpgADy_JxS66XQTBRHFleAg",
"file_size": 21331
"file_size": 21331,
}
ANIMATION = {
@ -65,74 +61,46 @@ ANIMATION = {
"mime_type": "video/mp4",
"thumb": PHOTO,
"file_id": "CgADBAAD4DUAAoceZAe2WiE9y0crrAI",
"file_size": 65837
"file_size": 65837,
}
ENTITY_BOLD = {
"offset": 5,
"length": 2,
"type": "bold"
}
ENTITY_BOLD = {"offset": 5, "length": 2, "type": "bold"}
ENTITY_ITALIC = {
"offset": 8,
"length": 1,
"type": "italic"
}
ENTITY_ITALIC = {"offset": 8, "length": 1, "type": "italic"}
ENTITY_LINK = {
"offset": 10,
"length": 6,
"type": "text_link",
"url": "http://google.com/"
}
ENTITY_LINK = {"offset": 10, "length": 6, "type": "text_link", "url": "http://google.com/"}
ENTITY_CODE = {
"offset": 17,
"length": 7,
"type": "code"
}
ENTITY_CODE = {"offset": 17, "length": 7, "type": "code"}
ENTITY_PRE = {
"offset": 30,
"length": 4,
"type": "pre"
}
ENTITY_PRE = {"offset": 30, "length": 4, "type": "pre"}
ENTITY_MENTION = {
"offset": 47,
"length": 9,
"type": "mention"
}
ENTITY_MENTION = {"offset": 47, "length": 9, "type": "mention"}
GAME = {
"title": "Karate Kido",
"description": "No trees were harmed in the making of this game :)",
"photo": [PHOTO, PHOTO, PHOTO],
"animation": ANIMATION
"animation": ANIMATION,
}
INVOICE = {
"title": "Working Time Machine",
"description": "Want to visit your great-great-great-grandparents? "
"Make a fortune at the races? "
"Shake hands with Hammurabi and take a stroll in the Hanging Gardens? "
"Order our Working Time Machine today!",
"Make a fortune at the races? "
"Shake hands with Hammurabi and take a stroll in the Hanging Gardens? "
"Order our Working Time Machine today!",
"start_parameter": "time-machine-example",
"currency": "USD",
"total_amount": 6250
"total_amount": 6250,
}
LOCATION = {
"latitude": 50.693416,
"longitude": 30.624605
}
LOCATION = {"latitude": 50.693416, "longitude": 30.624605}
VENUE = {
"location": LOCATION,
"title": "Venue Name",
"address": "Venue Address",
"foursquare_id": "4e6f2cec483bad563d150f98"
"foursquare_id": "4e6f2cec483bad563d150f98",
}
SHIPPING_ADDRESS = {
@ -141,7 +109,7 @@ SHIPPING_ADDRESS = {
"city": "DefaultCity",
"street_line1": "Central",
"street_line2": "Middle",
"post_code": "424242"
"post_code": "424242",
}
STICKER = {
@ -153,10 +121,10 @@ STICKER = {
"file_id": "AAbbCCddEEffGGhh1234567890",
"file_size": 1234,
"width": 128,
"height": 128
"height": 128,
},
"file_id": "AAbbCCddEEffGGhh1234567890",
"file_size": 12345
"file_size": 12345,
}
SUCCESSFUL_PAYMENT = {
@ -164,7 +132,7 @@ SUCCESSFUL_PAYMENT = {
"total_amount": 6250,
"invoice_payload": "HAPPY FRIDAYS COUPON",
"telegram_payment_charge_id": "_",
"provider_payment_charge_id": "12345678901234_test"
"provider_payment_charge_id": "12345678901234_test",
}
VIDEO = {
@ -174,7 +142,7 @@ VIDEO = {
"mime_type": "video/quicktime",
"thumb": PHOTO,
"file_id": "BAADAgpAADdawy_JxS72kRvV3cortAg",
"file_size": 10099782
"file_size": 10099782,
}
VIDEO_NOTE = {
@ -182,14 +150,14 @@ VIDEO_NOTE = {
"length": 240,
"thumb": PHOTO,
"file_id": "AbCdEfGhIjKlMnOpQrStUvWxYz",
"file_size": 186562
"file_size": 186562,
}
VOICE = {
"duration": 1,
"mime_type": "audio/ogg",
"file_id": "AwADawAgADADy_JxS2gopIVIIxlhAg",
"file_size": 4321
"file_size": 4321,
}
CALLBACK_QUERY = {}
@ -206,7 +174,7 @@ EDITED_MESSAGE = {
"chat": CHAT,
"date": 1508825372,
"edit_date": 1508825379,
"text": "hi there (edited)"
"text": "hi there (edited)",
}
FORWARDED_MESSAGE = {
@ -218,8 +186,15 @@ FORWARDED_MESSAGE = {
"forward_from_message_id": 123,
"forward_date": 1522749037,
"text": "Forwarded text with entities from public channel ",
"entities": [ENTITY_BOLD, ENTITY_CODE, ENTITY_ITALIC, ENTITY_LINK,
ENTITY_LINK, ENTITY_MENTION, ENTITY_PRE]
"entities": [
ENTITY_BOLD,
ENTITY_CODE,
ENTITY_ITALIC,
ENTITY_LINK,
ENTITY_LINK,
ENTITY_MENTION,
ENTITY_PRE,
],
}
INLINE_QUERY = {}
@ -229,7 +204,7 @@ MESSAGE = {
"from": USER,
"chat": CHAT,
"date": 1508709711,
"text": "Hi, world!"
"text": "Hi, world!",
}
MESSAGE_WITH_AUDIO = {
@ -238,7 +213,7 @@ MESSAGE_WITH_AUDIO = {
"chat": CHAT,
"date": 1508739776,
"audio": AUDIO,
"caption": "This is my favourite song"
"caption": "This is my favourite song",
}
MESSAGE_WITH_AUTHOR_SIGNATURE = {}
@ -250,7 +225,7 @@ MESSAGE_WITH_CONTACT = {
"from": USER,
"chat": CHAT,
"date": 1522850298,
"contact": CONTACT
"contact": CONTACT,
}
MESSAGE_WITH_DELETE_CHAT_PHOTO = {}
@ -261,7 +236,7 @@ MESSAGE_WITH_DOCUMENT = {
"chat": CHAT,
"date": 1508768012,
"document": DOCUMENT,
"caption": "Read my document"
"caption": "Read my document",
}
MESSAGE_WITH_EDIT_DATE = {}
@ -273,7 +248,7 @@ MESSAGE_WITH_GAME = {
"from": USER,
"chat": CHAT,
"date": 1508824810,
"game": GAME
"game": GAME,
}
MESSAGE_WITH_GROUP_CHAT_CREATED = {}
@ -283,7 +258,7 @@ MESSAGE_WITH_INVOICE = {
"from": USER,
"chat": CHAT,
"date": 1508761719,
"invoice": INVOICE
"invoice": INVOICE,
}
MESSAGE_WITH_LEFT_CHAT_MEMBER = {}
@ -293,7 +268,7 @@ MESSAGE_WITH_LOCATION = {
"from": USER,
"chat": CHAT,
"date": 1508755473,
"location": LOCATION
"location": LOCATION,
}
MESSAGE_WITH_MIGRATE_TO_CHAT_ID = {
@ -301,7 +276,7 @@ MESSAGE_WITH_MIGRATE_TO_CHAT_ID = {
"from": USER,
"chat": CHAT,
"date": 1526943253,
"migrate_to_chat_id": -1234567890987
"migrate_to_chat_id": -1234567890987,
}
MESSAGE_WITH_MIGRATE_FROM_CHAT_ID = {
@ -309,7 +284,7 @@ MESSAGE_WITH_MIGRATE_FROM_CHAT_ID = {
"from": USER,
"chat": CHAT,
"date": 1526943253,
"migrate_from_chat_id": -123456789
"migrate_from_chat_id": -123456789,
}
MESSAGE_WITH_NEW_CHAT_MEMBERS = {}
@ -324,7 +299,7 @@ MESSAGE_WITH_PHOTO = {
"chat": CHAT,
"date": 1508825154,
"photo": [PHOTO, PHOTO, PHOTO, PHOTO],
"caption": "photo description"
"caption": "photo description",
}
MESSAGE_WITH_MEDIA_GROUP = {
@ -333,7 +308,7 @@ MESSAGE_WITH_MEDIA_GROUP = {
"chat": CHAT,
"date": 1522843665,
"media_group_id": "12182749320567362",
"photo": [PHOTO, PHOTO, PHOTO, PHOTO]
"photo": [PHOTO, PHOTO, PHOTO, PHOTO],
}
MESSAGE_WITH_PINNED_MESSAGE = {}
@ -345,7 +320,7 @@ MESSAGE_WITH_STICKER = {
"from": USER,
"chat": CHAT,
"date": 1508771450,
"sticker": STICKER
"sticker": STICKER,
}
MESSAGE_WITH_SUCCESSFUL_PAYMENT = {
@ -353,7 +328,7 @@ MESSAGE_WITH_SUCCESSFUL_PAYMENT = {
"from": USER,
"chat": CHAT,
"date": 1508761169,
"successful_payment": SUCCESSFUL_PAYMENT
"successful_payment": SUCCESSFUL_PAYMENT,
}
MESSAGE_WITH_SUPERGROUP_CHAT_CREATED = {}
@ -364,7 +339,7 @@ MESSAGE_WITH_VENUE = {
"chat": CHAT,
"date": 1522849819,
"location": LOCATION,
"venue": VENUE
"venue": VENUE,
}
MESSAGE_WITH_VIDEO = {
@ -373,7 +348,7 @@ MESSAGE_WITH_VIDEO = {
"chat": CHAT,
"date": 1508756494,
"video": VIDEO,
"caption": "description"
"caption": "description",
}
MESSAGE_WITH_VIDEO_NOTE = {
@ -381,7 +356,7 @@ MESSAGE_WITH_VIDEO_NOTE = {
"from": USER,
"chat": CHAT,
"date": 1522835890,
"video_note": VIDEO_NOTE
"video_note": VIDEO_NOTE,
}
MESSAGE_WITH_VOICE = {
@ -389,7 +364,7 @@ MESSAGE_WITH_VOICE = {
"from": USER,
"chat": CHAT,
"date": 1508768403,
"voice": VOICE
"voice": VOICE,
}
PRE_CHECKOUT_QUERY = {
@ -397,7 +372,7 @@ PRE_CHECKOUT_QUERY = {
"from": USER,
"currency": "USD",
"total_amount": 6250,
"invoice_payload": "HAPPY FRIDAYS COUPON"
"invoice_payload": "HAPPY FRIDAYS COUPON",
}
REPLY_MESSAGE = {
@ -406,37 +381,22 @@ REPLY_MESSAGE = {
"chat": CHAT,
"date": 1508751866,
"reply_to_message": MESSAGE,
"text": "Reply to quoted message"
"text": "Reply to quoted message",
}
SHIPPING_QUERY = {
"id": "262181558684397422",
"from": USER,
"invoice_payload": "HAPPY FRIDAYS COUPON",
"shipping_address": SHIPPING_ADDRESS
"shipping_address": SHIPPING_ADDRESS,
}
USER_PROFILE_PHOTOS = {
"total_count": 1, "photos": [
[PHOTO, PHOTO, PHOTO]
]
}
USER_PROFILE_PHOTOS = {"total_count": 1, "photos": [[PHOTO, PHOTO, PHOTO]]}
FILE = {
"file_id": "XXXYYYZZZ",
"file_size": 5254,
"file_path": "voice\/file_8"
}
FILE = {"file_id": "XXXYYYZZZ", "file_size": 5254, "file_path": "voice/file_8"}
INVITE_LINK = 'https://t.me/joinchat/AbCdEfjKILDADwdd123'
INVITE_LINK = "https://t.me/joinchat/AbCdEfjKILDADwdd123"
UPDATE = {
"update_id": 123456789,
"message": MESSAGE
}
UPDATE = {"update_id": 123456789, "message": MESSAGE}
WEBHOOK_INFO = {
"url": "",
"has_custom_certificate": False,
"pending_update_count": 0
}
WEBHOOK_INFO = {"url": "", "has_custom_certificate": False, "pending_update_count": 0}

View file

@ -12,28 +12,28 @@ def test_export():
def test_file_name():
assert isinstance(animation.file_name, str)
assert animation.file_name == ANIMATION['file_name']
assert animation.file_name == ANIMATION["file_name"]
def test_mime_type():
assert isinstance(animation.mime_type, str)
assert animation.mime_type == ANIMATION['mime_type']
assert animation.mime_type == ANIMATION["mime_type"]
def test_file_id():
assert isinstance(animation.file_id, str)
# assert hash(animation) == ANIMATION['file_id']
assert animation.file_id == ANIMATION['file_id']
assert animation.file_id == ANIMATION["file_id"]
def test_file_size():
assert isinstance(animation.file_size, int)
assert animation.file_size == ANIMATION['file_size']
assert animation.file_size == ANIMATION["file_size"]
def test_thumb():
assert isinstance(animation.thumb, types.PhotoSize)
assert animation.thumb.file_id == ANIMATION['thumb']['file_id']
assert animation.thumb.width == ANIMATION['thumb']['width']
assert animation.thumb.height == ANIMATION['thumb']['height']
assert animation.thumb.file_size == ANIMATION['thumb']['file_size']
assert animation.thumb.file_id == ANIMATION["thumb"]["file_id"]
assert animation.thumb.width == ANIMATION["thumb"]["width"]
assert animation.thumb.height == ANIMATION["thumb"]["height"]
assert animation.thumb.file_size == ANIMATION["thumb"]["file_size"]

View file

@ -12,35 +12,36 @@ def test_export():
def test_id():
assert isinstance(chat.id, int)
assert chat.id == CHAT['id']
assert chat.id == CHAT["id"]
# assert hash(chat) == CHAT['id']
def test_name():
assert isinstance(chat.first_name, str)
assert chat.first_name == CHAT['first_name']
assert chat.first_name == CHAT["first_name"]
assert isinstance(chat.last_name, str)
assert chat.last_name == CHAT['last_name']
assert chat.last_name == CHAT["last_name"]
assert isinstance(chat.username, str)
assert chat.username == CHAT['username']
assert chat.username == CHAT["username"]
def test_type():
assert isinstance(chat.type, str)
assert chat.type == CHAT['type']
assert chat.type == CHAT["type"]
def test_chat_types():
assert types.ChatType.PRIVATE == 'private'
assert types.ChatType.GROUP == 'group'
assert types.ChatType.SUPER_GROUP == 'supergroup'
assert types.ChatType.CHANNEL == 'channel'
assert types.ChatType.PRIVATE == "private"
assert types.ChatType.GROUP == "group"
assert types.ChatType.SUPER_GROUP == "supergroup"
assert types.ChatType.CHANNEL == "channel"
def test_chat_type_filters():
from . import test_message
assert types.ChatType.is_private(test_message.message)
assert not types.ChatType.is_group(test_message.message)
assert not types.ChatType.is_super_group(test_message.message)
@ -49,13 +50,13 @@ def test_chat_type_filters():
def test_chat_actions():
assert types.ChatActions.TYPING == 'typing'
assert types.ChatActions.UPLOAD_PHOTO == 'upload_photo'
assert types.ChatActions.RECORD_VIDEO == 'record_video'
assert types.ChatActions.UPLOAD_VIDEO == 'upload_video'
assert types.ChatActions.RECORD_AUDIO == 'record_audio'
assert types.ChatActions.UPLOAD_AUDIO == 'upload_audio'
assert types.ChatActions.UPLOAD_DOCUMENT == 'upload_document'
assert types.ChatActions.FIND_LOCATION == 'find_location'
assert types.ChatActions.RECORD_VIDEO_NOTE == 'record_video_note'
assert types.ChatActions.UPLOAD_VIDEO_NOTE == 'upload_video_note'
assert types.ChatActions.TYPING == "typing"
assert types.ChatActions.UPLOAD_PHOTO == "upload_photo"
assert types.ChatActions.RECORD_VIDEO == "record_video"
assert types.ChatActions.UPLOAD_VIDEO == "upload_video"
assert types.ChatActions.RECORD_AUDIO == "record_audio"
assert types.ChatActions.UPLOAD_AUDIO == "upload_audio"
assert types.ChatActions.UPLOAD_DOCUMENT == "upload_document"
assert types.ChatActions.FIND_LOCATION == "find_location"
assert types.ChatActions.RECORD_VIDEO_NOTE == "record_video_note"
assert types.ChatActions.UPLOAD_VIDEO_NOTE == "upload_video_note"

View file

@ -12,23 +12,23 @@ def test_export():
def test_file_name():
assert isinstance(document.file_name, str)
assert document.file_name == DOCUMENT['file_name']
assert document.file_name == DOCUMENT["file_name"]
def test_mime_type():
assert isinstance(document.mime_type, str)
assert document.mime_type == DOCUMENT['mime_type']
assert document.mime_type == DOCUMENT["mime_type"]
def test_file_id():
assert isinstance(document.file_id, str)
# assert hash(document) == DOCUMENT['file_id']
assert document.file_id == DOCUMENT['file_id']
assert document.file_id == DOCUMENT["file_id"]
def test_file_size():
assert isinstance(document.file_size, int)
assert document.file_size == DOCUMENT['file_size']
assert document.file_size == DOCUMENT["file_size"]
def test_thumb():

View file

@ -12,17 +12,17 @@ def test_export():
def test_title():
assert isinstance(game.title, str)
assert game.title == GAME['title']
assert game.title == GAME["title"]
def test_description():
assert isinstance(game.description, str)
assert game.description == GAME['description']
assert game.description == GAME["description"]
def test_photo():
assert isinstance(game.photo, list)
assert len(game.photo) == len(GAME['photo'])
assert len(game.photo) == len(GAME["photo"])
assert all(map(lambda t: isinstance(t, types.PhotoSize), game.photo))

View file

@ -14,26 +14,26 @@ def test_export():
def test_message_id():
# assert hash(message) == MESSAGE['message_id']
assert message.message_id == MESSAGE['message_id']
assert message['message_id'] == MESSAGE['message_id']
assert message.message_id == MESSAGE["message_id"]
assert message["message_id"] == MESSAGE["message_id"]
def test_from():
assert isinstance(message.from_user, types.User)
assert message.from_user == message['from']
assert message.from_user == message["from"]
def test_chat():
assert isinstance(message.chat, types.Chat)
assert message.chat == message['chat']
assert message.chat == message["chat"]
def test_date():
assert isinstance(message.date, datetime.datetime)
assert int(message.date.timestamp()) == MESSAGE['date']
assert message.date == message['date']
assert int(message.date.timestamp()) == MESSAGE["date"]
assert message.date == message["date"]
def test_text():
assert message.text == MESSAGE['text']
assert message['text'] == MESSAGE['text']
assert message.text == MESSAGE["text"]
assert message["text"] == MESSAGE["text"]

View file

@ -12,16 +12,16 @@ def test_export():
def test_file_id():
assert isinstance(photo.file_id, str)
assert photo.file_id == PHOTO['file_id']
assert photo.file_id == PHOTO["file_id"]
def test_file_size():
assert isinstance(photo.file_size, int)
assert photo.file_size == PHOTO['file_size']
assert photo.file_size == PHOTO["file_size"]
def test_size():
assert isinstance(photo.width, int)
assert isinstance(photo.height, int)
assert photo.width == PHOTO['width']
assert photo.height == PHOTO['height']
assert photo.width == PHOTO["width"]
assert photo.height == PHOTO["height"]

View file

@ -13,7 +13,7 @@ def test_export():
def test_update_id():
assert isinstance(update.update_id, int)
# assert hash(update) == UPDATE['update_id']
assert update.update_id == UPDATE['update_id']
assert update.update_id == UPDATE["update_id"]
def test_message():

View file

@ -14,24 +14,24 @@ def test_export():
def test_id():
assert isinstance(user.id, int)
assert user.id == USER['id']
assert user.id == USER["id"]
# assert hash(user) == USER['id']
def test_bot():
assert isinstance(user.is_bot, bool)
assert user.is_bot == USER['is_bot']
assert user.is_bot == USER["is_bot"]
def test_name():
assert user.first_name == USER['first_name']
assert user.last_name == USER['last_name']
assert user.username == USER['username']
assert user.first_name == USER["first_name"]
assert user.last_name == USER["last_name"]
assert user.username == USER["username"]
def test_language_code():
assert user.language_code == USER['language_code']
assert user.locale == Locale.parse(USER['language_code'], sep='-')
assert user.language_code == USER["language_code"]
assert user.locale == Locale.parse(USER["language_code"], sep="-")
def test_full_name():
@ -40,8 +40,10 @@ def test_full_name():
def test_mention():
assert user.mention == f"@{USER['username']}"
assert user.get_mention('foo', as_html=False) == f"[foo](tg://user?id={USER['id']})"
assert user.get_mention('foo', as_html=True) == f"<a href=\"tg://user?id={USER['id']}\">foo</a>"
assert user.get_mention("foo", as_html=False) == f"[foo](tg://user?id={USER['id']})"
assert (
user.get_mention("foo", as_html=True) == f"<a href=\"tg://user?id={USER['id']}\">foo</a>"
)
def test_url():