def test_get_undo_recipe(self): # Test Action action_steps = AddCausalRelationship.get_undo_recipe(self.action_spec) # Test Assertions # expecting for one step: remove edge self.assertEqual(1, len(action_steps)) self.assertEqual(REMOVE_EDGE, action_steps[0].type) add_edge_step_params = action_steps[0].params self.assertEqual(3, len(add_edge_step_params)) source = add_edge_step_params.get(TField.SOURCE) self.assertEqual(self.source_vertex_id, source) target = add_edge_step_params.get(TField.TARGET) self.assertEqual(self.target_vertex_id, target) relation_name = add_edge_step_params[EdgeProperties.RELATIONSHIP_TYPE] self.assertEqual(EdgeLabels.CAUSES, relation_name)
def test_get_undo_recipe(self): # Test Action action_steps = AddCausalRelationship.get_undo_recipe(self.action_spec) # Test Assertions # expecting for one step: remove edge self.assertEqual(1, len(action_steps)) self.assertEqual(REMOVE_EDGE, action_steps[0].type) add_edge_step_params = action_steps[0].params self.assertEqual(3, len(add_edge_step_params)) source = add_edge_step_params.get(TField.SOURCE) self.assertEqual(self.source_vertex.vertex_id, source) target = add_edge_step_params.get(TField.TARGET) self.assertEqual(self.target_vertex.vertex_id, target) relation_name = add_edge_step_params[EdgeProperties.RELATIONSHIP_TYPE] self.assertEqual(EdgeLabel.CAUSES, relation_name)
def test_get_do_recipe(self): # Test Action action_steps = AddCausalRelationship.get_do_recipe(self.action_spec) # Test Assertions # expecting for one step: add edge self.assertThat(action_steps, matchers.HasLength(1)) self.assertEqual(ADD_EDGE, action_steps[0].type) add_edge_step_params = action_steps[0].params self.assertThat(add_edge_step_params, matchers.HasLength(3)) source = add_edge_step_params.get(TField.SOURCE) self.assertEqual(self.source_vertex.vertex_id, source) target = add_edge_step_params.get(TField.TARGET) self.assertEqual(self.target_vertex.vertex_id, target) relation_name = add_edge_step_params[EdgeProperties.RELATIONSHIP_TYPE] self.assertEqual(EdgeLabel.CAUSES, relation_name)