示例#1
0
    def setUp(self):
        self.user = ALISSUser.objects.create_user("*****@*****.**", "passwurd")
        self.client.login(username='******', password='******')

        t,u,c,s = Fixtures.create_users()
        self.user = c
        self.user.is_editor = True
        self.user.save()

         # Create an Organisation for 2 services
        self.org = Fixtures.create_organisation(t, u, self.user)
        self.new_org = Fixtures.create_organisation(t,u,u)

         # Create a service which has been reviewed recently and is represented by user.
        self.recently_reviewed_service = Fixtures.create_service(self.org)
        utc = pytz.UTC
        current_date = datetime.now()
        current_date = utc.localize(current_date)
        in_range_date = (current_date - timedelta(weeks=5))
        self.recently_reviewed_service.last_edited = in_range_date
        self.recently_reviewed_service.save()

         # Create a service which is outwith review range but is represented by user.
        self.unreviewed_service = Service.objects.create(name="Old Service", description="An old service which needs to be reviewed.", organisation=self.org, created_by=self.org.created_by, updated_by=self.org.updated_by)
        utc = pytz.UTC
        current_date = datetime.now()
        current_date = utc.localize(current_date)
        outwith_range_date = (current_date - timedelta(weeks=8))
        self.unreviewed_service.last_edited = outwith_range_date
        self.unreviewed_service.save()

         # Create a service which is not represented by the user.
        self.different_user_editor = Service.objects.create(name="Different Editor Service", description="A service which isn't edited by the other user.", organisation=self.new_org, created_by=self.new_org.created_by)
示例#2
0
 def test_organisation_valid_update_one_service_redirects_to_org_detail(
         self):
     Fixtures.create_service(self.organisation)
     self.assertEqual(self.organisation.services.count(), 1)
     response = self.client.post(
         reverse('organisation_edit', kwargs={'pk': self.organisation.pk}),
         {
             'name': 'an updated organisation',
             'description': 'a full description'
         })
     self.organisation.refresh_from_db()
     self.assertEqual(self.organisation.name, 'an updated organisation')
     self.assertEqual(response.status_code, 302)
     self.assertRedirects(
         response,
         reverse('organisation_detail_slug',
                 kwargs={'slug': self.organisation.slug}))
示例#3
0
 def setUp(self):
     self.user = ALISSUser.objects.create_user("*****@*****.**",
                                               "passwurd")
     self.client.login(username='******', password='******')
     self.organisation = Fixtures.create_organisation(self.user)
     self.service = Fixtures.create_service(self.organisation)
     self.non_edit_user = ALISSUser.objects.create_user(
         "*****@*****.**", "passwurd")
示例#4
0
 def setUp(self):
     t, u, c, s = Fixtures.create_users()
     self.org = Fixtures.create_organisation(t, u, c)
     self.service = Fixtures.create_service(self.org)
     self.org2 = Organisation.objects.create(
         name="Scottish Optometrist Society",
         description="Description of organisation",
         created_by=self.org.created_by,
         updated_by=self.org.updated_by)
示例#5
0
 def test_service_edit_without_claimant(self):
     new_org = Fixtures.create_organisation(self.organisation.created_by, self.organisation.created_by)
     new_service = Fixtures.create_service(new_org)
     edit_path = reverse('service_edit', kwargs={ 'pk': new_service.pk })
     self.assertEqual(self.client.get(edit_path).status_code, 302)
     self.client.login(username=self.user.email, password='******')
     self.assertEqual(self.client.get(edit_path).status_code, 200)
     self.client.login(username=self.editor.email, password='******')
     self.assertEqual(self.client.get(edit_path).status_code, 200)
     self.client.login(username=self.staff.email, password='******')
     self.assertEqual(self.client.get(edit_path).status_code, 200)
示例#6
0
 def test_organisation_publish(self):
     queryset = Fixtures.es_connection()
     org_queryset = Fixtures.es_organisation_connection()
     self.organisation.published = False
     self.organisation.save()
     unpublished_service = Fixtures.create_service(self.organisation)
     index_result = get_service(queryset, unpublished_service.id)
     self.client.login(username='******', password='******')
     self.assertEqual(len(index_result), 0)
     response = self.client.post(
         reverse('organisation_publish',
                 kwargs={'pk': self.organisation.pk}))
     self.organisation.refresh_from_db()
     index_result = get_service(queryset, unpublished_service.id)
     self.assertEqual(len(index_result), 1)
     self.assertTrue(self.organisation.published)
     self.assertEqual(response.status_code, 302)
     self.assertRedirects(response, (reverse('organisation_unpublished')))
     org_index_result = get_organisation_by_id(org_queryset,
                                               self.organisation.id)
     self.assertEqual(len(org_index_result), 1)
示例#7
0
 def setUp(self):
     self.user, self.editor, self.claimant, self.staff = Fixtures.create_users()
     self.organisation = Fixtures.create_organisation(self.user, self.editor, self.claimant)
     self.service = Fixtures.create_service(self.organisation)
     self.non_edit_user = ALISSUser.objects.create_user("*****@*****.**", "passwurd")
     self.client.login(username=self.claimant.email, password='******')