示例#1
0
 def test_from_seconds(self):
     self.assertEquals((1, 23), Protocol._from_seconds(23))
     self.assertEquals((1, 59), Protocol._from_seconds(59))
     self.assertEquals((2, 1), Protocol._from_seconds(60))
     self.assertEquals((2, 2), Protocol._from_seconds(120))
     self.assertEquals((2, 1), Protocol._from_seconds(119))
     self.assertRaises(InstrumentParameterException, Protocol._from_seconds, 3601)
     self.assertRaises(InstrumentParameterException, Protocol._from_seconds, 14)
示例#2
0
 def test_to_seconds(self):
     """ Test to second conversion. """
     self.assertEquals(240, Protocol._to_seconds(4, 1))
     self.assertEquals(59, Protocol._to_seconds(59, 0))
     self.assertEquals(60, Protocol._to_seconds(60, 0))
     self.assertEquals(3600, Protocol._to_seconds(60, 1))
     self.assertEquals(3660, Protocol._to_seconds(61, 1))
     self.assertRaises(InstrumentProtocolException, Protocol._to_seconds, 1, 2)
     self.assertRaises(InstrumentProtocolException, Protocol._to_seconds, 1, "foo")
示例#3
0
 def test_from_seconds(self):
     self.assertEquals((1, 23), Protocol._from_seconds(23))
     self.assertEquals((1, 59), Protocol._from_seconds(59))
     self.assertEquals((2, 1), Protocol._from_seconds(60))
     self.assertEquals((2, 2), Protocol._from_seconds(120))
     self.assertEquals((2, 1), Protocol._from_seconds(119))
     self.assertRaises(InstrumentParameterException, Protocol._from_seconds,
                       3601)
     self.assertRaises(InstrumentParameterException, Protocol._from_seconds,
                       14)
    def test_to_seconds(self):
	""" Test to second conversion. """
	self.assertEquals(240, Protocol._to_seconds(4, 1))
	self.assertEquals(59, Protocol._to_seconds(59, 0))
	self.assertEquals(60, Protocol._to_seconds(60, 0))
	self.assertEquals(3600, Protocol._to_seconds(60, 1))
	self.assertEquals(3660, Protocol._to_seconds(61, 1))
	self.assertRaises(InstrumentProtocolException,
			  Protocol._to_seconds, 1, 2)
	self.assertRaises(InstrumentProtocolException,
			  Protocol._to_seconds, 1, "foo")
示例#5
0
    def test_protocol_filter_capabilities(self):
        """
        This tests driver filter_capabilities.
        Iterate through available capabilities, and verify that they can pass successfully through the filter.
        Test silly made up capabilities to verify they are blocked by filter.
        """
        mock_callback = Mock()
        protocol = Protocol(MENU, Prompt, NEWLINE, mock_callback)
        driver_capabilities = Capability().list()
        test_capabilities = Capability().list()

        # Add a bogus capability that will be filtered out.
        test_capabilities.append("BOGUS_CAPABILITY")

        # Verify "BOGUS_CAPABILITY was filtered out
        self.assertEquals(sorted(driver_capabilities), sorted(protocol._filter_capabilities(test_capabilities)))
示例#6
0
    def test_protocol_filter_capabilities(self):
        """
        This tests driver filter_capabilities.
        Iterate through available capabilities, and verify that they can pass successfully through the filter.
        Test silly made up capabilities to verify they are blocked by filter.
        """
        mock_callback = Mock()
        protocol = Protocol(MENU, Prompt, NEWLINE, mock_callback)
        driver_capabilities = Capability().list()
        test_capabilities = Capability().list()

        # Add a bogus capability that will be filtered out.
        test_capabilities.append("BOGUS_CAPABILITY")

        # Verify "BOGUS_CAPABILITY was filtered out
        self.assertEquals(sorted(driver_capabilities),
                          sorted(protocol._filter_capabilities(test_capabilities)))