Esempio n. 1
0
    def test_add(self, header, payload_length):
        payload = payload_length * b"\0"

        message = header + payload
        assert isinstance(message, bytes)
        assert len(message) == len(header) + len(payload)
        assert FetcherHeader.from_bytes(message) == header
        assert FetcherHeader.from_bytes(message[:len(header)]) == header
        assert message[len(header):] == payload
Esempio n. 2
0
 def test_from_bytes_failure(self):
     with pytest.raises(ValueError):
         FetcherHeader.from_bytes(b"random bytes")
Esempio n. 3
0
 def test_from_bytes_success(self, header):
     assert FetcherHeader.from_bytes(bytes(header) + 42 * b"*") == header