Beispiel #1
0
def test_do_select_all(test_dao):
    """ do_select_all() should return a treelib Tree() on success. """
    DUT = dtmPoF(test_dao)

    _tree = DUT.do_select_all(parent_id=1)

    assert isinstance(_tree, Tree)
Beispiel #2
0
def test_do_select_opstress(test_dao):
    """ do_select() should return an instance of RAMSTKOpStress on success."""
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)
    _entity = DUT.do_select('0.4.1.1.1s')

    assert isinstance(_entity, RAMSTKOpStress)
    assert _entity.description == 'Test Operating Stress'
Beispiel #3
0
def test_do_select_test_method(test_dao):
    """ do_select() should return an instance of RAMSTKTestMethod on success."""
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)
    _entity = DUT.do_select('0.4.1.1.1t')

    assert isinstance(_entity, RAMSTKTestMethod)
    assert _entity.description == 'Test Test Method'
Beispiel #4
0
def test_do_select_mechanism(test_dao):
    """ do_select() should return an instance of RAMSTKMechanism on success. """
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)

    _entity = DUT.do_select('0.4.1')

    assert isinstance(_entity, RAMSTKMechanism)
    assert _entity.description == 'Test Failure Mechanism #1 for Mode ID 4'
Beispiel #5
0
def test_do_select_mode(test_dao):
    """ do_select() should return an instance of RAMSTKMode on success. """
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)

    _entity = DUT.do_select('0.4')

    assert isinstance(_entity, RAMSTKMode)
    assert _entity.description == 'System Test Failure Mode'
Beispiel #6
0
def test_do_select_all_non_existent_id(test_dao):
    """ do_select_all() should return an empty Tree() when passed a Mechanism ID that doesn't exist. """
    DUT = dtmPoF(test_dao)

    _tree = DUT.do_select_all(parent_id=100)

    assert isinstance(_tree, Tree)
    assert _tree.get_node(0).tag == 'PhysicsOfFailure'
    assert _tree.get_node(1) is None
Beispiel #7
0
def test_pof_create_data_model(test_dao):
    """ __init__() should return an instance of the PoF data model. """
    DUT = dtmPoF(test_dao)

    assert isinstance(DUT, dtmPoF)
    assert isinstance(DUT.dtm_mechanism, dtmMechanism)
    assert isinstance(DUT.dtm_opload, dtmOpLoad)
    assert isinstance(DUT.dtm_opstress, dtmOpStress)
    assert isinstance(DUT.dtm_testmethod, dtmTestMethod)
Beispiel #8
0
def test_do_update(test_dao):
    """ do_update() should return a zero error code on success. """
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)

    _error_code, _msg = DUT.do_update('0.4.1')

    assert _error_code == 0
    assert _msg == ("RAMSTK SUCCESS: Updating the RAMSTK Program database.")
Beispiel #9
0
def test_do_update_all(test_dao):
    """ do_update_all() should return a zero error code on success. """
    DUT = dtmPoF(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 line items in the damage "
                    "modeling worksheet.")
Beispiel #10
0
def test_do_update_non_existent_node_id(test_dao):
    """ do_update() should return a 2106 error code when attempting to update a non-existent Node ID from a PoF. """
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)

    _error_code, _msg = DUT.do_update('mode_1000')

    assert _error_code == 2006
    assert _msg == ("RAMSTK ERROR: Attempted to save non-existent entity with "
                    "Node ID mode_1000.")
Beispiel #11
0
def test_do_delete_non_existent_node_id(test_dao):
    """ do_delete() should return a 2105 error code when attempting to remove a non-existant item from the PoF. """
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)

    _error_code, _msg = DUT.do_delete('scadamoosh_1')

    assert _error_code == 2005
    assert _msg == ("  RAMSTK ERROR: Attempted to delete non-existent entity "
                    "with Node ID scadamoosh_1 from the Physics of Failure.")
Beispiel #12
0
def test_do_delete_opload(test_dao):
    """ do_delete() should return a zero error code on success when removing an Operating Load. """
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)

    _node_id = '0.4.1.{0:d}'.format(DUT.dtm_opload.last_id)

    _error_code, _msg = DUT.do_delete(_node_id)

    assert _error_code == 0
    assert _msg == ("RAMSTK SUCCESS: Deleting an item from the RAMSTK Program "
                    "database.")
Beispiel #13
0
def test_do_insert_no_parent_in_tree(test_dao):
    """ do_insert() should return a 2005 error code when attempting to add something to a non-existant parent Node. """
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)

    _error_code, _msg = DUT.do_insert(entity_id=1,
                                      parent_id='mechanism_1',
                                      level='opload')

    assert _error_code == 2005
    assert _msg == (
        "RAMSTK ERROR: Attempted to add an item under non-existent "
        "Node ID: mechanism_1.")
Beispiel #14
0
def test_do_insert_non_existent_type(test_dao):
    """ do_insert() should return a non-zero error code when trying a something to a PoF at a level that doesn't exist. """
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)

    _error_code, _msg = DUT.do_insert(entity_id=1,
                                      parent_id='0.4.1.1',
                                      level='scadamoosh')

    # Verify the insert went well.
    assert _error_code == 2005
    assert _msg == ("RAMSTK ERROR: Attempted to add an item to the Physics of "
                    "Failure with an undefined indenture level.  Level "
                    "scadamoosh was requested.  Must be one of opload, "
                    "opstress, or testmethod.")
Beispiel #15
0
def test_do_insert_test_method(test_dao):
    """ do_insert() should return a zero error code on success when adding a new Test Method to a PoF. """
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)

    _error_code, _msg = DUT.do_insert(entity_id=1,
                                      parent_id='0.4.1.1',
                                      level='testmethod')

    # Verify the insert went well.
    assert _error_code == 0
    assert _msg == (
        "RAMSTK SUCCESS: Adding one or more items to the RAMSTK Program database."
    )

    # Verify the insert added an OpLoad.
    _node_id = '0.4.1.1.{0:d}t'.format(DUT.dtm_testmethod.last_id)
    _method = DUT.do_select(_node_id)

    assert isinstance(_method, RAMSTKTestMethod)
Beispiel #16
0
def test_do_insert_opstress(test_dao):
    """ do_insert() should return a zero error code on success when adding a new Operating Stress to a PoF. """
    DUT = dtmPoF(test_dao)
    DUT.do_select_all(parent_id=1)

    _error_code, _msg = DUT.do_insert(entity_id=1,
                                      parent_id='0.4.1.1',
                                      level='opstress')

    # Verify the insert went well.
    assert _error_code == 0
    assert _msg == (
        "RAMSTK SUCCESS: Adding one or more items to the RAMSTK Program database."
    )

    # Verify the insert added an OpStress.
    _node_id = '0.4.1.1.{0:d}s'.format(DUT.dtm_opstress.last_id)
    _opstress = DUT.do_select(_node_id)

    assert isinstance(_opstress, RAMSTKOpStress)