Skip to content

Commit

Permalink
Merge pull request #31 from hollalll726/QuickReply
Browse files Browse the repository at this point in the history
Raise value error to avoid unknown error in server
  • Loading branch information
Karl Woojung Kim authored Sep 4, 2017
2 parents be4af7e + 0912ca8 commit d53505f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fbmq/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Message(object):
def __init__(self, text=None, attachment=None, quick_replies=None, metadata=None):
if text is not None and attachment is not None:
raise ValueError('Please set only one parameter "text" or "attachment"')
if not isinstance(quick_replies, list) and quick_replies is not None:
raise ValueError('quick_replies type must be "list"')

self.text = text
self.attachment = attachment
Expand Down
2 changes: 2 additions & 0 deletions tests/test_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def test_receipt(self):
def test_message(self):
with self.assertRaises(Exception):
m = Payload.Message(text="hello", attachment=Attachment.Image('img'))
with self.assertRaises(ValueError):
m = Payload.Message(text="hello", quick_replies=Payload.QuickReply(title='Yes', payload='PICK_YES'))

m = Payload.Message(text="hello", metadata="METADATA", quick_replies=[{'title': 'Yes', 'payload': 'PICK_YES'}])
self.assertEquals('{"attachment": null, "metadata": "METADATA", '
Expand Down

0 comments on commit d53505f

Please sign in to comment.