예제 #1
0
    def test_not_enough_GET_data(self):
        request = rf.get(
            '/api/position/summary', {
                'session_id': str(self.session_id),
                'end_time': str(datetime.now() + timedelta(minutes=30))
            })
        response = position_summary(request)

        self.assertTrue('"error_id": 302' in response.content.decode('utf-8'))
예제 #2
0
    def test_no_logged_in_used(self):
        request = rf.get(
            '/api/position/summary', {
                'start_time': str(datetime.now() - timedelta(minutes=1)),
                'end_time': str(datetime.now() + timedelta(minutes=30))
            })
        response = position_summary(request)

        self.assertTrue('"error_id": 300' in response.content.decode('utf-8'))
예제 #3
0
    def test_empty_datetime_string(self):
        request = rf.get(
            '/api/position/summary', {
                'session_id': str(self.session_id),
                'start_time': '',
                'end_time': str(datetime.now() + timedelta(minutes=30))
            })
        response = position_summary(request)

        self.assertTrue('"error_id": 305' in response.content.decode('utf-8'))
예제 #4
0
    def test_wrong_request_type(self):
        request = rf.post(
            '/api/position/summary', {
                'session_id': str(self.session_id),
                'start_time': str(datetime.now() - timedelta(minutes=1)),
                'end_time': str(datetime.now() + timedelta(minutes=30))
            })
        response = position_summary(request)

        self.assertTrue('"error_id": 301' in response.content.decode('utf-8'))
예제 #5
0
    def test_retrieve_within_date_range(self):
        request = rf.get(
            '/api/position/summary', {
                'session_id': str(self.session_id),
                'start_time': str(datetime.now() - timedelta(minutes=1)),
                'end_time': str(datetime.now() + timedelta(minutes=30))
            })
        response = position_summary(request)
        json_obj = json.loads(response.content.decode('utf-8'))

        self.assertEqual(1, len(json_obj['data']))
예제 #6
0
    def test_retrieved_objects(self):
        response = position_summary(self.request)
        json_obj = json.loads(response.content.decode('utf-8'))

        self.assertEqual(2, len(json_obj['data']))
예제 #7
0
    def test_success_status(self):
        response = position_summary(self.request)

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