From 0697dc314471a2bde90d52b1726914c85a360470 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 16 Feb 2021 16:13:24 +0530 Subject: Change travis and tests - Add celery run and stop worker command in travis - Fix failing tests --- .travis.yml | 3 +++ yaksh/evaluator_tests/test_simple_question_types.py | 10 +--------- yaksh/test_models.py | 17 +++++++++-------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0fad559..27b6dfe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,11 +29,14 @@ before_script: # command to run tests and coverage script: - coverage erase + - celery multi start 1 -A online_test worker -B - coverage run -p manage.py test -v 2 yaksh - coverage run -p manage.py test -v 2 stats - coverage run -p manage.py test -v 2 grades - coverage run -p manage.py test -v 2 yaksh.live_server_tests.load_test - coverage run -p manage.py test -v 2 api + - celery multi stop 1 + - find . -type f -name "*.pid" -exec rm -f {} \; after_success: - coverage combine diff --git a/yaksh/evaluator_tests/test_simple_question_types.py b/yaksh/evaluator_tests/test_simple_question_types.py index 5edd545..13d639e 100644 --- a/yaksh/evaluator_tests/test_simple_question_types.py +++ b/yaksh/evaluator_tests/test_simple_question_types.py @@ -662,16 +662,8 @@ class ArrangeQuestionTestCases(unittest.TestCase): regrade_answer.answer = 1 regrade_answer.save() details = self.answerpaper.regrade(self.question1.id) - err_msg = dedent("""\ - User: {0}; Quiz: {1}; Question: {2}. - {3} answer not a list.""".format( - self.user.username, - self.quiz.description, - self.question1.summary, - self.question1.type - )) self.assertFalse(details[0]) - self.assertEqual(details[1], err_msg) + self.assertIn("arrange answer not a list", details[1]) # Try regrade with incorrect answer # When diff --git a/yaksh/test_models.py b/yaksh/test_models.py index a424b36..9e0997d 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -284,8 +284,9 @@ class LearningModuleTestCases(unittest.TestCase): self.learning_module_two = LearningModule.objects.get(name='LM2') self.creator = User.objects.get(username='creator') self.student = User.objects.get(username='course_user') - self.learning_unit_one = LearningUnit.objects.get(id=1) - self.learning_unit_two = LearningUnit.objects.get(id=2) + learning_units = self.learning_module.learning_unit.order_by("order") + self.learning_unit_one = learning_units[0] + self.learning_unit_two = learning_units[1] self.quiz = Quiz.objects.get(description='demo quiz 1') self.lesson = Lesson.objects.get(name='L1') self.course = Course.objects.get(name='Python Course') @@ -1420,10 +1421,10 @@ class AnswerPaperTestCases(unittest.TestCase): expected_score = {"Q4": 1.0} # When score = self.answerpaper_single_question.get_per_question_score( - [(question_name, question_id)] + [(question_name, question_id, f"{question_id}-comments")] ) # Then - self.assertEqual(score, expected_score) + self.assertEqual(score['Q4'], expected_score['Q4']) # Given question_id = self.question2.id @@ -1431,10 +1432,10 @@ class AnswerPaperTestCases(unittest.TestCase): expected_score = {"Q2": 0.0} # When score = self.answerpaper.get_per_question_score( - [(question_name, question_id)] + [(question_name, question_id, f"{question_id}-comments")] ) # Then - self.assertEqual(score, expected_score) + self.assertEqual(score["Q2"], expected_score["Q2"]) # Given question_id = 131 @@ -1442,10 +1443,10 @@ class AnswerPaperTestCases(unittest.TestCase): expected_score = {'NA': 0} # When score = self.answerpaper.get_per_question_score( - [(question_name, question_id)] + [(question_name, question_id, f"{question_id}-comments")] ) # Then - self.assertEqual(score, expected_score) + self.assertEqual(score["NA"], expected_score["NA"]) def test_returned_question_is_not_none(self): # Test add_completed_question and next_question -- cgit