From 1372cf1f6f5523e21f0d898a1068de040edbc6fc Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 7 Feb 2020 11:38:50 +0100 Subject: [PATCH] Move tests from example app into main package. --- authority/tests.py | 21 ++++++++++++++++++--- example/exampleapp/tests.py | 19 ------------------- 2 files changed, 18 insertions(+), 22 deletions(-) delete mode 100644 example/exampleapp/tests.py diff --git a/authority/tests.py b/authority/tests.py index 2d8ba15..f7a4274 100644 --- a/authority/tests.py +++ b/authority/tests.py @@ -1,16 +1,16 @@ from django.conf import settings -from django.contrib.auth.models import Permission as DjangoPermission -from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model +from django.contrib.auth.models import Group, Permission as DjangoPermission from django.contrib.contenttypes.models import ContentType from django.core.exceptions import MultipleObjectsReturned from django.db.models import Q from django.test import TestCase +from django.urls import reverse import authority from authority import permissions from authority.models import Permission from authority.exceptions import NotAModel, UnsavedModelInstance -from authority.compat import get_user_model # Load the form from authority.forms import UserPermissionForm # noqa @@ -436,3 +436,18 @@ class GroupPermissionCacheTestCase(SmartCachingTestCase): "foo", self.group, approved=True, ) self.assertTrue(can_foo_with_group) + + +class AddPermissionTestCase(TestCase): + def test_add_permission_permission_denied_is_403(self): + user = get_user_model().objects.create(username="foo", email="foo@example.com",) + user.set_password("pw") + user.save() + + assert self.client.login(username="foo@example.com", password="pw") + url = reverse( + "authority-add-permission-request", + kwargs={"app_label": "foo", "module_name": "Bar", "pk": 1,}, + ) + r = self.client.get(url) + self.assertEqual(r.status_code, 403) diff --git a/example/exampleapp/tests.py b/example/exampleapp/tests.py deleted file mode 100644 index c0f2801..0000000 --- a/example/exampleapp/tests.py +++ /dev/null @@ -1,19 +0,0 @@ -from django.urls import reverse -from django.test import TestCase - -from authority.compat import get_user_model - - -class AddPermissionTestCase(TestCase): - def test_add_permission_permission_denied_is_403(self): - user = get_user_model().objects.create(username="foo", email="foo@example.com",) - user.set_password("pw") - user.save() - - assert self.client.login(username="foo@example.com", password="pw") - url = reverse( - "authority-add-permission-request", - kwargs={"app_label": "foo", "module_name": "Bar", "pk": 1,}, - ) - r = self.client.get(url) - self.assertEqual(r.status_code, 403)