示例#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())
示例#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)
示例#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())
示例#4
0
 def from_scanner_message(scanner_msg):
     return Message(MessageType.WARNING, scanner_msg.content())
示例#5
0
 def puck_recorded_message():
     return Message(MessageType.INFO, "Puck barcode recorded")
示例#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)
示例#7
0
 def puck_scan_completed_message():
     return Message(MessageType.INFO, "Scan completed!")
示例#8
0
 def scan_completed_message():
     return Message(MessageType.INFO, "Scan completed")
示例#9
0
 def scan_timeout_message():
     return Message(MessageType.WARNING, "Scan timeout")
示例#10
0
 def latest_barcode_message():
     return Message(MessageType.WARNING, "Puck barcode already in latest record", lifetime=3)