Add a Test for MessageAttachmentType (#3335)

This commit is contained in:
Harshil 2022-11-06 17:04:01 +02:00 committed by GitHub
parent d2c6c4b369
commit 834568d7f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,6 +57,11 @@ class TestConstants:
actual == expected
), f"Members {expected - actual} were not listed in constants.__all__"
def test_message_attachment_type(self):
assert all(
getattr(constants.MessageType, x.name, False) for x in constants.MessageAttachmentType
), "All MessageAttachmentType members should be in MessageType"
def test_to_json(self):
assert json.dumps(StrEnumTest.FOO) == json.dumps("foo")
assert json.dumps(IntEnumTest.FOO) == json.dumps(1)
@ -126,7 +131,7 @@ class TestConstants:
assert good_msg.caption == good_caption
bad_caption = good_caption + "Z"
match = "Media_caption_too_long"
match = "Message caption is too long"
with pytest.raises(BadRequest, match=match), data_file("telegram.png").open("rb") as f:
await bot.send_photo(photo=f, caption=bad_caption, chat_id=chat_id)