Beispiel #1
0
 def _test_set_params_invalidservice_no_exception(self):
     self.udsclient.config['exception_on_invalid_response'] = False
     control_type = services.CommunicationControl.ControlType.disableRxAndTx
     com_type = CommunicationType(subnet=5,
                                  normal_msg=True,
                                  network_management_msg=True)
     response = self.udsclient.communication_control(
         control_type=control_type, communication_type=com_type)
     self.assertFalse(response.valid)
Beispiel #2
0
 def _test_comcontrol_disable_subnet(self):
     control_type = services.CommunicationControl.ControlType.disableRxAndTx
     com_type = CommunicationType(subnet=3,
                                  normal_msg=True,
                                  network_management_msg=True)
     response = self.udsclient.communication_control(
         control_type=control_type, communication_type=com_type)
     self.assertTrue(response.positive)
     self.assertEqual(response.service_data.control_type_echo, control_type)
Beispiel #3
0
 def _test_comcontrol_bad_control_type_no_exception(self):
     self.udsclient.config['exception_on_unexpected_response'] = False
     com_type = CommunicationType(subnet=3,
                                  normal_msg=True,
                                  network_management_msg=True)
     response = self.udsclient.communication_control(
         control_type=9, communication_type=com_type)
     self.assertTrue(response.valid)
     self.assertTrue(response.unexpected)
Beispiel #4
0
 def _test_comcontrol_negative_response_no_exception(self):
     self.udsclient.config['exception_on_negative_response'] = False
     control_type = services.CommunicationControl.ControlType.disableRxAndTx
     com_type = CommunicationType(subnet=3,
                                  normal_msg=True,
                                  network_management_msg=True)
     response = self.udsclient.communication_control(
         control_type=control_type, communication_type=com_type)
     self.assertTrue(response.valid)
     self.assertFalse(response.positive)
Beispiel #5
0
 def _test_comcontrol_enable_node_spr(self):
     control_type = services.CommunicationControl.ControlType.enableRxAndTx
     com_type = CommunicationType(subnet=CommunicationType.Subnet.node,
                                  normal_msg=True)
     with self.udsclient.suppress_positive_response:
         response = self.udsclient.communication_control(
             control_type=control_type, communication_type=com_type)
         self.assertEqual(response, None)
     self.conn.fromuserqueue.get(
         timeout=0.2)  #Avoid closing connection prematurely
    def test_oob_values(self):
        with self.assertRaises(ValueError):
            CommunicationType(subnet=0,
                              normal_msg=False,
                              network_management_msg=False)

        with self.assertRaises(ValueError):
            CommunicationType(subnet='x',
                              normal_msg=True,
                              network_management_msg=False)

        with self.assertRaises(ValueError):
            CommunicationType(subnet=0,
                              normal_msg=1,
                              network_management_msg=True)

        with self.assertRaises(ValueError):
            CommunicationType(subnet=0,
                              normal_msg=True,
                              network_management_msg=1)
Beispiel #7
0
    def _test_bad_param(self):
        valid_com_type = CommunicationType(subnet=3, normal_msg=True, network_management_msg=True)
        with self.assertRaises(ValueError):
            self.udsclient.communication_control(control_type=u'x', communication_type=valid_com_type)	

        with self.assertRaises(ValueError):
            self.udsclient.communication_control(control_type=0x80, communication_type=valid_com_type)

        with self.assertRaises(ValueError):
            self.udsclient.communication_control(control_type=-1, communication_type=valid_com_type)

        with self.assertRaises(ValueError):
            self.udsclient.communication_control(control_type=0, communication_type=u'x')
Beispiel #8
0
    def _test_comcontrol_enable_node(self):
        control_type = services.CommunicationControl.ControlType.enableRxAndTx
        com_type = CommunicationType(subnet=CommunicationType.Subnet.node, normal_msg=True)
        response = self.udsclient.communication_control(control_type=control_type, communication_type=com_type)
        self.assertTrue(response.positive)
        self.assertEqual(response.service_data.control_type_echo, control_type)

        response = self.udsclient.communication_control(control_type=control_type, communication_type=com_type.get_byte())
        self.assertTrue(response.positive)
        self.assertEqual(response.service_data.control_type_echo, control_type)

        response = self.udsclient.communication_control(control_type=control_type, communication_type=com_type.get_byte_as_int())
        self.assertTrue(response.positive)
        self.assertEqual(response.service_data.control_type_echo, control_type)
 def test_str_repr(self):
     comtype = CommunicationType(subnet=CommunicationType.Subnet.node,
                                 normal_msg=True,
                                 network_management_msg=False)
     str(comtype)
     comtype.__repr__()
Beispiel #10
0
 def _test_set_params_invalidservice_exception(self):
     with self.assertRaises(InvalidResponseException) as handle:
         control_type = services.CommunicationControl.ControlType.disableRxAndTx
         com_type = CommunicationType(subnet=5, normal_msg=True, network_management_msg=True)
         self.udsclient.communication_control(control_type=control_type, communication_type=com_type)	
Beispiel #11
0
 def _test_comcontrol_negative_response_exception(self):
     with self.assertRaises(NegativeResponseException) as handle:
         control_type = services.CommunicationControl.ControlType.disableRxAndTx
         com_type = CommunicationType(subnet=3, normal_msg=True, network_management_msg=True)
         self.udsclient.communication_control(control_type=control_type, communication_type=com_type)	
Beispiel #12
0
 def _test_comcontrol_bad_control_type_exception(self):
     with self.assertRaises(UnexpectedResponseException) as handle:
         com_type = CommunicationType(subnet=3, normal_msg=True, network_management_msg=True)
         self.udsclient.communication_control(control_type=9, communication_type=com_type)