Пример #1
0
def test_request_do_insert_matrix_duplicate_row(test_dao, test_configuration):
    """ request_insert_matrix() should return True when attempting to insert a duplicate row. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    (_matrix, _column_hdrs, _row_hdrs) = DUT.request_do_select_all_matrix(
        1, 'hrdwr_vldtn')

    assert DUT.request_do_insert_matrix('hrdwr_vldtn', 2, 'S1:SS1:A2')
Пример #2
0
def test_request_do_update_matrix(test_dao, test_configuration):
    """ request_do_update_matrix() should return False on success. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)
    DUT.request_do_select_all_matrix(1, 'hrdwr_vldtn')

    assert not DUT.request_do_update_matrix(1, 'hrdwr_vldtn')
Пример #3
0
def test_request_do_select_non_existent_id(test_dao, test_configuration):
    """ request_do_select() should return None when requesting a Hardware item that doesn't exist. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)

    _hardware = DUT.request_do_select(100, table='general')

    assert _hardware is None
Пример #4
0
def test_request_do_insert_child(test_dao, test_configuration):
    """ request_do_insert() should return False on success when inserting a child Hardware item. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)
    DUT.request_do_select_all_matrix(1, 'hrdwr_rqrmnt')
    DUT.request_do_select_all_matrix(1, 'hrdwr_vldtn')

    assert not DUT.request_do_insert(revision_id=1, parent_id=1, part=0)
Пример #5
0
def test_request_do_select(test_dao, test_configuration):
    """ request_do_select() should return an instance of the RAMSTKHardware data model on success. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    _hardware = DUT.request_do_select(1, table='general')

    assert isinstance(_hardware, RAMSTKHardware)
Пример #6
0
def test_request_get_attributes(test_dao, test_configuration):
    """ request_get_attributes() should return a dict of {attribute name:attribute value} pairs for the RAMSTKHardware table. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    _attributes = DUT.request_get_attributes(1)

    assert isinstance(_attributes, dict)
    assert _attributes['revision_id'] == 1
Пример #7
0
def test_request_last_id(test_dao, test_configuration):
    """ request_last_id() should return the last Hardware ID used in the RAMSTK Program database. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    if pytest.mark.name == 'integration':
        assert DUT.request_last_id() == 12
    else:
        pass
Пример #8
0
def test_request_set_attributes_missing_nswc(test_dao, test_configuration):
    """ request_set_attributes() should return True when an attribute for the RAMSTKNSWC table is missing. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    ATTRIBUTES.pop('Clc')

    assert DUT.request_set_attributes(1, ATTRIBUTES)

    ATTRIBUTES['Clc'] = 0.0
Пример #9
0
def test_request_do_insert_matrix_row(test_dao, test_configuration):
    """ request_do_insert_matrix() should return False on successfully inserting a row. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    (_matrix, _column_hdrs, _row_hdrs) = DUT.request_do_select_all_matrix(
        1, 'hrdwr_vldtn')

    assert not DUT.request_do_insert_matrix('hrdwr_vldtn', 13, 'S1:SS1:A13')
    assert DUT._dmx_hw_vldtn_matrix.dic_row_hdrs[13] == 'S1:SS1:A13'
Пример #10
0
def test_request_set_attributes_missing_design_mechanic(
        test_dao, test_configuration):
    """ request_set_attributes() should return True when an attribute for the RAMSTKDesignMechanic table is missing. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    ATTRIBUTES.pop('pressure_upstream')

    assert DUT.request_set_attributes(1, ATTRIBUTES)

    ATTRIBUTES['pressure_upstream'] = 0.0
Пример #11
0
def test_request_set_attributes_missing_reliability(test_dao,
                                                    test_configuration):
    """ request_set_attributes() should return True when an attribute for the RAMSTKReliability table is missing. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    ATTRIBUTES.pop('hazard_rate_percent')

    assert DUT.request_set_attributes(1, ATTRIBUTES)

    ATTRIBUTES['hazard_rate_percent'] = 0.0
Пример #12
0
def test_request_set_attributes_missing_design_electric(
        test_dao, test_configuration):
    """ request_set_attributes() should return True when an attribute for the RAMSTKDesignElectric table is missing. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    ATTRIBUTES.pop('voltage_ac_operating')

    assert DUT.request_set_attributes(1, ATTRIBUTES)

    ATTRIBUTES['voltage_ac_operating'] = 0.0
Пример #13
0
def test_request_do_make_composite_reference_designator(
        test_dao, test_configuration):
    """ request_do_make_composite_reference_designator() should return a zero error code on success. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    (_error_code,
     _msg) = DUT.request_do_make_composite_reference_designator(node_id=1)

    assert _error_code == 0
    assert _msg == ''
    assert DUT.request_get_attributes(2)['comp_ref_des'] == 'S1:SS1'
Пример #14
0
def test_request_do_select_all_matrix(test_dao, test_configuration):
    """ request_do_select_all_matrix() should return a tuple containing the matrix, column headings, and row headings. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)

    (_matrix, _column_hdrs, _row_hdrs) = DUT.request_do_select_all_matrix(
        1, 'hrdwr_vldtn')

    assert isinstance(_matrix, pd.DataFrame)
    assert _column_hdrs[1] == ''
    assert _row_hdrs[1] == 'S1'
    assert _row_hdrs[2] == 'S1:SS1'
    assert _row_hdrs[3] == 'S1:SS2'
    assert _row_hdrs[4] == 'S1:SS3'
Пример #15
0
def test_request_do_insert_matrix_column(test_dao, test_configuration):
    """ request_do_insert_matrix() should return False on successfully inserting a column. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)
    (_matrix, _column_hdrs, _row_hdrs) = DUT.request_do_select_all_matrix(
        1, 'hrdwr_vldtn')

    if pytest.mark.name == 'integration':
        assert not DUT.request_insert_matrix(
            'hrdwr_vldtn', 1, 'Test Validation Task 1', row=False)
        assert DUT._dmx_hw_vldtn_matrix.dic_column_hdrs[
            1] == 'Test Validation Task 1'
    elif pytest.mark.name == 'hardware':
        assert not DUT.request_insert_matrix(
            'hrdwr_vldtn', 2, 'Test Validation Task 2', row=False)
        assert DUT._dmx_hw_vldtn_matrix.dic_column_hdrs[
            2] == 'Test Validation Task 2'
Пример #16
0
    def request_do_open_program(self):
        """
        Request an RAMSTK Program database be opened for analyses.

        :return: False if successful or True if an error is encountered.
        :rtype: bool
        """
        _return = False

        _database = None

        if self.RAMSTK_CONFIGURATION.RAMSTK_BACKEND == 'sqlite':
            _database = self.RAMSTK_CONFIGURATION.RAMSTK_BACKEND + ':///' + \
                self.RAMSTK_CONFIGURATION.RAMSTK_PROG_INFO['database']

        # If the database was successfully opened, create an instance of each
        # of the slave data controllers.
        _error_code, _msg = self.ramstk_model.do_open_program(_database)
        if _error_code == 0:
            pub.sendMessage('requestOpen')
            self.dic_controllers['revision'] = dtcRevision(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['function'] = dtcFunction(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['requirement'] = dtcRequirement(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['hardware'] = dtcHardwareBoM(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['validation'] = dtcValidation(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['profile'] = dtcUsageProfile(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['definition'] = dtcFailureDefinition(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['ffmea'] = dtcFMEA(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False,
                functional=True)
            self.dic_controllers['stakeholder'] = dtcStakeholder(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['allocation'] = dtcAllocation(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['hazops'] = dtcHazardAnalysis(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['similaritem'] = dtcSimilarItem(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False)
            self.dic_controllers['dfmeca'] = dtcFMEA(
                self.ramstk_model.program_dao,
                self.RAMSTK_CONFIGURATION,
                test=False,
                functional=False)
            self.dic_controllers['pof'] = dtcPoF(self.ramstk_model.program_dao,
                                                 self.RAMSTK_CONFIGURATION,
                                                 test=False)

            # Find which modules are active for the program being opened.
            self.dic_controllers['options'].request_do_select_all(site=False,
                                                                  program=True)
            _program_info = self.dic_controllers[
                'options'].request_get_options(site=False, program=True)
            self.RAMSTK_CONFIGURATION.RAMSTK_MODULES['function'] = \
                _program_info['function_active']
            self.RAMSTK_CONFIGURATION.RAMSTK_MODULES['requirement'] = \
                _program_info['requirement_active']
            self.RAMSTK_CONFIGURATION.RAMSTK_MODULES['hardware'] = \
                _program_info['hardware_active']
            self.RAMSTK_CONFIGURATION.RAMSTK_MODULES['validation'] = \
                _program_info['vandv_active']

            _page = 1
            for _module in self._lst_modules:
                if self.RAMSTK_CONFIGURATION.RAMSTK_MODULES[_module] == 1:
                    self.RAMSTK_CONFIGURATION.RAMSTK_PAGE_NUMBER[
                        _page] = _module
                    _page += 1

            # TODO: Where to put this code for the status icon?
            _icon = self.RAMSTK_CONFIGURATION.RAMSTK_ICON_DIR + \
                '/32x32/db-connected.png'
            _icon = gtk.gdk.pixbuf_new_from_file_at_size(_icon, 22, 22)
            self.icoStatus.set_from_pixbuf(_icon)
            self.icoStatus.set_tooltip(
                _(u"RAMSTK is connected to program database "
                  u"{0:s}.".format(
                      self.RAMSTK_CONFIGURATION.RAMSTK_PROG_INFO['database'])))

            self.loaded = True

            self.RAMSTK_CONFIGURATION.RAMSTK_USER_LOG.info(_msg)
            if not self.__test:
                pub.sendMessage('openedProgram')

        else:
            self.RAMSTK_CONFIGURATION.RAMSTK_DEBUG_LOG.error(_msg)
            _return = True

        return _return
Пример #17
0
def test_request_do_select_all(test_dao, test_configuration):
    """ request_do_select_all() should return a treelib Tree() with the Hardware BoM. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)

    assert isinstance(DUT.request_do_select_all(revision_id=1), Tree)
Пример #18
0
def test_data_controller_create(test_dao, test_configuration):
    """ __init__() should create an instance of a Hardware data controller. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)

    assert isinstance(DUT, dtcHardwareBoM)
    assert isinstance(DUT._dtm_data_model, dtmHardwareBoM)
Пример #19
0
def test_request_do_delete(test_dao, test_configuration):
    """ request_do_delete() should return False on success. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    assert not DUT.request_do_delete(DUT.request_last_id())
Пример #20
0
def test_request_do_delete_non_existent_id(test_dao, test_configuration):
    """ request_do_delete() should return True when attempting to delete a non-existent Node ID. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    assert DUT.request_do_delete(222)
Пример #21
0
def test_request_set_attributes(test_dao, test_configuration):
    """ request_set_attributes() should return False on success when setting the attributes. """
    DUT = dtcHardwareBoM(test_dao, test_configuration, test=True)
    DUT.request_do_select_all(revision_id=1)

    assert not DUT.request_set_attributes(1, ATTRIBUTES)