def test_payload(self): recipient = Payload.Recipient(id=123456, phone_number='+8210') message = Payload.Message(text="hello", metadata="METADATA", quick_replies=[{'title': 'Yes', 'payload': 'PICK_YES'}]) with self.assertRaises(ValueError): Payload.Payload(recipient=recipient, message=message, sender_action='NEW_ACTION') with self.assertRaises(ValueError): Payload.Payload(recipient=recipient, message=message, sender_action='typing_off', notification_type='NEW_NOTIFICATION_TYPE') p = Payload.Payload(recipient=recipient, message=message, sender_action='typing_off', notification_type='REGULAR') self.assertEquals( '{"message": {"attachment": null, "metadata": "METADATA", "quick_replies": ' '[{"content_type": "text", "payload": "PICK_YES", "title": "Yes"}], "text": "hello"},' ' "notification_type": "REGULAR", "recipient": {"id": 123456, "phone_number": "+8210"},' ' "sender_action": "typing_off"}', utils.to_json(p)) self.assertTrue(p.__eq__(p)) self.assertTrue(p.__eq__(utils.to_json(p)))
def test_receipt_with_phone(self): q = Payload.Recipient(id=123456, phone_number='+8210') self.assertEquals('{"id": 123456, "phone_number": "+8210"}', utils.to_json(q))
def test_receipt(self): q = Payload.Recipient(id=123456) self.assertEquals('{"id": 123456}', utils.to_json(q))