Example #1
0
    def no_test_pokemon_search(self, mock_bot_send_message,
                               mock_bot_sender_action):
        msg = {
            'message': {
                'quick_reply': {
                    'payload': "PAYLOAD_RELATED_POKEMON"
                }
            }
        }
        sender = "fake_user"
        msgbody = msg['message']

        user = UserStatus(sender)
        user.set_status('STATE_POKEMON_SEARCH_OK')
        user.set_q('黃色電氣老鼠')
        user.set_english('pikachu')
        user.set_chinese('皮卡丘')

        # 真正跑測試的地方~
        celery_handle_message(msg, sender, msgbody)

        print("\033[0;32m%s\033[m" %
              json.dumps(mock_bot_send_message.call_args_list,
                         indent=4,
                         sort_keys=True,
                         ensure_ascii=False))
Example #2
0
    def test_asian_legend(self, mock_bot_send_message, mock_bot_sender_action):
        msg = {'message': {'text': "老地方"}}
        sender = "fake_user"
        msgbody = msg['message']

        # 真正跑測試的地方~
        celery_handle_message(msg, sender, msgbody)
        print("\033[0;32m%s\033[m" %
              json.dumps(mock_bot_send_message.call_args_list,
                         indent=4,
                         sort_keys=True,
                         ensure_ascii=False))
Example #3
0
    def test_joke(self, mock_bot_send_message, mock_bot_sender_action):
        msg = {"message": {"text": "笑話"}}
        sender = "fake_user"
        msgbody = msg['message']

        # 開始跑測試囉~
        celery_handle_message(msg, sender, msgbody)

        print("\033[0;32m%s\033[m" %
              json.dumps(mock_bot_send_message.call_args_list,
                         indent=4,
                         sort_keys=True,
                         ensure_ascii=False))
        user = UserStatus(sender)
        assert user.get_status() == 'new'
Example #4
0
    def test_translate_english_to_chinese(self, mock_bot_send_message,
                                          mock_bot_sender_action):
        msg = {"message": {"text": "請問 avocado 的中文是什麼"}}
        sender = "fake_user"
        msgbody = msg['message']

        # 真正跑測試的地方~
        celery_handle_message(msg, sender, msgbody)

        # 檢查已讀是否送出
        assert mock_bot_sender_action.called

        print("\033[0;32m%s\033[m" %
              json.dumps(mock_bot_send_message.call_args_list,
                         indent=4,
                         sort_keys=True,
                         ensure_ascii=False))
        user = UserStatus(sender)
        assert user.get_status() == 'STATE_ENGLISH_TO_CHINESE_OK'
Example #5
0
    def test_pikachu_more(self, mock_bot_send_message, mock_bot_sender_action):
        msg = {"message": {"text": "pikachu"}}
        sender = "fake_user"
        msgbody = msg['message']

        # 真正跑測試的地方~
        celery_handle_message(msg, sender, msgbody)
        user = UserStatus(sender)
        assert user.get_status() == 'STATE_ENGLISH_TO_CHINESE_OK'

        # 接下來按下 "更多"
        msg = {"message": {"quick_reply": {"payload": 'PAYLOAD_MORE'}}}
        msgbody = msg['message']
        celery_handle_message(msg, sender, msgbody)
        print("\033[0;32m%s\033[m" %
              json.dumps(mock_bot_send_message.call_args_list,
                         indent=4,
                         sort_keys=True,
                         ensure_ascii=False))
    def test_location_info(self, mock_bot_send_message,
                           mock_bot_sender_action):
        msg = {
            'message': {
                'quick_reply': {
                    'payload': "PAYLOAD_LOCATION_INFO:1"
                }
            }
        }
        sender = "fake_user"
        msgbody = msg['message']

        # 真正跑測試的地方~
        celery_handle_message(msg, sender, msgbody)

        print("\033[0;32m%s\033[m" %
              json.dumps(mock_bot_send_message.call_args_list,
                         indent=4,
                         sort_keys=True,
                         ensure_ascii=False))