def test_get_problem_progress(self, **test_data): # pylint: disable=protected-access """ Tests _get_problem_progress Score can be 0, 0.5, or 1 Return a message for current problem progress """ self.xblock.weight = test_data['weight'] self.xblock.score = test_data['score'] self.assertEqual( _(test_data['result']), self.xblock._get_problem_progress(), )
def test_used_attempts_feedback_normal(self, max_attempts, count_attempts, result): # pylint: disable=invalid-name, protected-access """ Tests get_used_attempts_feedback Returns the used attempts feedback message after a student response """ self.xblock.max_attempts = max_attempts self.xblock.count_attempts = count_attempts self.assertEqual( _(result), self.xblock._get_used_attempts_feedback(), )
def test_get_submitted_message(self, word_count_valid, result): # pylint: disable=protected-access """ Tests _get_submitted_message Returns a message to display to the user after they submit a resopnse """ self.xblock._word_count_valid = MagicMock( return_value=word_count_valid) self.xblock.submitted_message = 'test submission received message' self.assertEqual( _(result), self.xblock._get_submitted_message(), )
def test_generate_validation_message(self): # pylint: disable=invalid-name, protected-access """ Checks classmethod _generate_validation_message """ msg = 'weight attempts cannot be negative' result = ValidationMessage(ValidationMessage.ERROR, _(msg)) test_result = self.xblock._generate_validation_message(msg) self.assertEqual( type(result), type(test_result), ) self.assertEqual( result.text, test_result.text, )
def test_get_user_alert(self, **test_data): # pylint: disable=protected-access """ Tests _get_user_alert if the word count is invalid this will return the invalid word count message """ self.xblock._word_count_valid = MagicMock( return_value=test_data['word_count_valid']) self.xblock.count_attempts = test_data['count_attempts'] self.xblock.min_word_count = test_data['min_word_count'] self.xblock.max_word_count = test_data['max_word_count'] self.assertEqual( _(str(test_data['result'])), self.xblock._get_user_alert( ignore_attempts=test_data['ignore_attempts']), )
def test_get_word_count_message( self, min_word_count, max_word_count, result, ): # pylint: disable=protected-access """ Tests _get_word_count_message Returns the word count message based on instructor set word count min and max """ self.xblock.min_word_count = min_word_count self.xblock.max_word_count = max_word_count self.assertEqual( _(result), self.xblock._get_word_count_message(), )