def setUp(self): self.anonymous = factories.AnonymousUserFactory() self.superuser = factories.SuperUserFactory() self.user = factories.UserFactory(username="******") self.other_user = factories.UserFactory(username="******") self.permission = factories.TreePermissionFactory( parent_path="my/path", name="my_name", user=self.user)
def test_check_permission(self): user = factories.UserFactory(password="******") assert self.client.login(username=user.username, password="******") response = self.client.get(reverse("repo_browse", args=[""])) self.assertEqual(response.status_code, 403) superuser = factories.SuperUserFactory(password="******") assert self.client.login(username=superuser.username, password="******") response = self.client.get(reverse("repo_browse", args=[""])) self.assertEqual(response.status_code, 200)
def test_check_permissions(self): view = views.DummyRepositoryView() self.assertRaises(NotImplementedError, view.check_permissions) request = RequestFactory() request.user = factories.UserFactory() view = views.DummyAdminShareView(request=request, path=Path("")) self.assertRaises(PermissionDenied, view.check_permissions) request = RequestFactory() request.user = factories.SuperUserFactory() view = views.DummyAdminShareView(request=request, path=Path("")) self.assertIsNone(view.check_permissions())
def test_superuser(self): factories.SuperUserFactory() field = forms.UsersChoiceField() self.assertQuerysetEqual(field.queryset, [])