-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
822 additions
and
1,644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,14 @@ | ||
from unittest.mock import Mock, patch | ||
|
||
from django.test import RequestFactory | ||
from django.contrib.auth.models import Permission, Group, User | ||
|
||
from accounts.models import DisclaimerContent | ||
from common.tests.helpers import set_up_fb | ||
from common.tests.helpers import create_configured_user | ||
|
||
|
||
class TestPermissionMixin(object): | ||
|
||
def setUp(self): | ||
set_up_fb() | ||
self.factory = RequestFactory() | ||
self.user =User.objects.create_user( | ||
username='testnonstaffuser', email='[email protected]', | ||
password='test' | ||
) | ||
self.staff_user = User.objects.create_user( | ||
username='testuser', email='[email protected]', password='test' | ||
) | ||
self.staff_user.is_staff = True | ||
self.staff_user.save() | ||
self.instructor_user = User.objects.create_user( | ||
username='testinstructoruser', email='[email protected]', | ||
password='test' | ||
) | ||
perm = Permission.objects.get(codename="can_view_registers") | ||
group, _ = Group.objects.get_or_create(name="instructors") | ||
group.permissions.add(perm) | ||
self.instructor_user.groups.add(group) | ||
@classmethod | ||
def setUpTestData(cls): | ||
cls.user = create_configured_user("test", "[email protected]", "test") | ||
cls.instructor_user = create_configured_user("instructor", "[email protected]", "test", instructor=True) | ||
cls.staff_user = create_configured_user("staff", "[email protected]", "test", staff=True) | ||
|
||
# Make sure we have a current disclaimer content | ||
DisclaimerContent.objects.create(version=None) | ||
|
||
mockresponse = Mock() | ||
mockresponse.status_code = 200 | ||
self.patcher = patch('requests.request', return_value = mockresponse) | ||
self.mock_request = self.patcher.start() | ||
|
||
def tearDown(self): | ||
self.patcher.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.