Test the django admin view, and that it can be loaded

This commit is contained in:
Calen Pennington
2019-08-02 13:27:16 -04:00
parent 85c4ba1a9d
commit ea8c8e8348
2 changed files with 16 additions and 3 deletions

View File

@@ -16,9 +16,21 @@ class TestAdminView(TestCase):
def setUp(self):
super(TestAdminView, self).setUp()
self.client = Client()
self.staff_user = UserFactory.create(is_staff=True)
self.client.login(username=self.staff_user.username, password=TEST_PASSWORD)
def test_admin_view_loads(self):
def test_admin_view_loads_for_is_staff(self):
staff_user = UserFactory.create(is_staff=True)
self.client.login(username=staff_user.username, password=TEST_PASSWORD)
response = self.client.get(reverse('admin:index'))
assert response.status_code == 200
def test_admin_view_loads_for_is_superuser(self):
superuser = UserFactory.create(is_superuser=True, is_staff=True)
self.client.login(username=superuser.username, password=TEST_PASSWORD)
response = self.client.get(reverse('admin:index'))
assert response.status_code == 200
def test_admin_view_doesnt_load_for_student(self):
student = UserFactory.create()
self.client.login(username=student.username, password=TEST_PASSWORD)
response = self.client.get(reverse('admin:index'))
assert response.status_code == 302

View File

@@ -233,6 +233,7 @@ class SystemTestSuite(PytestSuite):
if self.root == 'lms':
default_test_globs.append("{system}/tests.py".format(system=self.root))
default_test_globs.append("openedx/core/djangolib/*")
default_test_globs.append("openedx/core/tests/*")
default_test_globs.append("openedx/features")
def included(path):