def test_parse_illegal_callback_data(): """ Clients can send arbitrary bytes in callback data. Make sure the correct error is raised in this case. """ server_response = b'{"invalid utf-8": "\x80"}' with pytest.raises(TelegramError, match='Server response could not be decoded using UTF-8'): Request._parse(server_response)
def test_parse_illegal_json(): """ Clients can send arbitrary bytes in callback data. Make sure the correct error is raised in this case. """ server_response = b'{"invalid utf-8": "\x80", result: "KUKU"}' with pytest.raises(TelegramError, match='Invalid server response'): Request._parse(server_response)
def test_parse_illegal_callback_data(): """ Clients can send arbitrary bytes in callback data. Make sure the correct error is raised in this case. """ with pytest.raises( TelegramError, match='Server response could not be decoded using UTF-8'): server_response = b'{"invalid utf-8": "\x80"}' Request._parse(server_response)
def test_replaced_unprintable_char(): """ Clients can send arbitrary bytes in callback data. Make sure the correct error is raised in this case. """ server_response = b'{"invalid utf-8": "\x80", "result": "KUKU"}' assert Request._parse(server_response) == 'KUKU'