Example #1
0
    def test_error_message_header_bad_property_codes(self):
        """
        Testing the header BadPropertyCodes.
        This function will test all code values for this enum class.
        :return: None
        """

        error_type = 14
        error_type_value = Error.ErrorType.OFPET_BAD_PROPERTY

        error_code = 0

        iter_given_code = Error.ErrorType.get_class(
            error_type_value).__iter__()
        length = Error.ErrorType.get_class(error_type_value).__len__()

        while error_code < self.MAX_BAD_PROPERTY_CODE_VALUE or length > 0:
            data = UBInt32(random.randint(2, 250)).pack()
            xid = random.randint(2, 250)

            test_value = b'\x05\x01\x00\x10' + UBInt32(xid).pack() + UBInt16(error_type).pack() + \
                        UBInt16(error_code).pack() + data

            if error_code < self.MAX_BAD_PROPERTY_CODE_VALUE:
                error_code += 1
            length -= 1
            test_object_error_messages = Error.ErrorMsg(
                xid, error_type_value, iter_given_code.__next__(),
                data).pack()

            self.assertEqual(test_value, test_object_error_messages)
Example #2
0
    def test_error_message_header_async_config_failed_codes(self):
        """
        Testing the header AsyncConfigFailedCodes.
        This function will test all code values for this enum class.
        :return: None
        """

        error_type = 15
        error_type_value = Error.ErrorType.OFPET_ASYNC_CONFIG_FAILED

        error_code = 0

        iter_given_code = Error.ErrorType.get_class(
            error_type_value).__iter__()
        length = Error.ErrorType.get_class(error_type_value).__len__()

        while error_code < self.MAX_ASYNC_CONFIG_FAILED_CODE_VALUE or length > 0:
            data = UBInt32(random.randint(2, 250)).pack()
            xid = random.randint(2, 250)

            test_value = b'\x05\x01\x00\x10' + UBInt32(xid).pack() + UBInt16(error_type).pack() + \
                        UBInt16(error_code).pack() + data

            if error_code < self.MAX_ASYNC_CONFIG_FAILED_CODE_VALUE:
                error_code += 1
            length -= 1

            test_object_error_messages = Error.ErrorMsg(
                xid, error_type_value, iter_given_code.__next__(),
                data).pack()

            self.assertEqual(test_value, test_object_error_messages)
Example #3
0
 def setUp(self):
     self.test_generic_failed_code = Error.GenericFailedCode
     self.test_bad_action_code = Error.BadActionCode
     self.test_bad_instruction_code = Error.BadInstructionCode
     self.test_bad_match_code = Error.BadMatchCode
     self.test_bad_request_code = Error.BadRequestCode
     self.test_error_type = Error.ErrorType
     self.test_flow_mod_failed_code = Error.FlowModFailedCode
     self.test_group_mod_failed_code = Error.GroupModFailedCode
     self.test_hello_failed_code = Error.HelloFailedCode
     self.test_meter_mod_failed_code = Error.MeterModFailedCode
     self.test_port_mod_failed_code = Error.PortModFailedCode
     self.test_queue_op_failed_code = Error.QueueOpFailedCode
     self.test_role_request_failed_code = Error.RoleRequestFailedCode
     self.test_switch_config_failed_code = Error.SwitchConfigFailedCode
     self.test_table_feature_failed_code = Error.TableFeaturesFailedCode
     self.test_table_mod_failed_code = Error.TableModFailedCode
     self.test_bad_property_code = Error.BadPropertyCode
     self.test_async_config_failed_code = Error.AsyncConfigFailedCode
     self.test_flow_monitor_failed_code = Error.FlowMonitorFailedCode
     self.test_bundle_failed_code = Error.BundleFailedCode
     self.test_error_message = Error.ErrorMsg()
     self.test_error_experimenter_message = Error.ErrorExperimenterMsg()