def test_do_select_all(test_dao): """ do_select_all() should return a Tree() object populated with RAMSTKRequirement instances on success. """ DUT = dtmRequirement(test_dao) _tree = DUT.do_select_all(revision_id=1) assert isinstance(_tree, Tree) assert isinstance(_tree.get_node(1).data, RAMSTKRequirement)
def test_data_model_create(test_dao): """ __init__() should return a Requirement model. """ DUT = dtmRequirement(test_dao) assert isinstance(DUT, dtmRequirement) assert isinstance(DUT.tree, Tree) assert isinstance(DUT.dao, DAO)
def test_do_load_output_requirement(test_dao): """do_load_output() should return None when loading Requirements for export.""" DUT = dtmExports(test_dao) _requirement = dtmRequirement(test_dao) _tree = _requirement.do_select_all(revision_id=1) assert DUT.do_load_output('Requirement', _tree) is None
def test_do_select_non_existent_id(test_dao): """ do_select() should return None when a non-existent Requirement ID is requested. """ DUT = dtmRequirement(test_dao) DUT.do_select_all(revision_id=1) _requirement = DUT.do_select(100) assert _requirement is None
def test_do_export_to_xlsm(test_dao, test_export_file): """do_export() should return None when exporting to an Excel file.""" DUT = dtmExports(test_dao) _requirement = dtmRequirement(test_dao) _tree = _requirement.do_select_all(revision_id=1) DUT.do_load_output('Requirement', _tree) _test_excel = test_export_file + '_requirement.xlsm' assert DUT.do_export('excel', _test_excel) is None
def test_do_select(test_dao): """ do_select() should return an instance of the RAMSTKRequirement data model on success. """ DUT = dtmRequirement(test_dao) DUT.do_select_all(revision_id=1) _requirement = DUT.do_select(1) assert isinstance(_requirement, RAMSTKRequirement) assert _requirement.requirement_id == 1 assert _requirement.requirement_code == 'REL-0001'
def test_do_update_all(test_dao): """ do_update_all() should return a zero error code on success. """ DUT = dtmRequirement(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 requirement " "table.")
def test_do_update_non_existent_id(test_dao): """ do_update() should return a non-zero error code when passed a Requirement ID that doesn't exist. """ DUT = dtmRequirement(test_dao) DUT.do_select_all(revision_id=1) _error_code, _msg = DUT.do_update('100') assert _error_code == 2006 assert _msg == ('RAMSTK ERROR: Attempted to save non-existent Requirement ' 'ID 100.')
def test_do_delete(test_dao): """ do_delete() should return a zero error code on success. """ DUT = dtmRequirement(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.') assert DUT.last_id == 2
def test_do_insert_child(test_dao): """ do_insert() should return False on success when inserting a child (derived) Requirement. """ DUT = dtmRequirement(test_dao) DUT.do_select_all(revision_id=1) _error_code, _msg = DUT.do_insert(revision_id=1, parent_id=DUT.last_id) assert _error_code == 0 assert _msg == ('RAMSTK SUCCESS: Adding one or more items to the RAMSTK ' 'Program database.') assert DUT.last_id == 3
def test_do_update(test_dao): """ do_update() should return a zero error code on success. """ DUT = dtmRequirement(test_dao) DUT.do_select_all(revision_id=1) _requirement = DUT.do_select(1) _requirement.requirement_code = 'REL-0001' _error_code, _msg = DUT.do_update(1) assert _error_code == 0 assert _msg == ('RAMSTK SUCCESS: Updating the RAMSTK Program database.')