1- import sys
21import unittest
32from calendar import timegm
43from datetime import datetime , timedelta
4+ from unittest .mock import patch
55from urllib import parse
66
7+ import ddt
8+ import jwt
79from django .conf import settings
810from django .core .management import call_command
911from django .test .utils import override_settings
1012from django .urls import reverse
11- from unittest .mock import patch
12-
13- import ddt
14- import jwt
1513from rest_framework import status
1614from rest_framework .test import APITestCase
1715
2119TEST_OTHER_USER = "test_other_user_id"
2220
2321if 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
2523else :
26- def call_command (* args , ** kwargs ):
24+ def call_command (* args , ** kwargs ): # pylint: disable=function-redefined
2725 pass
2826
2927
@@ -111,7 +109,7 @@ def get_annotations(self, query_parameters=None, expected_status=200):
111109 self .assertEqual (expected_status , response .status_code )
112110 return response .data
113111
114- # pylint: disable=too-many-arguments
112+ # pylint: disable=too-many-positional- arguments
115113 def verify_pagination_info (
116114 self , response ,
117115 total_annotations ,
@@ -161,7 +159,7 @@ def get_page_value(url, current_page):
161159 self .assertEqual (get_page_value (response ['next' ], response ['current_page' ]), next_page )
162160 self .assertEqual (response ['start' ], start )
163161
164- # pylint: disable=too-many-arguments
162+ # pylint: disable=too-many-positional- arguments
165163 def verify_list_view_pagination (
166164 self ,
167165 query_parameters ,
@@ -176,7 +174,6 @@ def verify_list_view_pagination(
176174 """
177175 Verify pagination information for AnnotationListView
178176 """
179- total_annotations = total_annotations
180177 for i in range (total_annotations ):
181178 self ._create_annotation (text = f'annotation { i } ' )
182179
@@ -192,7 +189,7 @@ def verify_list_view_pagination(
192189 start = start
193190 )
194191
195- # pylint: disable=too-many-arguments
192+ # pylint: disable=too-many-positional- arguments
196193 def verify_search_view_pagination (
197194 self ,
198195 query_parameters ,
@@ -207,7 +204,6 @@ def verify_search_view_pagination(
207204 """
208205 Verify pagination information for AnnotationSearchView
209206 """
210- total_annotations = total_annotations
211207 for i in range (total_annotations ):
212208 self ._create_annotation (text = f'annotation { i } ' )
213209
@@ -370,15 +366,15 @@ def test_create_maximum_allowed(self):
370366 # if user tries to create note in a different course it should succeed
371367 kwargs = {'course_id' : 'test-course-id-2' }
372368 response = self ._create_annotation (** kwargs )
373- self .assertTrue ('id' in response )
369+ self .assertIn ('id' , response )
374370
375371 # if another user to tries to create note in first course it should succeed
376372 token = get_id_token (TEST_OTHER_USER )
377373 self .client .credentials (HTTP_X_ANNOTATOR_AUTH_TOKEN = token )
378374 self .headers = {'user' : TEST_OTHER_USER }
379375 kwargs = {'user' : TEST_OTHER_USER }
380376 response = self ._create_annotation (** kwargs )
381- self .assertTrue ('id' in response )
377+ self .assertIn ('id' , response )
382378
383379 def test_read_all_no_annotations (self ):
384380 """
@@ -437,7 +433,7 @@ def test_read_all_no_query_param(self):
437433 {'page' : 2 , 'annotations_per_page' : 10 , 'previous_page' : 1 , 'next_page' : 3 , 'start' : 10 },
438434 {'page' : 3 , 'annotations_per_page' : 3 , 'previous_page' : 2 , 'next_page' : None , 'start' : 20 }
439435 )
440- # pylint: disable=too-many-arguments
436+ # pylint: disable=too-many-positional- arguments
441437 def test_pagination_multiple_pages (self , page , annotations_per_page , previous_page , next_page , start ):
442438 """
443439 Verify that pagination info is correct when we have data spanned on multiple pages.
@@ -1081,7 +1077,7 @@ def test_search_highlight_tag(self):
10811077 {'page' : 2 , 'annotations_per_page' : 10 , 'previous_page' : 1 , 'next_page' : 3 , 'start' : 10 },
10821078 {'page' : 3 , 'annotations_per_page' : 3 , 'previous_page' : 2 , 'next_page' : None , 'start' : 20 }
10831079 )
1084- # pylint: disable=too-many-arguments
1080+ # pylint: disable=too-many-positional- arguments
10851081 def test_pagination_multiple_pages (self , page , annotations_per_page , previous_page , next_page , start ):
10861082 """
10871083 Verify that pagination info is correct when we have data spanned on multiple pages.
@@ -1221,7 +1217,7 @@ def test_no_token(self):
12211217 """
12221218 403 when no token is provided
12231219 """
1224- self .client ._credentials = {}
1220+ self .client ._credentials = {} # pylint: disable=protected-access
12251221 response = self .client .get (self .url , self .headers )
12261222 self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
12271223
0 commit comments