fix is_authenticated mocks

This commit is contained in:
Eric Fischer
2018-05-02 11:26:27 -04:00
parent e18448e27d
commit 4147b72f18
3 changed files with 12 additions and 6 deletions

View File

@@ -113,7 +113,10 @@ class CreatorGroupTest(TestCase):
def test_add_user_to_group_requires_authenticated(self):
with self.assertRaises(PermissionDenied):
with mock.patch('django.contrib.auth.models.User.is_authenticated') as mock_is_auth:
with mock.patch(
'django.contrib.auth.models.User.is_authenticated',
new_callable=mock.PropertyMock
) as mock_is_auth:
mock_is_auth.return_value = False
add_users(self.admin, CourseCreatorRole(), self.user)
@@ -129,7 +132,10 @@ class CreatorGroupTest(TestCase):
def test_remove_user_from_group_requires_authenticated(self):
with self.assertRaises(PermissionDenied):
with mock.patch('django.contrib.auth.models.User.is_authenticated') as mock_is_auth:
with mock.patch(
'django.contrib.auth.models.User.is_authenticated',
new_callable=mock.PropertyMock
) as mock_is_auth:
mock_is_auth.return_value = False
remove_users(self.admin, CourseCreatorRole(), self.user)