예제 #1
0
    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)
예제 #2
0
 def setUp(self):
     self.organisation = OrganisationFactory.create()
     self.resource = ResourceFactory.create(
         status=RESOURCE_APPROVED,
         organisation=self.organisation,
     )
     self.user = UserFactory.create()
예제 #3
0
    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})
예제 #4
0
 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',
     }
예제 #5
0
    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())
예제 #6
0
 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)
예제 #7
0
    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)
예제 #8
0
 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)
예제 #9
0
 def setUp(self):
     self.organisation = OrganisationFactory.create()
예제 #10
0
 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)
예제 #11
0
 def setUp(self):
     self.organisation = OrganisationFactory.create()
     self.resource_category = ResourceCategoryFactory.create()
예제 #12
0
 def setUp(self):
     OrganisationFactory.create()