예제 #1
0
    def test_unicode(self):
        """Smoke regression test for unicode messages"""
        from twentiment_api.client import Client

        with self._mock_socket():
            client = Client("localhost", 10001)
            # This used to blow the formatting up.
            client.guess(u'@laliminati LAL\u0130 2500 OMAMA YARDIM ET X')
예제 #2
0
    def test_send(self):
        from twentiment_api.client import Client

        with self._mock_socket() as socket:
            client = Client("localhost", 10001)
            client.guess("Hello, World!")

            socket.send_unicode.assert_called_once_with("GUESS Hello, World!")
예제 #3
0
    def test_error(self):
        from twentiment_api.client import Client, ClientError

        with self._mock_socket() as socket:
            socket.recv_string.return_value = "ERROR UNKNOWN_COMMAND"

            client = Client("localhost", 10001)
            call = lambda: client.guess("Hello, World!")
            self.assertRaises(ClientError, call)
예제 #4
0
    def test_okay(self):
        from twentiment_api.client import Client

        with self._mock_socket() as socket:
            socket.recv_string.return_value = "OK 0.5"

            client = Client("localhost", 10001)
            response = client.guess("Hello, World!")

            self.assertEquals(response, 0.5)