Esempio n. 1
0
 async def _send_cmd(self, cmd: bytes, expected: bytes) -> List[bytes]:
     self._writer.write(cmd + b'\r\n')
     #self._reader.readuntil(separator=b'\r\n')
     line = await self._reader.readline()
     return _parse_response(line, expected)
Esempio n. 2
0
def test_response_missing_crlf() -> None:
    with pytest.raises(AssertionError):
        _parse_response(b"USING a", b"")
Esempio n. 3
0
def test_unexpected_eof() -> None:
    with pytest.raises(ConnectionError) as e:
        _parse_response(b"", b"")
    assert e.value.args[0] == "Unexpected EOF"
Esempio n. 4
0
def test_unknown_response_error() -> None:
    with pytest.raises(UnknownResponseError) as e:
        _parse_response(b"FOO 1 2 3\r\n", b"")
    assert e.value.status == b"FOO"
    assert e.value.values == [b"1", b"2", b"3"]
Esempio n. 5
0
def test_buried_error_without_id() -> None:
    with pytest.raises(BuriedError):
        _parse_response(b"BURIED\r\n", b"")
Esempio n. 6
0
def test_buried_error_with_id() -> None:
    with pytest.raises(BuriedWithJobIDError) as e:
        _parse_response(b"BURIED 10\r\n", b"")
    assert e.value.job_id == 10
Esempio n. 7
0
def test_unknown_response_error() -> None:
    with pytest.raises(UnknownResponseError) as e:
        _parse_response(b'FOO 1 2 3\r\n', b'')
    assert e.value.status == b'FOO'
    assert e.value.values == [b'1', b'2', b'3']
Esempio n. 8
0
def test_buried_error_without_id() -> None:
    with pytest.raises(BuriedError) as e:
        _parse_response(b'BURIED\r\n', b'')
    assert e.value.id is None