def test_get_original_resource_valid_options(self, mock_entity_get): """Assert that the get_original_resource method behaves as expected when receiving valid values. """ n = NotificationHook() # Mock entity_get method to return a sample Task sample_task = Task(id=1, creator_id=1, title='Test', status='inprogress', story_id=1, project_id=1, assignee_id=1, priority='medium') mock_entity_get.return_value = sample_task sample_task_wmodel = TaskWmodel.from_db_model(sample_task) old_entity_values = n.get_original_resource('task', 1) self.assertEqual(old_entity_values['id'], sample_task_wmodel.id) self.assertEqual(old_entity_values['creator_id'], sample_task_wmodel.creator_id) self.assertEqual(old_entity_values['title'], sample_task_wmodel.title) self.assertEqual(old_entity_values['status'], sample_task_wmodel.status) self.assertEqual(old_entity_values['story_id'], sample_task_wmodel.story_id) self.assertEqual(old_entity_values['project_id'], sample_task_wmodel.project_id) self.assertEqual(old_entity_values['assignee_id'], sample_task_wmodel.assignee_id) self.assertEqual(old_entity_values['priority'], sample_task_wmodel.priority)
def test_get_original_resource_invalid_options(self): """Assert that the get_original_resource method behaves as expected when receiving invalid values. """ n = NotificationHook() # Test no resource self.assertIsNone(n.get_original_resource(None, None)) # Test invalid resource. self.assertIsNone(n.get_original_resource('invalid', 1)) # Test no resource_id self.assertIsNone(n.get_original_resource('story', None)) # Test invalid (gone) resource_id. self.assertIsNone(n.get_original_resource('story', 1000000))