def test_do_select_all(test_dao): """ do_select_all() should return a Tree() object populated with RAMSTKFunction instances on success. """ DUT = dtmFunction(test_dao, test=True) assert DUT.do_select_all(revision_id=1) is None assert isinstance(DUT.tree, Tree) assert isinstance(DUT.tree.get_node(1).data, RAMSTKFunction)
def test_create_data_model(test_dao): """ __init__() should return a Function model. """ DUT = dtmFunction(test_dao, test=True) assert isinstance(DUT, dtmFunction) assert isinstance(DUT.tree, Tree) assert isinstance(DUT.dao, DAO)
def test_do_load_output_function(test_dao): """do_load_output() should return None when loading Functions for export.""" DUT = dtmExports(test_dao) _function = dtmFunction(test_dao, test=True) _function.do_select_all(revision_id=1) assert DUT.do_load_output('Function', _function.tree) is None
def test_request_do_load_output(test_dao, test_configuration): """ request_do_load_output() should return None.""" DUT = dtcExports(test_dao, test_configuration, test=True) _function = dtmFunction(test_dao, test=True) _function.do_select_all(revision_id=1) assert DUT.request_do_load_output('Function', _function.tree) is None
def test_do_select(test_dao): """ do_select() should return an instance of the RAMSTKFunction data model on success. """ DUT = dtmFunction(test_dao, test=True) DUT.do_select_all(revision_id=1) _function = DUT.do_select(1) assert isinstance(_function, RAMSTKFunction) assert _function.function_id == 1 assert _function.availability_logistics == 1.0
def test_do_export_to_text(test_dao, test_export_file): """do_export() should return None when exporting to a text file.""" DUT = dtmExports(test_dao) _function = dtmFunction(test_dao, test=True) _function.do_select_all(revision_id=1) DUT.do_load_output('Function', _function.tree) _test_text = test_export_file + '_function.txt' assert DUT.do_export('text', _test_text) is None
def test_do_update_all(test_dao): """ do_update_all() should return a zero error code on success. """ DUT = dtmFunction(test_dao, test=True) 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 " "function table.")
def test_do_update_non_existent_id(test_dao): """ do_update() should return a non-zero error code when passed a Function ID that doesn't exist. """ DUT = dtmFunction(test_dao, test=True) DUT.do_select_all(revision_id=1) _error_code, _msg = DUT.do_update(100) assert _error_code == 2005 assert _msg == ("RAMSTK ERROR: Attempted to save non-existent " "Function ID 100.")
def test_do_delete(test_dao): """ do_delete() should return a zero error code on success. """ DUT = dtmFunction(test_dao, test=True) DUT.do_select_all(revision_id=1) DUT.do_insert(revision_id=1, parent_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.")
def test_do_update(test_dao): """ do_update() should return a zero error code on success. """ DUT = dtmFunction(test_dao, test=True) DUT.do_select_all(revision_id=1) _function = DUT.tree.get_node(1).data _function.availability_logistics = 0.9832 _error_code, _msg = DUT.do_update(1) assert _error_code == 0 assert _msg == ("RAMSTK SUCCESS: Updating the RAMSTK Program " "database.")
def test_request_do_export_to_csv(test_dao, test_configuration, test_export_file): """ request_do_export() should return None when exporting to a CSV file. """ DUT = dtcExports(test_dao, test_configuration, test=True) _function = dtmFunction(test_dao, test=True) _function.do_select_all(revision_id=1) DUT.request_do_load_output('Function', _function.tree) _test_csv = test_export_file + '_function.csv' assert DUT.request_do_export('csv', _test_csv) is None
def test_do_insert_sibling(test_dao): """ do_insert() should return False on success when inserting a sibling Function. """ DUT = dtmFunction(test_dao, test=True) DUT.do_select_all(revision_id=1) _error_code, _msg = DUT.do_insert(revision_id=1, parent_id=0) assert _error_code == 0 assert _msg == ( "RAMSTK SUCCESS: Adding one or more items to the RAMSTK Program " "database.") assert DUT.last_id == 4 DUT.do_delete(DUT.last_id)
def test_do_select_non_existent_id(test_dao): """ do_select() should return None when a non-existent Function ID is requested. """ DUT = dtmFunction(test_dao, test=True) _function = DUT.do_select(100) assert _function is None