1
- import sys
2
1
import unittest
3
2
from calendar import timegm
4
3
from datetime import datetime , timedelta
4
+ from unittest .mock import patch
5
5
from urllib import parse
6
6
7
+ import ddt
8
+ import jwt
7
9
from django .conf import settings
8
10
from django .core .management import call_command
9
11
from django .test .utils import override_settings
10
12
from django .urls import reverse
11
- from unittest .mock import patch
12
-
13
- import ddt
14
- import jwt
15
13
from rest_framework import status
16
14
from rest_framework .test import APITestCase
17
15
21
19
TEST_OTHER_USER = "test_other_user_id"
22
20
23
21
if not settings .ES_DISABLED :
24
- from notesapi .v1 .search_indexes .documents import NoteDocument
22
+ from notesapi .v1 .search_indexes .documents import NoteDocument # pylint: disable=unused-import
25
23
else :
26
- def call_command (* args , ** kwargs ):
24
+ def call_command (* args , ** kwargs ): # pylint: disable=function-redefined
27
25
pass
28
26
29
27
@@ -111,7 +109,7 @@ def get_annotations(self, query_parameters=None, expected_status=200):
111
109
self .assertEqual (expected_status , response .status_code )
112
110
return response .data
113
111
114
- # pylint: disable=too-many-arguments
112
+ # pylint: disable=too-many-positional- arguments
115
113
def verify_pagination_info (
116
114
self , response ,
117
115
total_annotations ,
@@ -161,7 +159,7 @@ def get_page_value(url, current_page):
161
159
self .assertEqual (get_page_value (response ['next' ], response ['current_page' ]), next_page )
162
160
self .assertEqual (response ['start' ], start )
163
161
164
- # pylint: disable=too-many-arguments
162
+ # pylint: disable=too-many-positional- arguments
165
163
def verify_list_view_pagination (
166
164
self ,
167
165
query_parameters ,
@@ -176,7 +174,6 @@ def verify_list_view_pagination(
176
174
"""
177
175
Verify pagination information for AnnotationListView
178
176
"""
179
- total_annotations = total_annotations
180
177
for i in range (total_annotations ):
181
178
self ._create_annotation (text = f'annotation { i } ' )
182
179
@@ -192,7 +189,7 @@ def verify_list_view_pagination(
192
189
start = start
193
190
)
194
191
195
- # pylint: disable=too-many-arguments
192
+ # pylint: disable=too-many-positional- arguments
196
193
def verify_search_view_pagination (
197
194
self ,
198
195
query_parameters ,
@@ -207,7 +204,6 @@ def verify_search_view_pagination(
207
204
"""
208
205
Verify pagination information for AnnotationSearchView
209
206
"""
210
- total_annotations = total_annotations
211
207
for i in range (total_annotations ):
212
208
self ._create_annotation (text = f'annotation { i } ' )
213
209
@@ -370,15 +366,15 @@ def test_create_maximum_allowed(self):
370
366
# if user tries to create note in a different course it should succeed
371
367
kwargs = {'course_id' : 'test-course-id-2' }
372
368
response = self ._create_annotation (** kwargs )
373
- self .assertTrue ('id' in response )
369
+ self .assertIn ('id' , response )
374
370
375
371
# if another user to tries to create note in first course it should succeed
376
372
token = get_id_token (TEST_OTHER_USER )
377
373
self .client .credentials (HTTP_X_ANNOTATOR_AUTH_TOKEN = token )
378
374
self .headers = {'user' : TEST_OTHER_USER }
379
375
kwargs = {'user' : TEST_OTHER_USER }
380
376
response = self ._create_annotation (** kwargs )
381
- self .assertTrue ('id' in response )
377
+ self .assertIn ('id' , response )
382
378
383
379
def test_read_all_no_annotations (self ):
384
380
"""
@@ -437,7 +433,7 @@ def test_read_all_no_query_param(self):
437
433
{'page' : 2 , 'annotations_per_page' : 10 , 'previous_page' : 1 , 'next_page' : 3 , 'start' : 10 },
438
434
{'page' : 3 , 'annotations_per_page' : 3 , 'previous_page' : 2 , 'next_page' : None , 'start' : 20 }
439
435
)
440
- # pylint: disable=too-many-arguments
436
+ # pylint: disable=too-many-positional- arguments
441
437
def test_pagination_multiple_pages (self , page , annotations_per_page , previous_page , next_page , start ):
442
438
"""
443
439
Verify that pagination info is correct when we have data spanned on multiple pages.
@@ -1081,7 +1077,7 @@ def test_search_highlight_tag(self):
1081
1077
{'page' : 2 , 'annotations_per_page' : 10 , 'previous_page' : 1 , 'next_page' : 3 , 'start' : 10 },
1082
1078
{'page' : 3 , 'annotations_per_page' : 3 , 'previous_page' : 2 , 'next_page' : None , 'start' : 20 }
1083
1079
)
1084
- # pylint: disable=too-many-arguments
1080
+ # pylint: disable=too-many-positional- arguments
1085
1081
def test_pagination_multiple_pages (self , page , annotations_per_page , previous_page , next_page , start ):
1086
1082
"""
1087
1083
Verify that pagination info is correct when we have data spanned on multiple pages.
@@ -1221,7 +1217,7 @@ def test_no_token(self):
1221
1217
"""
1222
1218
403 when no token is provided
1223
1219
"""
1224
- self .client ._credentials = {}
1220
+ self .client ._credentials = {} # pylint: disable=protected-access
1225
1221
response = self .client .get (self .url , self .headers )
1226
1222
self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
1227
1223
0 commit comments