11"""
22Tests for credentials service views.
33"""
4+ # pylint: disable=no-member
45from __future__ import unicode_literals
56import json
67
@@ -31,7 +32,7 @@ def setUp(self):
3132 super (UserCredentialViewSetTests , self ).setUp ()
3233
3334 self .user = factories .UserFactory ()
34- self .client .force_authenticate (self .user ) # pylint: disable=no-member
35+ self .client .force_authenticate (self .user )
3536
3637 self .program_cert = factories .ProgramCertificateFactory ()
3738 self .program_id = self .program_cert .program_id
@@ -43,7 +44,6 @@ def setUp(self):
4344
4445 def _add_permission (self , perm ):
4546 """ DRY helper to add usercredential model permissions to self.user """
46- # pylint: disable=no-member
4747 self .user .user_permissions .add (Permission .objects .get (codename = '{}_usercredential' .format (perm )))
4848
4949 def _attempt_update_user_credential (self , data ):
@@ -55,7 +55,6 @@ def _attempt_update_user_credential(self, data):
5555 Returns:
5656 Response: HTTP response from the API.
5757 """
58- # pylint: disable=no-member
5958 self ._add_permission ('change' )
6059 path = reverse ("api:v1:usercredential-detail" , args = [self .user_credential .id ])
6160 return self .client .patch (path = path , data = json .dumps (data ), content_type = JSON_CONTENT_TYPE )
@@ -120,7 +119,6 @@ def _attempt_create_user_credentials(self, data):
120119 Returns:
121120 Response: HTTP response from the API.
122121 """
123- # pylint: disable=no-member
124122 self ._add_permission ('add' )
125123 path = self .list_path
126124 return self .client .post (path = path , data = json .dumps (data ), content_type = JSON_CONTENT_TYPE )
@@ -457,7 +455,6 @@ class UserCredentialViewSetPermissionsTests(APITestCase):
457455
458456 def make_user (self , group = None , perm = None , ** kwargs ):
459457 """ DRY helper to create users with specific groups and/or permissions. """
460- # pylint: disable=no-member
461458 user = factories .UserFactory (** kwargs )
462459 if group :
463460 user .groups .add (Group .objects .get (name = group ))
@@ -482,7 +479,7 @@ def test_list(self, user_kwargs, expected_status):
482479 """
483480 list_path = reverse ("api:v1:usercredential-list" )
484481
485- self .client .force_authenticate (self .make_user (** user_kwargs )) # pylint: disable=no-member
482+ self .client .force_authenticate (self .make_user (** user_kwargs ))
486483 response = self .client .get (list_path , {'username' : 'test-user' })
487484 self .assertEqual (response .status_code , expected_status )
488485
@@ -509,7 +506,7 @@ def test_create(self, user_kwargs, expected_status):
509506 'attributes' : [],
510507 }
511508
512- self .client .force_authenticate (self .make_user (** user_kwargs )) # pylint: disable=no-member
509+ self .client .force_authenticate (self .make_user (** user_kwargs ))
513510 response = self .client .post (list_path , data = json .dumps (post_data ), content_type = JSON_CONTENT_TYPE )
514511 self .assertEqual (response .status_code , expected_status )
515512
@@ -533,7 +530,7 @@ def test_retrieve(self, user_kwargs, expected_status):
533530 user_credential = factories .UserCredentialFactory .create (credential = program_cert , username = 'test-user' )
534531 detail_path = reverse ("api:v1:usercredential-detail" , args = [user_credential .id ])
535532
536- self .client .force_authenticate (self .make_user (** user_kwargs )) # pylint: disable=no-member
533+ self .client .force_authenticate (self .make_user (** user_kwargs ))
537534 response = self .client .get (detail_path )
538535 self .assertEqual (response .status_code , expected_status )
539536
@@ -560,7 +557,7 @@ def test_partial_update(self, user_kwargs, expected_status):
560557 },
561558 'attributes' : [{'name' : 'dummy-attr-name' , 'value' : 'dummy-attr-value' }],
562559 }
563- self .client .force_authenticate (self .make_user (** user_kwargs )) # pylint: disable=no-member
560+ self .client .force_authenticate (self .make_user (** user_kwargs ))
564561 response = self .client .patch (path = detail_path , data = json .dumps (post_data ), content_type = JSON_CONTENT_TYPE )
565562 self .assertEqual (response .status_code , expected_status )
566563
@@ -574,18 +571,17 @@ class CredentialViewSetTests(APITestCase):
574571 def setUp (self ):
575572 super (CredentialViewSetTests , self ).setUp ()
576573
577- # pylint: disable=no-member
578574 self .user = factories .UserFactory ()
579575 self .user .groups .add (Group .objects .get (name = Role .ADMINS ))
580- self .client .force_authenticate (self .user ) # pylint: disable=no-member
576+ self .client .force_authenticate (self .user )
581577 self .request = APIRequestFactory ().get ('/' )
582578
583579 def assert_permission_required (self , data ):
584580 """
585581 Ensure access to these APIs is restricted to those with explicit model
586582 permissions.
587583 """
588- self .client .force_authenticate (user = factories .UserFactory ()) # pylint: disable=no-member
584+ self .client .force_authenticate (user = factories .UserFactory ())
589585 response = self .client .get (self .list_path , data )
590586 self .assertEqual (response .status_code , 403 )
591587
0 commit comments