Beispiel #1
0
 def test_critical_constants(self):
     """ ATTENTION: Changing of those constants may require changing of C++ code"""
     assert Header.length == 32
     assert Header.State.FAILURE == "FAILURE"
     assert Header.State.SUCCESS == "SUCCESS"
     assert Header.State.WAITING == "WAITING"
     assert Header.default_protocol_name() == "fetch"
Beispiel #2
0
    def test_neq(self):
        header = Header("name", Header.State.SUCCESS, "crit", 42)

        other_name = header.clone()
        other_name.name = "toto"
        assert header != other_name

        other_state = header.clone()
        other_state.state = Header.State.FAILURE
        assert header != other_state

        other_crit = header.clone()
        other_crit.severity = "tnih"
        assert header != other_crit

        other_len = header.clone()
        other_len.payload_length = 69
        assert header != other_len
Beispiel #3
0
 def test_from_network(self):
     header = Header("fetch", "SUCCESS", "crit", 42)
     assert Header.from_network(bytes(header) + 42 * b"*") == header
Beispiel #4
0
 def test_failure_header(self, state):
     header = Header("fetch", state, "crit", 42)
     assert bytes(header) == b"fetch:FAILURE:crit    :42      :"
Beispiel #5
0
 def test_success_header(self, state):
     header = Header("name", state, "crit", 41)
     assert bytes(header) == b"name :SUCCESS:crit    :41      :"
Beispiel #6
0
 def test_len(self):
     header = Header("name", "SUCCESS", "crit", 42)
     assert len(header) == len(bytes(header))
Beispiel #7
0
 def test_hash(self):
     header = Header("name", "SUCCESS", "crit", 42)
     assert hash(header) == hash(bytes(header))
Beispiel #8
0
 def test_repr(self):
     header = Header("name", "SUCCESS", "crit", 42)
     assert isinstance(repr(header), str)
Beispiel #9
0
 def test_eq(self):
     header = Header("name", Header.State.SUCCESS, "crit", 42)
     assert header == bytes(header)
     assert bytes(header) == header
Beispiel #10
0
 def test_len(self):
     header = Header("name", "SUCCESS", "hint", 42)
     assert len(header) == len(str(header))
Beispiel #11
0
 def test_clone(self):
     header = Header("name", Header.State.SUCCESS, "crit", 42)
     other = header.clone()
     assert other is not header
     assert other == header
Beispiel #12
0
 def test_hash(self):
     header = Header("name", "SUCCESS", "hint", 42)
     assert hash(header) == hash(str(header))
Beispiel #13
0
 def test_eq(self):
     header = Header("name", Header.State.SUCCESS, "hint", 42)
     assert header == str(header)
     assert str(header) == header
Beispiel #14
0
 def test_from_network(self):
     header = Header("fetch", "SUCCESS", "hint", 42)
     assert Header.from_network(str(header) + 42 * "*") == header
Beispiel #15
0
 def test_failure_header(self, state):
     header = Header("fetch", state, "hint", 42)
     assert str(header) == "fetch:FAILURE:hint    :42      :"
Beispiel #16
0
 def test_success_header(self, state):
     header = Header("name", state, "hint", 41)
     assert str(header) == "name :SUCCESS:hint    :41      :"