def header(self): return FetcherHeader( FetcherType.TCP, PayloadType.AGENT, status=42, payload_length=69, )
def test_eq(self, header, type_, status, payload_length): assert header == bytes(header) assert bytes(header) == header assert bytes(header) == bytes(header) assert header == FetcherHeader(type_, status=status, payload_length=payload_length)
def header(self, fetcher_type, payload_type, status, payload_length): return FetcherHeader( fetcher_type, payload_type, status=status, payload_length=payload_length, )
def test_neq_other_status(self, header, status): other = status + 1 assert other != header.status assert header != FetcherHeader( header.type, status=other, payload_length=header.payload_length, )
def test_neq_other_payload_length(self, header, payload_length): other = payload_length + 1 assert other != header.payload_length assert header != FetcherHeader( header.type, status=header.status, payload_length=other, )
def test_neq_other_type(self, header): other = FetcherType.TCP assert other != header.type assert header != FetcherHeader( other, status=header.status, payload_length=header.payload_length, )
def test_neq_other_result_type(self, header): other = PayloadType.ERROR assert other != header.payload_type assert header != FetcherHeader( header.fetcher_type, other, status=header.status, payload_length=header.payload_length, )
def test_eq(self, header, fetcher_type, payload_type, status, payload_length, stats_length): assert header == bytes(header) assert bytes(header) == header assert bytes(header) == bytes(header) assert header == FetcherHeader( fetcher_type, payload_type, status=status, payload_length=payload_length, stats_length=stats_length, )
def test_controller_success(self): payload = AgentPayload(69 * b"\0") header = FetcherHeader( FetcherType.TCP, PayloadType.AGENT, status=42, payload_length=len(payload), ) message = FetcherMessage(header, payload) assert len(message) == 89 assert make_payload_answer(message) == ( b"fetch:SUCCESS: :89 :" + header + payload)
def test_controller_success(self): payload = AgentPayload(69 * b"\0") stats = L3Stats(CPUTracker()) header = FetcherHeader( FetcherType.TCP, PayloadType.AGENT, status=42, payload_length=len(payload), stats_length=len(stats), ) message = FetcherMessage(header, payload, stats) assert make_payload_answer(message) == (b"fetch:SUCCESS: :240 :" + header + payload + stats)
def test_neq(self): f_header = FetcherHeader("TCP", status=1, payload_length=42) other_name = f_header.clone() other_name.name = "toto" assert f_header != other_name other_status = f_header.clone() other_status.status = 99 assert f_header != other_status other_len = f_header.clone() other_len.payload_length = 69 assert f_header != other_len
def test_len(self): f_header = FetcherHeader("name", status=0, payload_length=42) assert len(f_header) == len(bytes(f_header))
def test_hash(self): f_header = FetcherHeader("name", status=0, payload_length=42) assert hash(f_header) == hash(bytes(f_header))
def test_repr(self): f_header = FetcherHeader("name", status=0, payload_length=42) assert isinstance(repr(f_header), str)
def test_eq(self): f_header = FetcherHeader("TCP", status=1, payload_length=42) assert f_header == bytes(f_header) assert bytes(f_header) == f_header
def test_clone(self): f_header = FetcherHeader("TCP", status=1, payload_length=42) other = f_header.clone() assert other is not f_header assert other == f_header
def test_from_network(self): f_header = FetcherHeader("TCP", status=1, payload_length=42) assert FetcherHeader.from_network(bytes(f_header) + 42 * b"*") == f_header
def test_from_network(self): header = FetcherHeader(FetcherType.TCP, status=1, payload_length=42) assert FetcherHeader.from_network(bytes(header) + 42 * b"*") == header
def test_repr(self): header = FetcherHeader(FetcherType.TCP, status=0, payload_length=42) assert isinstance(repr(header), str)
def test_hash(self): header = FetcherHeader(FetcherType.TCP, status=0, payload_length=42) assert hash(header) == hash(bytes(header))
def header(self, type_, status, payload_length): return FetcherHeader(type_, status=status, payload_length=payload_length)
def test_len(self): header = FetcherHeader(FetcherType.TCP, status=0, payload_length=42) assert len(header) == len(bytes(header))