コード例 #1
0
    def test_wrong_request_type(self):
        mock_request = rf.post(
            '/api/position/select?session_id=' + str(self.session_id),
            {'position_id': str(self.position_id)})
        response = position_select_id(mock_request)

        self.assertTrue('"error_id": 301' in response.content.decode('utf-8'))
コード例 #2
0
    def test_position_does_not_belong_to_student(self):
        new_user = User.objects.create(username='******',
                                       email='*****@*****.**',
                                       first_name='first_test1',
                                       last_name='last_test1')
        new_user.set_password('test_password1234')
        new_user.save()

        new_student = Student.objects.create(user=new_user)
        new_student.save()

        new_position = Position.objects.create(x=1,
                                               y=1,
                                               student=new_student,
                                               timestamp=datetime.now())
        new_position.save()

        mock_request = rf.get(
            '/api/position/select', {
                'session_id': str(self.session_id),
                'position_id': str(new_position.id)
            })
        response = position_select_id(mock_request)

        self.assertTrue('"error_id": 304' in response.content.decode('utf-8'))
コード例 #3
0
    def test_position_does_not_exist(self):
        mock_request = rf.get('/api/position/select', {
            'session_id': str(self.session_id),
            'position_id': 111
        })
        response = position_select_id(mock_request)

        self.assertTrue('"error_id": 303' in response.content.decode('utf-8'))
コード例 #4
0
    def test_objects_retrieved(self):
        response = position_select_id(self.request)
        json_obj = json.loads(response.content.decode('utf-8'))

        self.assertTrue('x' in json_obj['data'])
        self.assertTrue('y' in json_obj['data'])
        self.assertTrue('id' in json_obj['data'])
        self.assertTrue('student' in json_obj['data'])
        self.assertTrue('timestamp' in json_obj['data'])
コード例 #5
0
    def test_not_enough_GET_data(self):
        mock_request = rf.get('/api/position/select',
                              {'session_id': str(self.session_id)})
        response = position_select_id(mock_request)

        self.assertTrue('"error_id": 302' in response.content.decode('utf-8'))
コード例 #6
0
    def test_no_logged_in_used(self):
        mock_request = rf.get('/api/position/select',
                              {'position_id': str(self.position_id)})
        response = position_select_id(mock_request)

        self.assertTrue('"error_id": 300' in response.content.decode('utf-8'))
コード例 #7
0
    def test_success_stats(self):
        response = position_select_id(self.request)

        self.assertTrue(
            '"status": "success"' in response.content.decode('utf-8'))