From 1db8524726b5d1f07b96b664e9e91954064a5621 Mon Sep 17 00:00:00 2001 From: Doyle Rowland Date: Fri, 11 Mar 2022 08:44:22 -0500 Subject: [PATCH] feat: rename fld_action_recommended to fld_description (#1028) * refactor: rename action_recommended field to description * test: update test suite * refactor: change fld_action_recommended to fld_description in database --- data/postgres_program_db.sql | 4 +- .../dbrecords/programdb_action_record.py | 12 +- src/ramstk/views/gtk3/fmea/panel.py | 2 +- .../action/action_integration_test.py | 184 +++++++++--------- .../programdb/action/action_unit_test.py | 101 +++++----- tests/models/programdb/action/conftest.py | 6 +- 6 files changed, 153 insertions(+), 156 deletions(-) diff --git a/data/postgres_program_db.sql b/data/postgres_program_db.sql index b3ec70614..78a305382 100644 --- a/data/postgres_program_db.sql +++ b/data/postgres_program_db.sql @@ -755,7 +755,7 @@ CREATE TABLE ramstk_action ( fld_mechanism_id INTEGER NOT NULL, fld_cause_id INTEGER NOT NULL, fld_action_id INTEGER NOT NULL, - fld_action_recommended VARCHAR DEFAULT '', + fld_description VARCHAR DEFAULT '', fld_action_category VARCHAR(512) DEFAULT '', fld_action_owner VARCHAR(512) DEFAULT '', fld_action_due_date DATE DEFAULT CURRENT_DATE + INTERVAL '30 day', @@ -1236,7 +1236,7 @@ AS SELECT md.fld_revision_id, mc.fld_description AS mc_description, cs.fld_description AS cs_description, ct.fld_description AS ct_description, - ac.fld_action_recommended AS ac_description, + ac.fld_description AS ac_description, md.fld_mission, md.fld_mission_phase, md.fld_effect_local, diff --git a/src/ramstk/models/dbrecords/programdb_action_record.py b/src/ramstk/models/dbrecords/programdb_action_record.py index 409faef26..45e1f67d5 100644 --- a/src/ramstk/models/dbrecords/programdb_action_record.py +++ b/src/ramstk/models/dbrecords/programdb_action_record.py @@ -27,7 +27,7 @@ class RAMSTKActionRecord(RAMSTK_BASE, RAMSTKBaseRecord): # type: ignore """ __defaults__ = { - "action_recommended": "", + "description": "", "action_category": "", "action_owner": "", "action_due_date": date.today() + timedelta(days=30), @@ -80,10 +80,10 @@ class RAMSTKActionRecord(RAMSTK_BASE, RAMSTKBaseRecord): # type: ignore nullable=False, ) - action_recommended = Column( - "fld_action_recommended", + description = Column( + "fld_description", String, - default=__defaults__["action_recommended"], + default=__defaults__["description"], ) action_category = Column( "fld_action_category", @@ -131,7 +131,7 @@ class RAMSTKActionRecord(RAMSTK_BASE, RAMSTKBaseRecord): # type: ignore def get_attributes(self): """Retrieve current values of the RAMSTKAction data model attributes. - :return: {cause_id, action_id, action_recommended, + :return: {cause_id, action_id, description, action_category, action_owner, action_due_date, action_status, action_taken, action_approved, action_approved_date, action_closed, @@ -141,7 +141,7 @@ def get_attributes(self): return { "cause_id": self.cause_id, "action_id": self.action_id, - "action_recommended": self.action_recommended, + "description": self.description, "action_category": self.action_category, "action_owner": self.action_owner, "action_due_date": self.action_due_date, diff --git a/src/ramstk/views/gtk3/fmea/panel.py b/src/ramstk/views/gtk3/fmea/panel.py index 5cce366c3..013079bf0 100644 --- a/src/ramstk/views/gtk3/fmea/panel.py +++ b/src/ramstk/views/gtk3/fmea/panel.py @@ -1428,7 +1428,7 @@ def __do_load_action(self, node: treelib.Node, row: Gtk.TreeIter) -> Gtk.TreeIte _entity.cause_id, 0, _entity.action_id, - _entity.action_recommended, + _entity.description, "", "", "", diff --git a/tests/models/programdb/action/action_integration_test.py b/tests/models/programdb/action/action_integration_test.py index 2bbe03a08..e0dc719aa 100644 --- a/tests/models/programdb/action/action_integration_test.py +++ b/tests/models/programdb/action/action_integration_test.py @@ -19,7 +19,7 @@ @pytest.fixture(scope="class") -def test_tablemodel(test_program_dao): +def test_table_model(test_program_dao): """Get a data manager instance for each test class.""" # Create the device under test (dut) and connect to the database. dut = RAMSTKActionTable() @@ -46,7 +46,7 @@ def test_tablemodel(test_program_dao): del dut -@pytest.mark.usefixtures("test_tablemodel") +@pytest.mark.usefixtures("test_table_model") class TestSelectMethods: """Class for testing data manager select_all() and select() methods.""" @@ -54,10 +54,10 @@ def on_succeed_select_all(self, tree): assert isinstance(tree, Tree) assert isinstance(tree.get_node(3).data["action"], RAMSTKActionRecord) assert isinstance(tree.get_node(4).data["action"], RAMSTKActionRecord) - print("\033[36m\nsucceed_retrieve_action topic was broadcast.") + print("\033[36m\n\tsucceed_retrieve_action topic was broadcast.") @pytest.mark.integration - def test_do_select_all_populated_tree(self, test_tablemodel): + def test_do_select_all_populated_tree(self, test_table_model): """should return a Tree() object populated with RAMSTKActionRecord instances.""" pub.subscribe(self.on_succeed_select_all, "succeed_retrieve_all_action") @@ -72,223 +72,223 @@ def test_do_select_all_populated_tree(self, test_tablemodel): pub.unsubscribe(self.on_succeed_select_all, "succeed_retrieve_all_action") -@pytest.mark.usefixtures("test_attributes", "test_tablemodel") +@pytest.mark.usefixtures("test_attributes", "test_table_model") class TestInsertMethods: """Class for testing the data manager insert() method.""" def on_succeed_insert_sibling(self, tree): assert isinstance(tree, Tree) assert isinstance(tree.get_node(5).data["action"], RAMSTKActionRecord) - print("\033[36m\nsucceed_insert_action topic was broadcast.") + print("\033[36m\n\tsucceed_insert_action topic was broadcast.") - def on_fail_insert_no_parent(self, error_message): - assert error_message == ( + def on_fail_insert_no_parent(self, logger_name, message): + assert logger_name == "DEBUG" + assert message == ( "do_insert: Database error when attempting to add a record. Database " "returned:\n\tKey (fld_cause_id)=(100) is not present in table " '"ramstk_cause".' ) - print("\033[35m\nfail_insert_action topic was broadcast.") + print("\033[35m\n\tfail_insert_action topic was broadcast.") @pytest.mark.integration - def test_do_insert_sibling(self, test_attributes, test_tablemodel): + def test_do_insert_sibling(self, test_attributes, test_table_model): """should add a record to the record tree and update last_id.""" pub.subscribe(self.on_succeed_insert_sibling, "succeed_insert_action") pub.sendMessage("request_insert_action", attributes=test_attributes) - assert test_tablemodel.last_id == 5 + assert test_table_model.last_id == 5 pub.unsubscribe(self.on_succeed_insert_sibling, "succeed_insert_action") @pytest.mark.integration - def test_do_insert_no_parent(self, test_attributes, test_tablemodel): + def test_do_insert_no_parent(self, test_attributes, test_table_model): """should send the fail message if the parent ID does not exist.""" - pub.subscribe(self.on_fail_insert_no_parent, "fail_insert_action") + pub.subscribe(self.on_fail_insert_no_parent, "do_log_debug_msg") test_attributes["cause_id"] = 100 pub.sendMessage("request_insert_action", attributes=test_attributes) - pub.unsubscribe(self.on_fail_insert_no_parent, "fail_insert_action") + pub.unsubscribe(self.on_fail_insert_no_parent, "do_log_debug_msg") -@pytest.mark.usefixtures("test_tablemodel") +@pytest.mark.usefixtures("test_table_model") class TestDeleteMethods: """Class for testing the data manager delete() method.""" def on_succeed_delete(self, tree): assert isinstance(tree, Tree) - print("\033[36m\nsucceed_delete_action topic was broadcast") + print("\033[36m\n\tsucceed_delete_action topic was broadcast") - def on_fail_delete_non_existent_id(self, error_message): - assert error_message == ("Attempted to delete non-existent Action ID 300.") - print("\033[35m\nfail_delete_action topic was broadcast") + def on_fail_delete_non_existent_id(self, logger_name, message): + assert logger_name == "DEBUG" + assert message == ("Attempted to delete non-existent Action ID 300.") + print("\033[35m\n\tfail_delete_action topic was broadcast") - def on_fail_delete_not_in_tree(self, error_message): - assert error_message == ("Attempted to delete non-existent Action ID 4.") - print("\033[35m\nfail_delete_action topic was broadcast") + def on_fail_delete_not_in_tree(self, logger_name, message): + assert logger_name == "DEBUG" + assert message == ("Attempted to delete non-existent Action ID 4.") + print("\033[35m\n\tfail_delete_action topic was broadcast") @pytest.mark.integration - def test_do_delete(self, test_tablemodel): + def test_do_delete(self, test_table_model): """should remove the deleted record from records tree and update last_id.""" pub.subscribe(self.on_succeed_delete, "succeed_delete_action") pub.sendMessage("request_delete_action", node_id=3) - assert test_tablemodel.last_id == 4 + assert test_table_model.last_id == 4 pub.unsubscribe(self.on_succeed_delete, "succeed_delete_action") @pytest.mark.integration def test_do_delete_non_existent_id(self): """should send the fail message when node ID doesn't exist in the tree.""" - pub.subscribe(self.on_fail_delete_non_existent_id, "fail_delete_action") + pub.subscribe(self.on_fail_delete_non_existent_id, "do_log_debug_msg") pub.sendMessage("request_delete_action", node_id=300) - pub.unsubscribe(self.on_fail_delete_non_existent_id, "fail_delete_action") + pub.unsubscribe(self.on_fail_delete_non_existent_id, "do_log_debug_msg") @pytest.mark.integration - def test_do_delete_not_in_tree(self, test_tablemodel): + def test_do_delete_not_in_tree(self, test_table_model): """should send the fail message when node doesn't exist in the tree.""" - pub.subscribe(self.on_fail_delete_not_in_tree, "fail_delete_action") + pub.subscribe(self.on_fail_delete_not_in_tree, "do_log_debug_msg") - test_tablemodel.tree.remove_node(4) + test_table_model.tree.remove_node(4) pub.sendMessage("request_delete_action", node_id=4) - pub.unsubscribe(self.on_fail_delete_not_in_tree, "fail_delete_action") + pub.unsubscribe(self.on_fail_delete_not_in_tree, "do_log_debug_msg") -@pytest.mark.usefixtures("test_tablemodel") +@pytest.mark.usefixtures("test_table_model") class TestUpdateMethods: """Class for testing update() and update_all() methods.""" def on_succeed_update(self, tree): assert isinstance(tree, Tree) - assert tree.get_node(3).data["action"].action_recommended == ("Get a clue.") + assert tree.get_node(3).data["action"].description == ("Get a clue.") assert tree.get_node(3).data["action"].action_closed == 1 - print("\033[36m\nsucceed_update_action topic was broadcast") + print("\033[36m\n\tsucceed_update_action topic was broadcast") def on_succeed_update_all(self): print( - "\033[36m\nsucceed_update_all topic was broadcast when updating all " + "\033[36m\n\tsucceed_update_all topic was broadcast when updating all " "Actions" ) - def on_fail_update_wrong_data_type(self, error_message): - assert error_message == ( - "do_update: The value for one or more attributes for action ID 3 was " - "the wrong type." + def on_fail_update_wrong_data_type(self, logger_name, message): + assert logger_name == "DEBUG" + assert message == ( + "The value for one or more attributes for action ID 3 was the wrong type." ) - print("\033[35m\nfail_update_action topic was broadcast on wrong data type.") + print("\033[35m\n\tfail_update_action topic was broadcast on wrong data type.") - def on_fail_update_root_node_wrong_data_type(self, error_message): - assert error_message == ("do_update: Attempting to update the root node 0.") - print("\033[35m\nfail_update_action topic was broadcast on root node.") + def on_fail_update_root_node_wrong_data_type(self, logger_name, message): + assert logger_name == "DEBUG" + assert message == ("Attempting to update the root node 0.") + print("\033[35m\n\tfail_update_action topic was broadcast on root node.") - def on_fail_update_non_existent_id(self, error_message): - assert error_message == ( - "do_update: Attempted to save non-existent action with action ID 100." - ) - print("\033[35m\nfail_update_action topic was broadcast on non-existent ID.") + def on_fail_update_non_existent_id(self, logger_name, message): + assert logger_name == "DEBUG" + assert message == ("Attempted to save non-existent action with action ID 100.") + print("\033[35m\n\tfail_update_action topic was broadcast on non-existent ID.") - def on_fail_update_no_data_package(self, error_message): - assert error_message == ("do_update: No data package found for action ID 3.") - print("\033[35m\nfail_update_action topic was broadcast on no data package.") + def on_fail_update_no_data_package(self, logger_name, message): + assert logger_name == "DEBUG" + assert message == ("No data package found for action ID 3.") + print("\033[35m\n\tfail_update_action topic was broadcast on no data package.") @pytest.mark.integration - def test_do_update(self, test_tablemodel): + def test_do_update(self, test_table_model): """should update record in database and records tree.""" pub.subscribe(self.on_succeed_update, "succeed_update_action") - test_tablemodel.tree.get_node(3).data[ - "action" - ].action_recommended = "Get a clue." - test_tablemodel.tree.get_node(3).data["action"].action_closed = 1 + test_table_model.tree.get_node(3).data["action"].description = "Get a clue." + test_table_model.tree.get_node(3).data["action"].action_closed = 1 pub.sendMessage("request_update_action", node_id=3) assert ( - test_tablemodel.tree.get_node(3).data["action"].action_recommended + test_table_model.tree.get_node(3).data["action"].description == "Get a clue." ) - assert test_tablemodel.tree.get_node(3).data["action"].action_closed == 1 + assert test_table_model.tree.get_node(3).data["action"].action_closed == 1 pub.unsubscribe(self.on_succeed_update, "succeed_update_action") @pytest.mark.integration - def test_do_update_all(self, test_tablemodel): + def test_do_update_all(self, test_table_model): """should update all records in database and records tree.""" pub.subscribe(self.on_succeed_update_all, "succeed_update_all_action") - test_tablemodel.tree.get_node(3).data[ + test_table_model.tree.get_node(3).data[ "action" ].description = "Test failure action" - test_tablemodel.tree.get_node(3).data["action"].rpn_detection = 2 - test_tablemodel.tree.get_node(4).data[ + test_table_model.tree.get_node(3).data["action"].rpn_detection = 2 + test_table_model.tree.get_node(4).data[ "action" ].description = "Big test failure action" - test_tablemodel.tree.get_node(4).data["action"].rpn_detection = 7 + test_table_model.tree.get_node(4).data["action"].rpn_detection = 7 pub.sendMessage("request_update_all_action") assert ( - test_tablemodel.tree.get_node(3).data["action"].description + test_table_model.tree.get_node(3).data["action"].description == "Test failure action" ) - assert test_tablemodel.tree.get_node(3).data["action"].rpn_detection == 2 + assert test_table_model.tree.get_node(3).data["action"].rpn_detection == 2 assert ( - test_tablemodel.tree.get_node(4).data["action"].description + test_table_model.tree.get_node(4).data["action"].description == "Big test failure action" ) - assert test_tablemodel.tree.get_node(4).data["action"].rpn_detection == 7 + assert test_table_model.tree.get_node(4).data["action"].rpn_detection == 7 pub.unsubscribe(self.on_succeed_update_all, "succeed_update_all_action") @pytest.mark.integration - def test_do_update_wrong_data_type(self, test_tablemodel): + def test_do_update_wrong_data_type(self, test_table_model): """should send fail message if attribute has wrong data type.""" - pub.subscribe(self.on_fail_update_wrong_data_type, "fail_update_action") + pub.subscribe(self.on_fail_update_wrong_data_type, "do_log_debug_msg") - _action = test_tablemodel.do_select(3) + _action = test_table_model.do_select(3) _action.action_approved = {1: 2} pub.sendMessage("request_update_action", node_id=3) - pub.unsubscribe(self.on_fail_update_wrong_data_type, "fail_update_action") + pub.unsubscribe(self.on_fail_update_wrong_data_type, "do_log_debug_msg") @pytest.mark.integration - def test_do_update_root_node_wrong_data_type(self, test_tablemodel): + def test_do_update_root_node_wrong_data_type(self, test_table_model): """should send fail message when attempting to update root node.""" - pub.subscribe( - self.on_fail_update_root_node_wrong_data_type, "fail_update_action" - ) + pub.subscribe(self.on_fail_update_root_node_wrong_data_type, "do_log_debug_msg") - _action = test_tablemodel.do_select(4) + _action = test_table_model.do_select(4) _action.action_closed = {1: 2} pub.sendMessage("request_update_action", node_id=0) pub.unsubscribe( - self.on_fail_update_root_node_wrong_data_type, "fail_update_action" + self.on_fail_update_root_node_wrong_data_type, "do_log_debug_msg" ) @pytest.mark.integration def test_do_update_non_existent_id(self): """should send fail message when node ID does not exist.""" - pub.subscribe(self.on_fail_update_non_existent_id, "fail_update_action") + pub.subscribe(self.on_fail_update_non_existent_id, "do_log_debug_msg") pub.sendMessage("request_update_action", node_id=100) - pub.unsubscribe(self.on_fail_update_non_existent_id, "fail_update_action") + pub.unsubscribe(self.on_fail_update_non_existent_id, "do_log_debug_msg") @pytest.mark.integration - def test_do_update_no_data_package(self, test_tablemodel): + def test_do_update_no_data_package(self, test_table_model): """should send fail message when node ID has no data package.""" - pub.subscribe(self.on_fail_update_no_data_package, "fail_update_action") + pub.subscribe(self.on_fail_update_no_data_package, "do_log_debug_msg") - test_tablemodel.tree.get_node(3).data.pop("action") + test_table_model.tree.get_node(3).data.pop("action") pub.sendMessage("request_update_action", node_id=3) - pub.unsubscribe(self.on_fail_update_no_data_package, "fail_update_action") + pub.unsubscribe(self.on_fail_update_no_data_package, "do_log_debug_msg") -@pytest.mark.usefixtures("test_tablemodel") +@pytest.mark.usefixtures("test_table_model") class TestGetterSetter: """Class for testing methods that get or set.""" @@ -296,16 +296,16 @@ def on_succeed_get_attributes(self, attributes): assert isinstance(attributes, dict) assert attributes["action_id"] == 3 assert ( - attributes["action_recommended"] + attributes["description"] == "Test FMEA Recommended Action #1 for Cause ID 3" ) - print("\033[36m\nsucceed_get_action_attributes topic was broadcast.") + print("\033[36m\n\tsucceed_get_action_attributes topic was broadcast.") def on_succeed_get_data_manager_tree(self, tree): assert isinstance(tree, Tree) assert isinstance(tree.get_node(3).data["action"], RAMSTKActionRecord) assert isinstance(tree.get_node(4).data["action"], RAMSTKActionRecord) - print("\033[36m\nsucceed_get_action_tree topic was broadcast") + print("\033[36m\n\tsucceed_get_action_tree topic was broadcast") def on_succeed_set_attributes(self, tree): assert isinstance(tree, Tree) @@ -313,17 +313,17 @@ def on_succeed_set_attributes(self, tree): tree.get_node(4).data["action"].action_owner == "John Jacob Jingleheimer Schmidt" ) - print("\033[36m\nsucceed_get_action_tree topic was broadcast") + print("\033[36m\n\tsucceed_get_action_tree topic was broadcast") @pytest.mark.integration - def test_do_get_attributes(self, test_tablemodel): + def test_do_get_attributes(self, test_table_model): """should return a dict of attribute key:value pairs.""" pub.subscribe(self.on_succeed_get_attributes, "succeed_get_action_attributes") - test_tablemodel.do_get_attributes(node_id=3) + test_table_model.do_get_attributes(node_id=3) assert ( - test_tablemodel.tree.get_node(3).data["action"].action_recommended + test_table_model.tree.get_node(3).data["action"].description == "Test FMEA Recommended Action #1 for Cause ID 3" ) @@ -341,7 +341,7 @@ def test_on_get_tree_data_manager(self): ) @pytest.mark.integration - def test_do_set_attributes(self, test_tablemodel): + def test_do_set_attributes(self, test_table_model): """should set the value of the requested attribute.""" pub.subscribe(self.on_succeed_set_attributes, "succeed_get_action_tree") @@ -352,7 +352,7 @@ def test_do_set_attributes(self, test_tablemodel): ) assert ( - test_tablemodel.do_select(4).action_owner + test_table_model.do_select(4).action_owner == "John Jacob Jingleheimer Schmidt" ) diff --git a/tests/models/programdb/action/action_unit_test.py b/tests/models/programdb/action/action_unit_test.py index d8b668b83..36b42ab7e 100644 --- a/tests/models/programdb/action/action_unit_test.py +++ b/tests/models/programdb/action/action_unit_test.py @@ -26,7 +26,7 @@ @pytest.fixture(scope="function") -def test_tablemodel(mock_program_dao): +def test_table_model(mock_program_dao): """Get a data manager instance for each test function.""" # Create the device under test (dut) and connect to the database. dut = RAMSTKActionTable() @@ -47,7 +47,7 @@ def test_tablemodel(mock_program_dao): del dut -@pytest.mark.usefixtures("test_recordmodel", "test_tablemodel") +@pytest.mark.usefixtures("test_recordmodel", "test_table_model") class TestCreateModels: """Class for model initialization test suite.""" @@ -58,10 +58,7 @@ def test_record_model_create(self, test_recordmodel): # Verify class attributes are properly initialized. assert test_recordmodel.__tablename__ == "ramstk_action" - assert ( - test_recordmodel.action_recommended - == "Test FMEA Action #1 for Cause ID #3." - ) + assert test_recordmodel.description == "Test FMEA Action #1 for Cause ID #3." assert test_recordmodel.action_category == "Detection" assert test_recordmodel.action_owner == "" assert test_recordmodel.action_due_date == date.today() + timedelta(days=30) @@ -73,104 +70,106 @@ def test_record_model_create(self, test_recordmodel): assert test_recordmodel.action_close_date == date.today() + timedelta(days=30) @pytest.mark.unit - def test_data_manager_create(self, test_tablemodel): + def test_data_manager_create(self, test_table_model): """__init__() should return a PoF data manager.""" - assert isinstance(test_tablemodel, RAMSTKActionTable) - assert isinstance(test_tablemodel.tree, Tree) - assert isinstance(test_tablemodel.dao, MockDAO) - assert test_tablemodel._db_id_colname == "fld_action_id" - assert test_tablemodel._db_tablename == "ramstk_action" - assert test_tablemodel._tag == "action" - assert test_tablemodel._root == 0 - assert test_tablemodel._revision_id == 0 - assert test_tablemodel._parent_id == 0 - assert test_tablemodel.last_id == 0 - assert pub.isSubscribed(test_tablemodel.do_select_all, "selected_revision") + assert isinstance(test_table_model, RAMSTKActionTable) + assert isinstance(test_table_model.tree, Tree) + assert isinstance(test_table_model.dao, MockDAO) + assert test_table_model._db_id_colname == "fld_action_id" + assert test_table_model._db_tablename == "ramstk_action" + assert test_table_model._tag == "action" + assert test_table_model._root == 0 + assert test_table_model._revision_id == 0 + assert test_table_model._parent_id == 0 + assert test_table_model.last_id == 0 + assert pub.isSubscribed(test_table_model.do_select_all, "selected_revision") + assert pub.isSubscribed( + test_table_model.do_get_attributes, "request_get_action_attributes" + ) assert pub.isSubscribed( - test_tablemodel.do_get_attributes, "request_get_action_attributes" + test_table_model.do_set_attributes, "request_set_action_attributes" ) assert pub.isSubscribed( - test_tablemodel.do_set_attributes, "request_set_action_attributes" + test_table_model.do_set_attributes, "wvw_editing_action" ) - assert pub.isSubscribed(test_tablemodel.do_set_attributes, "wvw_editing_action") - assert pub.isSubscribed(test_tablemodel.do_update, "request_update_action") - assert pub.isSubscribed(test_tablemodel.do_get_tree, "request_get_action_tree") - assert pub.isSubscribed(test_tablemodel.do_delete, "request_delete_action") - assert pub.isSubscribed(test_tablemodel.do_insert, "request_insert_action") + assert pub.isSubscribed(test_table_model.do_update, "request_update_action") + assert pub.isSubscribed(test_table_model.do_get_tree, "request_get_action_tree") + assert pub.isSubscribed(test_table_model.do_delete, "request_delete_action") + assert pub.isSubscribed(test_table_model.do_insert, "request_insert_action") -@pytest.mark.usefixtures("test_tablemodel") +@pytest.mark.usefixtures("test_table_model") class TestSelectMethods: """Class for testing data manager select_all() and select() methods.""" @pytest.mark.unit - def test_do_select_all(self, test_tablemodel): + def test_do_select_all(self, test_table_model): """should return a Tree() object populated with RAMSTKActionRecord instances.""" - test_tablemodel.do_select_all( + test_table_model.do_select_all( { "revision_id": 1, } ) assert isinstance( - test_tablemodel.tree.get_node(1).data["action"], RAMSTKActionRecord + test_table_model.tree.get_node(1).data["action"], RAMSTKActionRecord ) assert isinstance( - test_tablemodel.tree.get_node(2).data["action"], RAMSTKActionRecord + test_table_model.tree.get_node(2).data["action"], RAMSTKActionRecord ) @pytest.mark.unit - def test_do_select(self, test_tablemodel): + def test_do_select(self, test_table_model): """should return an instance of the RAMSTKActionRecord on success.""" - test_tablemodel.do_select_all( + test_table_model.do_select_all( { "revision_id": 1, } ) - _action = test_tablemodel.do_select(1) + _action = test_table_model.do_select(1) assert isinstance(_action, RAMSTKActionRecord) - assert _action.action_recommended == "Test FMEA Action #1 for Cause ID #3." + assert _action.description == "Test FMEA Action #1 for Cause ID #3." assert _action.action_category == "Detection" @pytest.mark.unit - def test_do_select_non_existent_id(self, test_tablemodel): + def test_do_select_non_existent_id(self, test_table_model): """should return None when a non-existent action ID is requested.""" - test_tablemodel.do_select_all( + test_table_model.do_select_all( { "revision_id": 1, } ) - assert test_tablemodel.do_select(100) is None + assert test_table_model.do_select(100) is None -@pytest.mark.usefixtures("test_attributes", "test_tablemodel") +@pytest.mark.usefixtures("test_attributes", "test_table_model") class TestInsertMethods: """Class for testing the data manager insert() method.""" @pytest.mark.unit - def test_do_insert_sibling(self, test_attributes, test_tablemodel): + def test_do_insert_sibling(self, test_attributes, test_table_model): """should add a record to the record tree and update last_id.""" - test_tablemodel.do_select_all(test_attributes) - test_tablemodel.do_insert(test_attributes) + test_table_model.do_select_all(test_attributes) + test_table_model.do_insert(test_attributes) - assert test_tablemodel.last_id == 3 + assert test_table_model.last_id == 3 assert isinstance( - test_tablemodel.tree.get_node(3).data["action"], RAMSTKActionRecord + test_table_model.tree.get_node(3).data["action"], RAMSTKActionRecord ) -@pytest.mark.usefixtures("test_tablemodel") +@pytest.mark.usefixtures("test_table_model") class TestDeleteMethods: """Class for testing the data manager delete() method.""" @pytest.mark.unit - def test_do_delete(self, test_tablemodel): + def test_do_delete(self, test_table_model): """should remove the record from the record tree and update last_id.""" - test_tablemodel.do_select_all( + test_table_model.do_select_all( { "revision_id": 1, "hardware_id": 1, @@ -179,10 +178,10 @@ def test_do_delete(self, test_tablemodel): "cause_id": 3, } ) - test_tablemodel.do_delete(2) + test_table_model.do_delete(2) - assert test_tablemodel.last_id == 1 - assert test_tablemodel.tree.get_node(2) is None + assert test_table_model.last_id == 1 + assert test_table_model.tree.get_node(2) is None @pytest.mark.usefixtures("test_attributes", "test_recordmodel") @@ -195,9 +194,7 @@ def test_get_record_model_attributes(self, test_recordmodel): _attributes = test_recordmodel.get_attributes() assert isinstance(_attributes, dict) - assert ( - _attributes["action_recommended"] == "Test FMEA Action #1 for Cause ID #3." - ) + assert _attributes["description"] == "Test FMEA Action #1 for Cause ID #3." assert _attributes["action_taken"] == "" @pytest.mark.unit diff --git a/tests/models/programdb/action/conftest.py b/tests/models/programdb/action/conftest.py index 0d415d337..e8a0eb7f3 100644 --- a/tests/models/programdb/action/conftest.py +++ b/tests/models/programdb/action/conftest.py @@ -18,7 +18,7 @@ def mock_program_dao(monkeypatch): _action_1.mechanism_id = 3 _action_1.cause_id = 3 _action_1.action_id = 1 - _action_1.action_recommended = "Test FMEA Action #1 for Cause ID #3." + _action_1.description = "Test FMEA Action #1 for Cause ID #3." _action_1.action_category = "Detection" _action_1.action_owner = "" _action_1.action_due_date = date.today() + timedelta(days=30) @@ -36,7 +36,7 @@ def mock_program_dao(monkeypatch): _action_2.mechanism_id = 3 _action_2.cause_id = 3 _action_2.action_id = 2 - _action_2.action_recommended = "Test FMEA Action #2 for Cause ID #3." + _action_2.description = "Test FMEA Action #2 for Cause ID #3." _action_2.action_category = "Detection" _action_2.action_owner = "" _action_2.action_due_date = date.today() + timedelta(days=23) @@ -65,7 +65,7 @@ def test_attributes(): "mechanism_id": 3, "cause_id": 3, "action_id": 1, - "action_recommended": "Test FMEA Action #1 for Cause ID #3.", + "description": "Test FMEA Action #1 for Cause ID #3.", "action_category": "", "action_owner": "weibullguy", "action_due_date": date.today(),