Example #1
0
    def test_survey_retrieved(self):
        end_session_create_survey_instance(self.request)

        self.assertEqual(1, len(SurveyInstance.objects.filter(survey=self.new_survey)))
        survey_instance = SurveyInstance.objects.get(survey=self.new_survey)

        self.assertEqual(1, len(SurveyQuestionInstance.objects.filter(survey_instance=survey_instance)))
        self.assertEqual(1, len(SurveyPositionInstance.objects.filter(survey_instance=survey_instance)))
Example #2
0
    def test_bad_class_lookup(self):
        mock_request = rf.post('/api/survey/generate?session_id=' + str(self.session_id), {
            'class': 1111
        })
        response = end_session_create_survey_instance(mock_request)

        self.assertTrue('"error_id": 506' in response.content.decode('utf-8'))
Example #3
0
    def test_no_logged_in_user(self):
        mock_request = rf.post('/api/survey/generate', {
            'class': str(self.new_class.id)
        })
        response = end_session_create_survey_instance(mock_request)

        self.assertTrue('"error_id": 500' in response.content.decode('utf-8'))
Example #4
0
    def test_wrong_request_type(self):
        mock_request = rf.get('/api/survey/generate?session_id=' + str(self.session_id), {
            'class': str(self.new_class.id)
        })
        response = end_session_create_survey_instance(mock_request)

        self.assertTrue('"error_id": 501' in response.content.decode('utf-8'))
    def test_survey_instance_already_exists(self):
        new_survey = SurveyInstance.objects.create(
            survey=self.new_survey,
            student=self.new_student,
            date_generated=timezone.now().date())
        new_survey.save()
        response = end_session_create_survey_instance(self.request)

        print(response.content.decode('utf-8'))

        self.assertTrue('"error_id": 510' in response.content.decode('utf-8'))
Example #6
0
    def test_not_enough_POST_data(self):
        mock_request = rf.post('/api/survey/generate?session_id=' + str(self.session_id), {})
        response = end_session_create_survey_instance(mock_request)

        self.assertTrue('"error_id": 503' in response.content.decode('utf-8'))
Example #7
0
    def test_success_status(self):
        response = end_session_create_survey_instance(self.request)

        self.assertTrue('"status": "success"' in response.content.decode('utf-8'))
Example #8
0
    def test_no_survey_with_class(self):
        self.new_survey.delete()
        response = end_session_create_survey_instance(self.request)

        self.assertTrue('"error_id": 504' in response.content.decode('utf-8'))