def setUp(self): self.user_admin = UserAdmin(User, AdminSite()) self.superuser = UserFactory.create(is_superuser=True) self.organisation = OrganisationFactory.create() self.organisation_1 = OrganisationFactory.create() self.user_with_org = UserFactory.create(is_staff=True) self.user_with_org.approved_organisations.add(self.organisation) self.user_with_org.approved_organisations.add(self.organisation_1) self.user_with_org_1 = UserFactory.create(is_staff=True) self.user_with_org_1.approved_organisations.add(self.organisation)
def setUp(self): self.organisation = OrganisationFactory.create() self.resource = ResourceFactory.create( status=RESOURCE_APPROVED, organisation=self.organisation, ) self.user = UserFactory.create()
def setUp(self): self.url = reverse('resource-list') self.resource_1 = ResourceFactory.create(status=RESOURCE_APPROVED) self.like_url = reverse('resource-like', kwargs={'pk': self.resource_1.id}) self.tried_url = reverse('resource-tried', kwargs={'pk': self.resource_1.id}) self.organisation = OrganisationFactory.create() self.user = UserFactory.create( is_staff=True, approved_organisations=[self.organisation], password='******') self.logged_in_client = APIClient() self.logged_in_client.login(username=self.user.email, password='******') ResourceFactory.create(status=RESOURCE_REJECTED) ResourceFactory.create(privacy=[self.organisation], status=RESOURCE_APPROVED) self.url = reverse('resource-list') self.update_url = reverse('resource-detail', kwargs={'pk': self.resource_1.id})
def setUp(self): self.user = UserFactory.create( approved_organisations=OrganisationFactory.create_batch(size=10)) self.resource_category = ResourceCategoryFactory.create() self.initial = { 'title': 'test', 'abstract': 'abstract', 'content': 'content', }
def test_permissions_multiple_grants(self): """Test orgs are approved if there are multiple matches to the email domain.""" organisation_a = OrganisationFactory.create(email="*****@*****.**") organisation_b = OrganisationFactory.create(email="*****@*****.**") organisation_c = OrganisationFactory.create(email="*****@*****.**") form = UserRegistrationForm({ 'email': '*****@*****.**', 'password': '******', 'confirm_password': '******', 'first_name': 'test', 'last_name': 'test', 'chosen_organisations': [organisation_a, organisation_b], 'privacy_agreement': True, }) self.assertTrue(form.is_valid()) user = form.save() self.assertIn(organisation_a, user.approved_organisations.all()) self.assertIn(organisation_b, user.approved_organisations.all()) self.assertNotIn(organisation_c, user.approved_organisations.all())
def test_resource_detail(self): organisation = OrganisationFactory.create() resource = ResourceFactory.create( slug='testing', status=RESOURCE_APPROVED, organisation=organisation, privacy=[organisation], ) user = UserFactory.create( approved_organisations=[resource.organisation], ) response = self.app.get(reverse('resources:resource-detail', kwargs={'slug': resource.slug}), user=user) self.assertEqual(response.status_code, 200)
def setUp(self): self.resource_admin = ResourceAdmin(Resource, AdminSite()) self.user_admin = UserAdmin(User, AdminSite()) self.organisation = OrganisationFactory.create() self.resource = ResourceFactory.create(organisation=self.organisation) self.resource_1 = ResourceFactory.create( organisation=self.organisation) self.resource_2 = ResourceFactory.create() self.user_without_organisation = UserFactory.create(is_staff=True) self.user_with_organisation = UserFactory.create(is_staff=True) self.user_with_organisation.approved_organisations.add( self.organisation)
def test_resource_exist_no_access(self): organisation = OrganisationFactory.create() resource = ResourceFactory.create( slug='testing', status=RESOURCE_APPROVED, organisation=organisation, privacy=[organisation], ) response = self.app.get( reverse('resources:resource-detail', kwargs={'slug': resource.slug})) url = '{url}?next={next}'.format( url=reverse('accounts:login'), next=resource.get_absolute_url(), ) self.assertEqual(response.location, url)
def setUp(self): self.organisation = OrganisationFactory.create()
def setUp(self): self.organisation = OrganisationFactory.create() self.organisation_1 = OrganisationFactory.create() self.user = UserFactory.create( approved_organisations=[self.organisation]) self.superuser = UserFactory.create(is_superuser=True)
def setUp(self): self.organisation = OrganisationFactory.create() self.resource_category = ResourceCategoryFactory.create()
def setUp(self): OrganisationFactory.create()