Пример #1
0
    def test_receive_message(self):
        arguments = MockArgumentParser()
        viber_api = MockViberApi(None)
        client = MockViberBotClient(arguments, viber_client=viber_api)
        self.assertIsNotNone(client)

        request = unittest.mock.Mock()
        request.get_data.return_value = "{}"
        request.headers = {"X-Viber-Content-Signature": "SIGNATURE"}

        return_request = ViberMessageRequest()
        return_request._message = "Hello"
        return_request._sender = UserProfile(user_id="User123")
        viber_api._request = return_request

        client.receive_message(request)
Пример #2
0
    def test_receive_message(self):
        arguments = MockArgumentParser()
        viber_api = MockViberApi(None)
        client = MockViberBotClient(arguments, viber_client=viber_api)
        self.assertIsNotNone(client)

        request = unittest.mock.Mock()
        request.get_data.return_value = "{}"
        request.headers = {"X-Viber-Content-Signature": "SIGNATURE"}

        return_request = ViberMessageRequest()
        return_request._message = "Hello"
        return_request._sender = UserProfile(user_id="User123")
        viber_api._request = return_request

        client.receive_message(request)
Пример #3
0
    def test_handle_message_request(self):
        arguments = MockArgumentParser()
        client = MockViberBotClient(arguments, viber_client=MockViberApi(None))
        self.assertIsNotNone(client)

        request = ViberMessageRequest()
        request._message = "Hello"
        request._sender = UserProfile(user_id="User123")

        client.test_question = "Hi there"

        client.handle_message_request(request)

        self.assertIsNotNone(client.test_viber_client)
        self.assertIsNotNone(client.test_viber_client._messages)
        self.assertEquals(1, len(client.test_viber_client._messages))
        self.assertEquals("Hi there", client.test_viber_client._messages[0].text)
Пример #4
0
    def test_handle_message_request(self):
        arguments = MockArgumentParser()
        client = MockViberBotClient(arguments, viber_client=MockViberApi(None))
        self.assertIsNotNone(client)

        request = ViberMessageRequest()
        request._message = "Hello"
        request._sender = UserProfile(user_id="User123")

        client.test_question = "Hi there"

        client.handle_message_request(request)

        self.assertIsNotNone(client.test_viber_client)
        self.assertIsNotNone(client.test_viber_client._messages)
        self.assertEqual(1, len(client.test_viber_client._messages))
        self.assertEqual("Hi there",
                         client.test_viber_client._messages[0].text)