def test_to_readable_output_reale_packet_expect_readable_returned(self): test_deserialization = Deserialization() test_packet = 'AAA123>BBB123,APRS-1*,WIDE1*,APRS-10*,WIDE2*:!4252.29NT07538.40W&PHG7130 Yes hello, testing.' actual_value = test_deserialization.to_readable_output(test_packet) assert actual_value is not 'this is not a proper aprs packet'
def test_to_readable_output_nonsense_packet_expect_raw_returned(self): test_deserialization = Deserialization() expected_return = 'this is not a proper aprs packet' actual_value = test_deserialization.to_readable_output(expected_return) assert actual_value == expected_return
class CliProcessor(Processor): def __init__(self): """Sets up the functionality we will be using.""" self.log_handler = None self.config = None self.deserializer = Deserialization() def get_name(self): """Gets the name of this processor to match against the config.""" return "cli" def load(self, config, log_handler): """Initializes the processor, assigning the params locally.. Args: packet: A decoded packet to output to the CLI. """ self.config = config self.log_handler = log_handler def handle(self, packet): """Handles a single packet, outputting it to the CLI in a human-readable format. Args: packet: A decoded packet to output to the CLI. """ print_friendly_packet = self.deserializer.to_readable_output(packet) self.log_handler.log_packet(packet, print_friendly_packet)