def test_delete_story(self): topic_services.delete_story(self.user_id_admin, self.TOPIC_ID, self.story_id_1) topic = topic_services.get_topic_by_id(self.TOPIC_ID) self.assertEqual(topic.canonical_story_ids, [self.story_id_2]) topic_commit_log_entry = ( topic_models.TopicCommitLogEntryModel.get_commit(self.TOPIC_ID, 3)) self.assertEqual(topic_commit_log_entry.commit_type, 'edit') self.assertEqual(topic_commit_log_entry.topic_id, self.TOPIC_ID) self.assertEqual(topic_commit_log_entry.user_id, self.user_id_admin) self.assertEqual( topic_commit_log_entry.commit_message, 'Removed %s from canonical story ids' % self.story_id_1)
def delete(self, topic_id, story_id): """Handles Delete requests.""" if not feconf.ENABLE_NEW_STRUCTURES: raise self.PageNotFoundException story_domain.Story.require_valid_story_id(story_id) topic_domain.Topic.require_valid_topic_id(topic_id) story = story_services.get_story_by_id(story_id, strict=False) if story is None: raise self.PageNotFoundException topic = topic_services.get_topic_by_id(topic_id, strict=False) if topic is None or story_id not in topic.canonical_story_ids: raise self.PageNotFoundException topic = topic_services.get_topic_by_id(topic_id, strict=False) if topic is None: raise self.PageNotFoundException( Exception('The topic with the given id doesn\'t exist.')) story_services.delete_story(self.user_id, story_id) topic_services.delete_story(self.user_id, topic_id, story_id)