Example #1
0
    def test_lifetime_can_be_initialised(self):
        # Arrange
        lifetime = 0.1

        # Act
        msg = Message(MessageType.INFO, "hello", lifetime)

        # Assert
        time.sleep(lifetime)
        self.assertTrue(msg.has_expired())
Example #2
0
    def test_parameters_initalised_correctly(self):
        # Arrange
        type = MessageType.WARNING
        content = "hello there"

        # Act
        msg = Message(type, content)

        # Assert
        self.assertEqual(msg.type(), type)
        self.assertEqual(msg.content(), content)
Example #3
0
    def test_message_has_default_lifetime(self):
        # Arrange
        expected_lifetime = 2

        # Act
        msg = Message(MessageType.INFO, "hello")

        # Assert
        time.sleep(expected_lifetime / 2)
        self.assertFalse(msg.has_expired())
        time.sleep(expected_lifetime / 2)
        self.assertTrue(msg.has_expired())
Example #4
0
 def from_scanner_message(scanner_msg):
     return Message(MessageType.WARNING, scanner_msg.content())
Example #5
0
 def puck_recorded_message():
     return Message(MessageType.INFO, "Puck barcode recorded")
Example #6
0
 def camera_not_found_message():
     return Message(
         MessageType.WARNING,
         "camera can not be found.\nEnter the configuration to select the camera.",
         lifetime=0)
Example #7
0
 def puck_scan_completed_message():
     return Message(MessageType.INFO, "Scan completed!")
Example #8
0
 def scan_completed_message():
     return Message(MessageType.INFO, "Scan completed")
Example #9
0
 def scan_timeout_message():
     return Message(MessageType.WARNING, "Scan timeout")
Example #10
0
 def latest_barcode_message():
     return Message(MessageType.WARNING, "Puck barcode already in latest record", lifetime=3)