Ejemplo n.º 1
0
    def test_log_answer(self):
        log_message = "the log message"
        level = logging.WARN

        message = CMCMessage.log_answer(log_message, level)
        assert CMCMessage.from_bytes(bytes(message)) == message
        assert message.header.name == "fetch"
        assert message.header.state == CMCHeader.State.LOG
        assert message.header.log_level.strip() == "warning"
        assert message.header.payload_length == len(message) - len(
            message.header)
        assert message.header.payload_length == len(log_message)
Ejemplo n.º 2
0
 def test_result_answer(self, fetcher_message, count):
     fetcher_messages = list(repeat(fetcher_message, count))
     message = CMCMessage.result_answer(*fetcher_messages)
     assert CMCMessage.from_bytes(bytes(message)) == message
     assert len(fetcher_messages) == count
     assert message.header.name == "fetch"
     assert message.header.state == CMCHeader.State.RESULT
     assert message.header.log_level.strip() == ""
     assert message.header.payload_length == len(message) - len(
         message.header)
     assert message.header.payload_length == count * len(fetcher_message)
     assert not set(message.payload) ^ set(fetcher_messages)
Ejemplo n.º 3
0
 def test_controller_end_of_reply(self):
     assert CMCMessage.end_of_reply() == b"fetch:ENDREPL:        :0       :"
Ejemplo n.º 4
0
 def test_controller_log(self):
     assert CMCMessage.log_answer(
         "payload",
         logging.WARNING,
     ) == b"fetch:LOG    :warning :7       :payload"
Ejemplo n.º 5
0
 def test_from_bytes(self, eor):
     assert CMCMessage.from_bytes(bytes(eor)) == eor
Ejemplo n.º 6
0
 def eor(self):
     return CMCMessage.end_of_reply()
Ejemplo n.º 7
0
 def test_make_end_of_reply_answer(self):
     assert make_end_of_reply_answer() is CMCMessage.end_of_reply()
Ejemplo n.º 8
0
 def test_from_bytes(self, message):
     assert CMCMessage.from_bytes(bytes(message)) == message
Ejemplo n.º 9
0
 def message(self, header, fetcher_message):
     return CMCMessage(header, fetcher_message)
Ejemplo n.º 10
0
 def test_end_of_reply(self):
     assert CMCMessage.end_of_reply() is CMCMessage.end_of_reply()