Skip to content

Commit

Permalink
Fix part of oppia#6550: Raise code coverage of core.storage.question.…
Browse files Browse the repository at this point in the history
…gae_models to 100% (oppia#6558)
  • Loading branch information
shutas authored and DubeySandeep committed Apr 14, 2019
1 parent a1c7181 commit bb4e6b7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions core/storage/question/gae_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Tests for core.storage.question.gae_models."""

import datetime
import types

from core.domain import state_domain
from core.platform import models
Expand All @@ -39,6 +40,26 @@ def test_create_question(self):
self.assertEqual(question_model.language_code, language_code)


def test_raise_exception_by_mocking_collision(self):
state = state_domain.State.create_default_state('ABC')
question_state_data = state.to_dict()
language_code = 'en'
version = 1

with self.assertRaisesRegexp(
Exception, 'The id generator for QuestionModel is producing too '
'many collisions.'
):
# Swap dependent method get_by_id to simulate collision every time.
with self.swap(
question_models.QuestionModel, 'get_by_id',
types.MethodType(
lambda x, y: True,
question_models.QuestionModel)):
question_models.QuestionModel.create(
question_state_data, language_code, version)


class QuestionSummaryModelUnitTests(test_utils.GenericTestBase):
"""Tests the QuestionSummaryModel class."""

Expand Down

0 comments on commit bb4e6b7

Please sign in to comment.