Beispiel #1
0
    def set_attributes(self, attributes):
        """
        Method to set the current values of the RAMSTKUnit data model
        attributes.

        :param tuple attributes: tuple containing the values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKUnit {0:d} attributes.". \
            format(self.unit_id)

        try:
            self.code = str(none_to_default(attributes[0], 'Unit Code'))
            self.description = str(
                none_to_default(attributes[2], 'Unit Description'))
            self.unit_type = str(none_to_default(attributes[2], ''))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKUnit.set_attributes()."
        except TypeError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKUnit attributes."

        return _error_code, _msg
Beispiel #2
0
    def set_attributes(self, attributes):
        """
        RPN to set the current values of the RAMSTKRPN data model
        attributes.

        :param tuple attributes: tuple containing the values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKRPN {0:d} attributes.". \
            format(self.rpn_id)

        try:
            self.name = str(none_to_default(attributes[0], 'RPN Name'))
            self.description = str(
                none_to_default(attributes[1], 'RPN Description'))
            self.rpn_type = str(none_to_default(attributes[2], ''))
            self.value = int(none_to_default(attributes[3], 0))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKRPN.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKRPN attributes."

        return _error_code, _msg
    def set_attributes(self, attributes):
        """
        Method to set the RAMSTKSoftwareDevelopment data model attributes.

        :param tuple attributes: tuple of values to assign to the instance
                                 attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKSoftwareDevelopment {0:d} " \
               "attributes.".format(self.software_id)

        try:
            self.answer = int(none_to_default(attributes[0], 0))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKSoftwareDevelopment.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKSoftwareDevelopment attributes."

        return _error_code, _msg
Beispiel #4
0
def test_error_handler_zero_division_error():
    """ error_handler() should return a 20 error code when passed a ZeroDivisionError string. """
    _error_code = error_handler(['float division by zero dunna work dude'])
    assert _error_code == 20

    _error_code = error_handler(
        ['That was integer division or modulo by zero'])
    assert _error_code == 20
Beispiel #5
0
def test_error_handler_value_error():
    """ error_handler() should return a 10 error code when passed a ValueError string. """
    _error_code = error_handler(
        ['That is invalid literal for int() with base 10'])
    assert _error_code == 10

    _error_code = error_handler(['I could not convert string to float'])
    assert _error_code == 10
Beispiel #6
0
    def set_attributes(self, attributes):
        """
        Method to set the RAMSTKGrowthTest data model attributes.

        :param tuple attributes: tuple of values to assign to the instance
                                 attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKGrowthTest {0:d} attributes.". \
               format(self.phase_id)

        try:
            self.i_mi = float(none_to_default(attributes[0], 0.0))
            self.i_mf = float(none_to_default(attributes[1], 0.0))
            self.i_ma = float(none_to_default(attributes[2], 0.0))
            self.i_num_fails = int(none_to_default(attributes[3], 0))
            self.p_growth_rate = float(none_to_default(attributes[4], 0.0))
            self.p_ms = float(none_to_default(attributes[5], 0.0))
            self.p_fef_avg = float(none_to_default(attributes[6], 0.0))
            self.p_prob = float(none_to_default(attributes[7], 0.0))
            self.p_mi = float(none_to_default(attributes[8], 0.0))
            self.p_mf = float(none_to_default(attributes[9], 0.0))
            self.p_ma = float(none_to_default(attributes[10], 0.0))
            self.p_test_time = float(none_to_default(attributes[11], 0.0))
            self.p_num_fails = float(none_to_default(attributes[12], 0.0))
            self.p_start_date = none_to_default(attributes[13], date.today())
            self.p_end_date = none_to_default(attributes[14], date.today())
            self.p_weeks = float(none_to_default(attributes[15], 0.0))
            self.p_test_units = int(none_to_default(attributes[16], 0))
            self.p_tpu = float(none_to_default(attributes[17], 0.0))
            self.p_tpupw = float(none_to_default(attributes[18], 0.0))
            self.o_growth_rate = float(none_to_default(attributes[19], 0.0))
            self.o_ms = float(none_to_default(attributes[20], 0.0))
            self.o_fef_avg = float(none_to_default(attributes[21], 0.0))
            self.o_mi = float(none_to_default(attributes[22], 0.0))
            self.o_mf = float(none_to_default(attributes[23], 0.0))
            self.o_ma = float(none_to_default(attributes[24], 0.0))
            self.o_test_time = float(none_to_default(attributes[25], 0.0))
            self.o_num_fails = int(none_to_default(attributes[26], 0))
            self.o_ttff = float(none_to_default(attributes[27], 0.0))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKGrowthTest.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKGrowthTest attributes."

        return _error_code, _msg
Beispiel #7
0
    def set_attributes(self, attributes):
        """
        Method to set the RAMSTKSurvivalData data model attributes.

        :param tuple attributes: tuple of values to assign to the instance
                                 attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKSurvivalData {0:d} attributes.". \
               format(self.record_id)

        try:
            self.name = str(none_to_default(attributes[0], ''))
            self.source_id = int(none_to_default(attributes[1], 0))
            self.failure_date = none_to_default(attributes[2], date.today())
            self.left_interval = float(none_to_default(attributes[3], 0.0))
            self.right_interval = float(none_to_default(attributes[4], 0.0))
            self.status_id = int(none_to_default(attributes[5], 0))
            self.quantity = int(none_to_default(attributes[6], 0))
            self.tbf = float(none_to_default(attributes[7], 0.0))
            self.mode_type_id = int(none_to_default(attributes[8], 0))
            self.nevada_chart = int(none_to_default(attributes[9], 0))
            self.ship_date = none_to_default(attributes[10], date.today())
            self.number_shipped = int(none_to_default(attributes[11], 0))
            self.return_date = none_to_default(attributes[12], date.today())
            self.number_returned = int(none_to_default(attributes[13], 0))
            self.user_float_1 = float(none_to_default(attributes[14], 0.0))
            self.user_float_2 = float(none_to_default(attributes[15], 0.0))
            self.user_float_3 = float(none_to_default(attributes[16], 0.0))
            self.user_integer_1 = int(none_to_default(attributes[17], 0))
            self.user_integer_2 = int(none_to_default(attributes[18], 0))
            self.user_integer_3 = int(none_to_default(attributes[19], 0))
            self.user_string_1 = str(none_to_default(attributes[20], ''))
            self.user_string_2 = str(none_to_default(attributes[21], ''))
            self.user_string_3 = str(none_to_default(attributes[22], ''))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKSurvivalData.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKSurvivalData attributes."

        return _error_code, _msg
Beispiel #8
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKFailureDefinition attributes.

        :param dict attributes: dict containing {attr name:attr value} pairs
                                of the values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKFailureDefinition {0:d} attributes.".\
            format(self.definition_id)

        try:
            self.definition = str(
                none_to_default(attributes['definition'],
                                'Failure Definition'))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKFailureDefinition.set_attributes().".format(_err)
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKFailureDefinition attributes."

        return _error_code, _msg
Beispiel #9
0
    def set_attributes(self, values):
        """
        Method to set the RAMSTKIncidentAction data model attributes.

        :param tuple values: tuple of values to assign to the instance
                             attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKIncidentAction {0:d} attributes.". \
               format(self.action_id)

        try:
            self.action_owner = int(none_to_default(values[0], 0))
            self.action_prescribed = str(none_to_default(values[1], ''))
            self.action_taken = str(none_to_default(values[2], ''))
            self.approved = int(none_to_default(values[3], 0))
            self.approved_by = int(none_to_default(values[4], 0))
            self.approved_date = none_to_default(
                values[5],
                date.today() + timedelta(days=30))
            self.closed = int(none_to_default(values[6], 0))
            self.closed_by = int(none_to_default(values[7], 0))
            self.closed_date = none_to_default(
                values[8],
                date.today() + timedelta(days=30))
            self.due_date = none_to_default(values[9],
                                            date.today() + timedelta(days=30))
            self.status_id = int(none_to_default(values[10], 0))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKIncidentAction.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKIncidentAction attributes."

        return _error_code, _msg
Beispiel #10
0
    def set_attributes(self, values):
        """
        Method to set the Incident Component data model attributes.

        :param tuple values: tuple of values to assign to the instance
                             attributes.
        :return: (_error_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKIncidentDetail {0:d} attributes.". \
               format(self.incident_id)

        try:
            self.age_at_incident = float(none_to_default(values[0], 0.0))
            self.cnd_nff = int(none_to_default(values[1], 0))
            self.failure = int(none_to_default(values[2], 0))
            self.initial_installation = int(none_to_default(values[3], 0))
            self.interval_censored = int(none_to_default(values[4], 0))
            self.mode_type_id = int(none_to_default(values[5], 0))
            self.occ_fault = int(none_to_default(values[6], 0))
            self.suspension = int(none_to_default(values[7], 0))
            self.ttf = float(none_to_default(values[8], 0.0))
            self.use_op_time = int(none_to_default(values[9], 0))
            self.use_cal_time = int(none_to_default(values[10], 0))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKIncidentDetail.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKIncidentDetail attributes."

        return _error_code, _msg
Beispiel #11
0
    def set_attributes(self, attributes):
        """
        Method to set the RAMSTKTest data model attributes.

        :param tuple attributes: tuple of values to assign to the instance
                                 attributes.
        :return: (_error_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKTest {0:d} attributes.". \
               format(self.test_id)

        try:
            self.assess_model_id = int(none_to_default(attributes[0], 0))
            self.attachment = str(none_to_default(attributes[1], ''))
            self.avg_fef = float(none_to_default(attributes[2], 0.0))
            self.avg_growth = float(none_to_default(attributes[3], 0.0))
            self.avg_ms = float(none_to_default(attributes[4], 0.0))
            self.chi_square = float(none_to_default(attributes[5], 0.0))
            self.confidence = float(none_to_default(attributes[6], 0.0))
            self.consumer_risk = float(none_to_default(attributes[7], 0.0))
            self.cramer_vonmises = float(none_to_default(attributes[8], 0.0))
            self.cum_failures = int(none_to_default(attributes[9], 0))
            self.cum_mean = float(none_to_default(attributes[10], 0.0))
            self.cum_mean_ll = float(none_to_default(attributes[11], 0.0))
            self.cum_mean_se = float(none_to_default(attributes[12], 0.0))
            self.cum_mean_ul = float(none_to_default(attributes[13], 0.0))
            self.cum_time = float(none_to_default(attributes[14], 0.0))
            self.description = str(none_to_default(attributes[15], ''))
            self.grouped = int(none_to_default(attributes[16], 0))
            self.group_interval = float(none_to_default(attributes[17], 0.0))
            self.inst_mean = float(none_to_default(attributes[18], 0.0))
            self.inst_mean_ll = float(none_to_default(attributes[19], 0.0))
            self.inst_mean_se = float(none_to_default(attributes[20], 0.0))
            self.inst_mean_ul = float(none_to_default(attributes[21], 0.0))
            self.mg = float(none_to_default(attributes[22], 0.0))
            self.mgp = float(none_to_default(attributes[23], 0.0))
            self.n_phases = int(none_to_default(attributes[24], 1))
            self.name = str(none_to_default(attributes[25], ''))
            self.plan_model_id = int(none_to_default(attributes[26], 0))
            self.prob = float(none_to_default(attributes[27], 75.0))
            self.producer_risk = float(none_to_default(attributes[28], 0.0))
            self.scale = float(none_to_default(attributes[29], 0.0))
            self.scale_ll = float(none_to_default(attributes[30], 0.0))
            self.scale_se = float(none_to_default(attributes[31], 0.0))
            self.scale_ul = float(none_to_default(attributes[32], 0.0))
            self.shape = float(none_to_default(attributes[33], 0.0))
            self.shape_ll = float(none_to_default(attributes[34], 0.0))
            self.shape_se = float(none_to_default(attributes[35], 0.0))
            self.shape_ul = float(none_to_default(attributes[36], 0.0))
            self.tr = float(none_to_default(attributes[37], 0.0))
            self.ttt = float(none_to_default(attributes[38], 0.0))
            self.ttff = float(none_to_default(attributes[39], 0.0))
            self.type_id = int(none_to_default(attributes[40], 0))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKTest.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKTest attributes."

        return _error_code, _msg
Beispiel #12
0
    def set_attributes(self, attributes):
        """
        Method to set the RAMSTKSurvival data model attributes.

        :param tuple attributes: tuple of values to assign to the instance
                                 attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKSurvival {0:d} attributes.". \
               format(self.survival_id)

        try:
            self.hardware_id = int(none_to_default(attributes[0], 0))
            self.description = str(none_to_default(attributes[1], ''))
            self.source_id = int(none_to_default(attributes[2], 0))
            self.distribution_id = int(none_to_default(attributes[3], 0))
            self.confidence = float(none_to_default(attributes[4], 75.0))
            self.confidence_type_id = int(none_to_default(attributes[5], 0))
            self.confidence_method_id = int(none_to_default(attributes[6], 0))
            self.fit_method_id = int(none_to_default(attributes[7], 0))
            self.rel_time = float(none_to_default(attributes[8], 0.0))
            self.n_rel_points = int(none_to_default(attributes[9], 0))
            self.n_suspension = int(none_to_default(attributes[10], 0))
            self.n_failures = int(none_to_default(attributes[11], 0))
            self.scale_ll = float(none_to_default(attributes[12], 0.0))
            self.scale = float(none_to_default(attributes[13], 0.0))
            self.scale_ul = float(none_to_default(attributes[14], 0.0))
            self.shape_ll = float(none_to_default(attributes[15], 0.0))
            self.shape = float(none_to_default(attributes[16], 0.0))
            self.shape_ul = float(none_to_default(attributes[17], 0.0))
            self.location_ll = float(none_to_default(attributes[18], 0.0))
            self.location = float(none_to_default(attributes[19], 0.0))
            self.location_ul = float(none_to_default(attributes[20], 0.0))
            self.variance_1 = float(none_to_default(attributes[21], 0.0))
            self.variance_2 = float(none_to_default(attributes[22], 0.0))
            self.variance_3 = float(none_to_default(attributes[23], 0.0))
            self.covariance_1 = float(none_to_default(attributes[24], 0.0))
            self.covariance_2 = float(none_to_default(attributes[25], 0.0))
            self.covariance_3 = float(none_to_default(attributes[26], 0.0))
            self.mhb = float(none_to_default(attributes[27], 0.0))
            self.lp = float(none_to_default(attributes[28], 0.0))
            self.lr = float(none_to_default(attributes[29], 0.0))
            self.aic = float(none_to_default(attributes[30], 0.0))
            self.bic = float(none_to_default(attributes[31], 0.0))
            self.mle = float(none_to_default(attributes[32], 0.0))
            self.start_time = float(none_to_default(attributes[33], 0.0))
            self.start_date = none_to_default(attributes[34], date.today())
            self.end_date = none_to_default(attributes[35],
                                            date.today() + timedelta(days=30))
            self.nevada_chart = int(none_to_default(attributes[36], 0))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKSurvival.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKSurvival attributes."

        return _error_code, _msg
Beispiel #13
0
def test_error_handler_default():
    """ error_handler() should return a 1000 error code when passed a error string it can't parse. """
    _error_code = error_handler(['Some kinda error message'])
    assert _error_code == 1000
Beispiel #14
0
def test_error_handler_index_error():
    """ error_handler() should return a 40 error code when passed a IndexError string. """
    _error_code = error_handler(['That index out of range'])
    assert _error_code == 40
Beispiel #15
0
    def set_attributes(self, attributes):
        """
        Method to set the RAMSTKIncident data model attributes.

        :param tuple attributes: tuple of values to assign to the instance
                                 attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKIncident {0:d} attributes.". \
               format(self.incident_id)

        try:
            self.accepted = int(none_to_default(attributes[0], 0))
            self.approved = int(none_to_default(attributes[1], 0))
            self.approved_by = int(none_to_default(attributes[2], 0))
            self.analysis = str(none_to_default(attributes[3], ''))
            self.category_id = int(none_to_default(attributes[4], 0))
            self.chargeable = int(none_to_default(attributes[5], -1))
            self.chargeable_1 = int(none_to_default(attributes[6], -1))
            self.chargeable_2 = int(none_to_default(attributes[7], -1))
            self.chargeable_3 = int(none_to_default(attributes[8], -1))
            self.chargeable_4 = int(none_to_default(attributes[9], -1))
            self.chargeable_5 = int(none_to_default(attributes[10], -1))
            self.chargeable_6 = int(none_to_default(attributes[11], -1))
            self.chargeable_7 = int(none_to_default(attributes[12], -1))
            self.chargeable_8 = int(none_to_default(attributes[13], -1))
            self.chargeable_9 = int(none_to_default(attributes[14], -1))
            self.chargeable_10 = int(none_to_default(attributes[15], -1))
            self.complete = int(none_to_default(attributes[16], 0))
            self.complete_by = int(none_to_default(attributes[17], 0))
            self.cost = float(none_to_default(attributes[18], 0.0))
            self.criticality_id = int(none_to_default(attributes[19], 0))
            self.date_approved = none_to_default(
                attributes[20],
                date.today() + timedelta(days=30))
            self.date_complete = none_to_default(
                attributes[21],
                date.today() + timedelta(days=30))
            self.date_requested = none_to_default(attributes[22], date.today())
            self.date_reviewed = none_to_default(
                attributes[23],
                date.today() + timedelta(days=30))
            self.description_long = str(none_to_default(attributes[24], ''))
            self.description_short = str(none_to_default(attributes[25], ''))
            self.detection_method_id = int(none_to_default(attributes[26], 0))
            self.execution_time = float(none_to_default(attributes[27], 0.0))
            self.hardware_id = int(none_to_default(attributes[28], 0))
            self.incident_age = int(none_to_default(attributes[29], 0))
            self.life_cycle_id = int(none_to_default(attributes[30], 0))
            self.relevant = int(none_to_default(attributes[31], -1))
            self.relevant_1 = int(none_to_default(attributes[32], -1))
            self.relevant_2 = int(none_to_default(attributes[33], -1))
            self.relevant_3 = int(none_to_default(attributes[34], -1))
            self.relevant_4 = int(none_to_default(attributes[35], -1))
            self.relevant_5 = int(none_to_default(attributes[36], -1))
            self.relevant_6 = int(none_to_default(attributes[37], -1))
            self.relevant_7 = int(none_to_default(attributes[38], -1))
            self.relevant_8 = int(none_to_default(attributes[39], -1))
            self.relevant_9 = int(none_to_default(attributes[40], -1))
            self.relevant_10 = int(none_to_default(attributes[41], -1))
            self.relevant_11 = int(none_to_default(attributes[42], -1))
            self.relevant_12 = int(none_to_default(attributes[43], -1))
            self.relevant_13 = int(none_to_default(attributes[44], -1))
            self.relevant_14 = int(none_to_default(attributes[45], -1))
            self.relevant_15 = int(none_to_default(attributes[46], -1))
            self.relevant_16 = int(none_to_default(attributes[47], -1))
            self.relevant_17 = int(none_to_default(attributes[48], -1))
            self.relevant_18 = int(none_to_default(attributes[49], -1))
            self.relevant_19 = int(none_to_default(attributes[50], -1))
            self.relevant_20 = int(none_to_default(attributes[51], -1))
            self.remarks = str(none_to_default(attributes[52], ''))
            self.request_by = int(none_to_default(attributes[53], 0))
            self.reviewed = int(none_to_default(attributes[54], 0))
            self.reviewed_by = int(none_to_default(attributes[55], 0))
            self.software_id = int(none_to_default(attributes[56], 0))
            self.status_id = int(none_to_default(attributes[57], 0))
            self.test_case = str(none_to_default(attributes[58], ''))
            self.test_found = str(none_to_default(attributes[59], ''))
            self.type_id = int(none_to_default(attributes[60], 0))
            self.unit = str(none_to_default(attributes[61], ''))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKIncident.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKIncident attributes."

        return _error_code, _msg
Beispiel #16
0
def test_error_handler_type_error():
    """ error_handler() should return a 10 error code when passed a TypeError string. """
    _error_code = error_handler(
        ['The argument must be a string or a number dude!'])
    assert _error_code == 10
Beispiel #17
0
    def set_attributes(self, attributes):
        """
        Method to set the RAMSTKSoftware data model attributes.

        :param tuple attributes: tuple of values to assign to the instance
                                 attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKSoftware {0:d} attributes.". \
               format(self.software_id)

        try:
            self.a = float(none_to_default(attributes[0], 0.0))
            self.aloc = int(none_to_default(attributes[1], 0))
            self.am = float(none_to_default(attributes[2], 0.0))
            self.application_id = int(none_to_default(attributes[3], 0))
            self.ax = int(none_to_default(attributes[4], 0))
            self.budget_test = float(none_to_default(attributes[5], 0.0))
            self.budget_dev = float(none_to_default(attributes[6], 0.0))
            self.bx = int(none_to_default(attributes[7], 0))
            self.category_id = int(none_to_default(attributes[8], 0))
            self.cb = int(none_to_default(attributes[9], 0))
            self.cx = int(none_to_default(attributes[10], 0))
            self.d = float(none_to_default(attributes[11], 0.0))
            self.dc = float(none_to_default(attributes[12], 0.0))
            self.dd = int(none_to_default(attributes[13], 0))
            self.description = str(none_to_default(attributes[14], ''))
            self.development_id = int(none_to_default(attributes[15], 0))
            self.dev_assess_type_id = int(none_to_default(attributes[16], 0))
            self.df = float(none_to_default(attributes[17], 0.0))
            self.do = float(none_to_default(attributes[18], 0.0))
            self.dr = float(none_to_default(attributes[19], 0.0))
            self.dr_eot = int(none_to_default(attributes[20], 0))
            self.dr_test = int(none_to_default(attributes[21], 0))
            self.e = float(none_to_default(attributes[22], 0.0))
            self.ec = float(none_to_default(attributes[23], 0.0))
            self.et = float(none_to_default(attributes[24], 0.0))
            self.ev = float(none_to_default(attributes[25], 0.0))
            self.ew = float(none_to_default(attributes[26], 0.0))
            self.f = float(none_to_default(attributes[27], 0.0))
            self.ft1 = float(none_to_default(attributes[28], 0.0))
            self.ft2 = float(none_to_default(attributes[29], 0.0))
            self.hloc = int(none_to_default(attributes[30], 0))
            self.labor_hours_dev = float(none_to_default(attributes[31], 0.0))
            self.labor_hours_test = float(none_to_default(attributes[32], 0.0))
            self.level = int(none_to_default(attributes[33], 0))
            self.loc = int(none_to_default(attributes[34], 0))
            self.n_branches = int(none_to_default(attributes[35], 0))
            self.n_branches_test = int(none_to_default(attributes[36], 0))
            self.n_inputs = int(none_to_default(attributes[37], 0))
            self.n_inputs_test = int(none_to_default(attributes[38], 0))
            self.n_interfaces = int(none_to_default(attributes[39], 0))
            self.n_interfaces_test = int(none_to_default(attributes[40], 0))
            self.ncb = int(none_to_default(attributes[41], 0))
            self.nm = int(none_to_default(attributes[42], 0))
            self.nm_test = int(none_to_default(attributes[43], 0))
            self.os = float(none_to_default(attributes[44], 0.0))
            self.parent_id = int(none_to_default(attributes[45], 0))
            self.phase_id = int(none_to_default(attributes[46], 0))
            self.ren_avg = float(none_to_default(attributes[47], 0.0))
            self.ren_eot = float(none_to_default(attributes[48], 0.0))
            self.rpfom = float(none_to_default(attributes[49], 0.0))
            self.s1 = float(none_to_default(attributes[50], 0.0))
            self.s2 = float(none_to_default(attributes[51], 0.0))
            self.sa = float(none_to_default(attributes[52], 0.0))
            self.schedule_dev = float(none_to_default(attributes[53], 0.0))
            self.schedule_test = float(none_to_default(attributes[54], 0.0))
            self.sl = float(none_to_default(attributes[55], 0.0))
            self.sm = float(none_to_default(attributes[56], 0.0))
            self.sq = float(none_to_default(attributes[57], 0.0))
            self.sr = float(none_to_default(attributes[58], 0.0))
            self.st = float(none_to_default(attributes[59], 0.0))
            self.sx = float(none_to_default(attributes[60], 0.0))
            self.t = float(none_to_default(attributes[61], 0.0))
            self.tc = float(none_to_default(attributes[62], 0.0))
            self.tcl = int(none_to_default(attributes[63], 0))
            self.te = float(none_to_default(attributes[64], 0.0))
            self.test_approach = int(none_to_default(attributes[65], 0))
            self.test_effort = int(none_to_default(attributes[66], 0))
            self.test_path = int(none_to_default(attributes[67], 0))
            self.test_time = float(none_to_default(attributes[68], 0.0))
            self.test_time_eot = float(none_to_default(attributes[69], 0.0))
            self.tm = float(none_to_default(attributes[70], 0.0))
            self.um = int(none_to_default(attributes[71], 0))
            self.wm = int(none_to_default(attributes[72], 0))
            self.xm = int(none_to_default(attributes[73], 0))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKSoftware.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKSoftware attributes."

        return _error_code, _msg