Exemple #1
0
    def __init__(self, dao, configuration, **kwargs):
        """
        Initialize a Allocation data controller instance.

        :param dao: the data access object used to communicate with the
                    connected RAMSTK Program database.
        :type dao: :py:class:`ramstk.dao.DAO.DAO`
        :param configuration: the RAMSTK configuration instance.
        :type configuration: :py:class:`ramstk.Configuration.Configuration`
        """
        RAMSTKDataController.__init__(
            self,
            configuration,
            model=dtmAllocation(dao),
            ramstk_module='allocation',
            **kwargs)

        # Initialize private dictionary attributes.

        # Initialize private list attributes.

        # Initialize private scalar attributes.
        self._dtm_hardware_bom = dtmHardwareBoM(dao)

        # Initialize public dictionary attributes.
        self.dic_hardware_data = {}

        # Initialize public list attributes.

        # Initialize public scalar attributes.
        self.system_hazard_rate = 0.0

        pub.subscribe(self.insert_hardware_listener, 'insertedHardware')
        pub.subscribe(self.request_do_delete, 'deletedHardware')
Exemple #2
0
def test_do_load_output_hardware(test_dao):
    """do_load_output() should return None when loading Hardware for export."""
    DUT = dtmExports(test_dao)

    _hardware = dtmHardwareBoM(test_dao)
    _tree = _hardware.do_select_all(revision_id=1)

    assert DUT.do_load_output('Hardware', _tree) is None
Exemple #3
0
def test_do_update_non_existent_id(test_dao):
    """ do_update() should return a non-zero error code when passed a Hardware ID that doesn't exist. """
    DUT = dtmHardwareBoM(test_dao)
    DUT.do_select_all(revision_id=1)

    _error_code, _msg = DUT.do_update(100)

    assert _error_code == 12036
Exemple #4
0
def test_do_select_all(test_dao):
    """ do_select_all() should return a Tree() object populated with RAMSTKHardware instances on success. """
    DUT = dtmHardwareBoM(test_dao)

    _tree = DUT.do_select_all(revision_id=1)

    assert isinstance(_tree, Tree)
    assert isinstance(_tree.get_node(1).data, dict)
Exemple #5
0
def test_do_update_all(test_dao):
    """ do_update_all() should return a zero error code on success. """
    DUT = dtmHardwareBoM(test_dao)
    DUT.do_select_all(revision_id=1)

    _error_code, _msg = DUT.do_update_all()

    assert _error_code == 0
    assert _msg == ("RAMSTK SUCCESS: Updating all records in the hardware bill "
                    "of materials.")
Exemple #6
0
def test_do_delete_non_existent_id(test_dao):
    """ do_delete() should return a non-zero error code when passed a Hardware ID that doesn't exist. """
    DUT = dtmHardwareBoM(test_dao)
    DUT.do_select_all(revision_id=1)

    _error_code, _msg = DUT.do_delete(300)

    assert _error_code == 2005
    assert _msg == ('RAMSTK ERROR: Attempted to delete non-existent Hardware BoM '
                    'record ID 300.')
Exemple #7
0
def test_do_delete(test_dao):
    """ do_delete() should return a zero error code on success. """
    DUT = dtmHardwareBoM(test_dao)
    DUT.do_select_all(revision_id=1)

    _error_code, _msg = DUT.do_delete(DUT.last_id)

    assert _error_code == 0
    assert _msg == ('RAMSTK SUCCESS: Deleting an item from the RAMSTK Program '
                    'database.')
Exemple #8
0
def test_do_insert_part(test_dao):
    """ do_insert() should return a zero error code on success when inserting a child Hardware piece part. """
    DUT = dtmHardwareBoM(test_dao)
    DUT.do_select_all(revision_id=1)

    _error_code, _msg = DUT.do_insert(revision_id=1, parent_id=1, part=1)

    assert _error_code == 0
    assert _msg == ("RAMSTK SUCCESS: Adding a new hardware item to the RAMSTK "
                    "Program database.")
Exemple #9
0
def test_do_select(test_dao):
    """ do_select() should return an instance of the RAMSTKHardware data model on success. """
    DUT = dtmHardwareBoM(test_dao)
    DUT.do_select_all(revision_id=1)

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

    assert isinstance(_hardware, RAMSTKHardware)
    assert _hardware.ref_des == 'S1'
    assert _hardware.cage_code == ''
Exemple #10
0
def test_do_update(test_dao):
    """ do_update() should return a zero error code on success. """
    DUT = dtmHardwareBoM(test_dao)
    DUT.do_select_all(revision_id=1)

    _hardware = DUT.do_select(1, table='general')
    _hardware.cost = 0.9832

    _error_code, _msg = DUT.do_update(1)

    assert _error_code == 0
    assert _msg == ('RAMSTK SUCCESS: Updating the RAMSTK Program database.')
Exemple #11
0
def test_data_model_create(test_dao):
    """ __init__() should return a Hardware BoM model. """
    DUT = dtmHardwareBoM(test_dao)

    assert isinstance(DUT, dtmHardwareBoM)
    assert isinstance(DUT.dtm_hardware, dtmHardware)
    assert isinstance(DUT.dtm_design_electric, dtmDesignElectric)
    assert isinstance(DUT.dtm_design_mechanic, dtmDesignMechanic)
    assert isinstance(DUT.dtm_mil_hdbk_f, dtmMilHdbkF)
    assert isinstance(DUT.dtm_nswc, dtmNSWC)
    assert isinstance(DUT.dtm_reliability, dtmReliability)
    assert isinstance(DUT.tree, Tree)
    assert isinstance(DUT.dao, DAO)
    assert DUT._tag == 'HardwareBoM'
Exemple #12
0
def test_do_select_non_existent_id(test_dao):
    """ do_select() should return None when a non-existent Hardware ID is requested. """
    DUT = dtmHardwareBoM(test_dao)

    assert DUT.do_select(100, table='general') is None