Beispiel #1
0
 def __init__(self, number, head=True):
     """
         :param number - the number of protocol
         :param head - flag for init header
     """
     Base.__init__(self)
     self.header = head
     self.add_bits = '00000'
     # message types, see ELM spec. page 44
     self.mess_SF = 0  # the Single Frame
     self.mess_FF = 1  # the First Frame (of a multi frame message)
     self.mess_CF = 2  # the Consecutive Frame
     # The header bits depends on protocol number.
     # It uses for CAN protocol only
     self.header_bits = self.__get_bits(number)
     self.header_11 = 11
     self.header_29 = 29
     self.frame_start = 10
     self.data_start_byte = 4
Beispiel #2
0
class TestMain(unittest.TestCase):
    def setUp(self):
        self.pm = Base()

    def test_remove_searching(self):
        data = self.pm.remove_searching(['SEARCHING...'])
        self.assertEqual(data, [])

        data = self.pm.remove_searching(['SEARCHING...', '410000000000'])
        self.assertEqual(data, ['410000000000'])

        # Exception - ValueError
        data = self.pm.remove_searching(['410C34'])
        self.assertEqual(data, ['410C34'])

    def test_create_data(self):
        with self.assertRaises(NotImplementedError) as cm:
            self.pm.create_data([])
        self.assertIsInstance(cm.exception, NotImplementedError)

    def test_check_result(self):
        resp = self.pm.check_result(['NODATA'])
        self.assertFalse(resp)

        resp = self.pm.check_result(['410C7D'])
        self.assertTrue(resp)

    @mock.patch('sys.stdout')
    def test_check_error(self, mock_out):
        # if hasn't error
        resp = self.pm.check_error(['410C7D'])
        self.assertTrue(resp)

        # if some error appears
        resp = self.pm.check_error(['7F0112'])
        self.assertFalse(resp)

        resp = self.pm.check_error(['7F0188'])
        self.assertFalse(resp)
Beispiel #3
0
 def setUp(self):
     self.pm = Base()
Beispiel #4
0
 def __init__(self, head=True):
     Base.__init__(self)
     self.header = head
     self.check_sum = -2