Esempio n. 1
0
def test_create_mechanism_data_model(test_dao):
    """ __init__() should return instance of Mechanism data model. """
    DUT = dtmMechanism(test_dao)

    assert isinstance(DUT, dtmMechanism)
    assert isinstance(DUT.tree, Tree)
    assert isinstance(DUT.dao, DAO)
Esempio n. 2
0
def test_do_select_all(test_dao):
    """ do_select_all() should return a treelib Tree() on success when selecting Mechanisms. """
    DUT = dtmMechanism(test_dao)
    _tree = DUT.do_select_all(parent_id=4)

    assert isinstance(_tree, Tree)
    assert isinstance(_tree.get_node(1).data, RAMSTKMechanism)
Esempio n. 3
0
    def __init__(self, dao):
        """
        Initialize a PhysicsOfFailure data model instance.

        :param dao: the data access object for communicating with the RAMSTK
                    Program database.
        :type dao: :class:`ramstk.dao.DAO.DAO`
        """
        RAMSTKDataModel.__init__(self, dao)

        # Initialize private dictionary attributes.

        # Initialize private list attributes.

        # Initialize private scalar attributes.
        self._functional = False

        # Initialize public dictionary attributes.

        # Initialize public list attributes.

        # Initialize public scalar attributes.
        self.dtm_mode = dtmMode(dao)
        self.dtm_mechanism = dtmMechanism(dao)
        self.dtm_opload = OpLoadDataModel(dao)
        self.dtm_opstress = OpStressDataModel(dao)
        self.dtm_testmethod = TestMethodDataModel(dao)
Esempio n. 4
0
def test_do_select_non_existent_id(test_dao):
    """ do_select() should return None when a non-existent Mechanism ID is requested. """
    DUT = dtmMechanism(test_dao)
    DUT.do_select_all(parent_id=4)

    _mechanism = DUT.do_select('100')

    assert _mechanism is None
Esempio n. 5
0
def test_do_insert_3(test_dao):
    """ do_insert() should return a zero error code on success. """
    DUT = dtmMechanism(test_dao)
    DUT.do_select_all(parent_id=4)

    _error_code, _msg = DUT.do_insert(mode_id=4)

    assert _error_code == 0
    assert _msg == ("RAMSTK SUCCESS: Adding one or more items to the RAMSTK "
                    "Program database.")
Esempio n. 6
0
def test_do_select(test_dao):
    """ do_select() should return an instance of the RAMSTKMechanism data model on success. """
    DUT = dtmMechanism(test_dao)
    DUT.do_select_all(parent_id=4)

    _mechanism = DUT.do_select(1)

    assert isinstance(_mechanism, RAMSTKMechanism)
    assert _mechanism.mechanism_id == 1
    assert _mechanism.description == 'Test Failure Mechanism #1 for Mode ID 4'
Esempio n. 7
0
def test_do_update_non_existent_id(test_dao):
    """ do_update() should return a non-zero error code when passed an Mechanism ID that doesn't exist. """
    DUT = dtmMechanism(test_dao)
    DUT.do_select_all(parent_id=1)

    _error_code, _msg = DUT.do_update(100)

    assert _error_code == 2006
    assert _msg == (
        "RAMSTK ERROR: Attempted to save non-existent Mechanism ID 100.")
Esempio n. 8
0
def test_do_update_all(test_dao):
    """ do_update_all() should return a zero error code on success. """
    DUT = dtmMechanism(test_dao)
    DUT.do_select_all(parent_id=1)

    _error_code, _msg = DUT.do_update_all()

    assert _error_code == 0
    assert _msg == (
        "RAMSTK SUCCESS: Updating all records in the FMEA mechanisms "
        "table.")
Esempio n. 9
0
def test_do_delete(test_dao):
    """ do_delete() should return a zero error code on success. """
    DUT = dtmMechanism(test_dao)
    DUT.do_select_all(parent_id=4)

    __, __ = DUT.do_insert(mode_id=4)
    _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.")
Esempio n. 10
0
def test_do_update(test_dao):
    """ do_update() should return a zero error code on success. """
    DUT = dtmMechanism(test_dao)
    DUT.do_select_all(parent_id=4)

    _mechanism = DUT.do_select(1)
    _mechanism.pof_include = 1

    _error_code, _msg = DUT.do_update(1)

    assert _error_code == 0
    assert _msg == ("RAMSTK SUCCESS: Updating the RAMSTK Program database.")