def test_get_story_by_url_fragment(self): story = story_fetchers.get_story_by_url_fragment( url_fragment='story-one') self.assertEqual(story.id, self.STORY_ID) self.assertEqual(story.url_fragment, 'story-one') story = story_fetchers.get_story_by_url_fragment( url_fragment='fake-story') self.assertEqual(story, None)
def test_get_story_by_url_fragment(self) -> None: story = story_fetchers.get_story_by_url_fragment( url_fragment='story-one') # Ruling out the possibility of None for mypy type checking. assert story is not None self.assertEqual(story.id, self.story_id) self.assertEqual(story.url_fragment, 'story-one') story = story_fetchers.get_story_by_url_fragment( url_fragment='fake-story') self.assertEqual(story, None)
def does_story_exist_with_url_fragment(url_fragment): """Checks if the url fragment for the story exists. Args: url_fragment: str. The url_fragment of the story. Returns: bool. Whether the the url fragment for the story exists or not. """ story = story_fetchers.get_story_by_url_fragment(url_fragment) return story is not None
def test_initialize_structure_thumbnails_exist(self): # To validate the thumbnails for topics ans stories can be fetched # using AssetsDevHandler. self.post_json('/initialize_android_test_data', {}, use_payload=False, csrf_token=None) topic = topic_fetchers.get_topic_by_name('Android test') story = story_fetchers.get_story_by_url_fragment( 'android-end-to-end-testing') self.get_custom_response( '/assetsdevhandler/topic/%s/assets/thumbnail/test_svg.svg' % topic.id, 'image/svg+xml') self.get_custom_response( '/assetsdevhandler/story/%s/assets/thumbnail/test_svg.svg' % story.id, 'image/svg+xml')
def get(self, exploration_id): """Handles GET request.""" story_url_fragment = self.request.get('story_url_fragment') story = story_fetchers.get_story_by_url_fragment(story_url_fragment) if story is None: raise self.InvalidInputException if not story.has_exploration(exploration_id): raise self.InvalidInputException pretest_questions = (question_services.get_questions_by_skill_ids( feconf.NUM_PRETEST_QUESTIONS, story.get_prerequisite_skill_ids_for_exp_id(exploration_id), True)) question_dicts = [question.to_dict() for question in pretest_questions] self.values.update({ 'pretest_question_dicts': question_dicts, }) self.render_json(self.values)
def test_initialize_structures_are_valid(self): self.post_json('/initialize_android_test_data', {}, use_payload=False, csrf_token=None) exp_id = '26' topic = topic_fetchers.get_topic_by_name('Android test') exploration = exp_fetchers.get_exploration_by_id(exp_id) story = story_fetchers.get_story_by_url_fragment( 'android-end-to-end-testing') skill = skill_fetchers.get_skill_by_description( 'Dummy Skill for Android') skill.validate() story.validate() topic.validate(strict=True) exploration.validate(strict=True) for node in story.story_contents.nodes: self.assertEqual(node.exploration_id, exp_id)