From ef5c86c427e86dbaeb3828b7f1d5c8f059517bed Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 23 Oct 2019 10:47:17 +0200 Subject: [PATCH] Add quick reply tests --- tests/test_quick_reply.py | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/test_quick_reply.py diff --git a/tests/test_quick_reply.py b/tests/test_quick_reply.py new file mode 100644 index 0000000..ff2a19e --- /dev/null +++ b/tests/test_quick_reply.py @@ -0,0 +1,49 @@ +from fbchat._quick_reply import ( + QuickReplyText, + QuickReplyLocation, + QuickReplyPhoneNumber, + QuickReplyEmail, + graphql_to_quick_reply, +) + + +def test_parse_minimal(): + data = { + "content_type": "text", + "payload": None, + "external_payload": None, + "data": None, + "title": "A", + "image_url": None, + } + assert QuickReplyText(title="A") == graphql_to_quick_reply(data) + data = {"content_type": "location"} + assert QuickReplyLocation() == graphql_to_quick_reply(data) + data = {"content_type": "user_phone_number"} + assert QuickReplyPhoneNumber() == graphql_to_quick_reply(data) + data = {"content_type": "user_email"} + assert QuickReplyEmail() == graphql_to_quick_reply(data) + + +def test_parse_text_full(): + data = { + "content_type": "text", + "title": "A", + "payload": "Some payload", + "image_url": "https://example.com/image.jpg", + "data": None, + } + assert QuickReplyText( + payload="Some payload", + data=None, + is_response=False, + title="A", + image_url="https://example.com/image.jpg", + ) == graphql_to_quick_reply(data) + + +def test_parse_with_is_response(): + data = {"content_type": "text"} + assert QuickReplyText(is_response=True) == graphql_to_quick_reply( + data, is_response=True + )