Esempio n. 1
0
    def test_AttestableBasicNote_signing(self):
        """Verify that signing is possible for those with relevant permission.
        """

        sign_url = "attestable-basic-note-sign"

        note = models.AttestableBasicNote.objects.create(**self.note_data)

        # Fresh notes should be unsigned
        assert not note.signed()

        # Providers with can_attend == False should not be able to sign
        can_sign_group = user_factories.PermGroupFactory(
            permissions=['workup.sign_AttestableBasicNote'])
        cannot_sign_group = user_factories.NoPermGroupFactory()

        can_sign = user_factories.UserFactory(groups=[can_sign_group])
        cannot_sign = user_factories.UserFactory(groups=[cannot_sign_group])

        for user in [can_sign, cannot_sign]:
            log_in_user(self.client, user)
            response = self.client.get(reverse(sign_url, args=(note.id, )))
            detail_url = reverse('attestable-basic-note-detail',
                                 args=(note.id, ))
            self.assertRedirects(response, detail_url)
            assert models.AttestableBasicNote.objects.get(
                pk=note.id).signed() == (user == can_sign)
            note.signer = None
            note.save()
Esempio n. 2
0
    def test_export_dispensing_histories(self):
        export_dispensing_histories_url = reverse('inventory:export-dispensing-history')
        no_perm_group = user_factories.NoPermGroupFactory()
        csv_perm_group = user_factories.PermGroupFactory(permissions=['inventory.export_csv'])

        for group in [no_perm_group, csv_perm_group]:
            log_in_user(self.client, user_factories.UserFactory(groups=[group]))
            response = self.client.post(export_dispensing_histories_url, {'start_date': '2020-09-22','end_date': '2020-09-28'})

            if group == csv_perm_group:
                assert response.status_code == 200
                self.assertEqual(response["Content-Disposition"],
                                 f"attachment; filename=drug-dispensing-history-through-09/28/20.csv")
            else:
                 assert response.status_code == 403
Esempio n. 3
0
    def test_workup_pdf(self):
        """Verify that pdf download with the correct name
        """

        wu_url = "workup-pdf"

        no_perm_group = user_factories.NoPermGroupFactory()
        pdf_perm_group = user_factories.PermGroupFactory(
            permissions=['workup.export_pdf_Workup'])

        for group in [no_perm_group, pdf_perm_group]:
            log_in_user(self.client,
                        user_factories.UserFactory(groups=[group]))
            response = self.client.get(reverse(wu_url, args=(self.wu.id, )))
            assert response.status_code == 200 if group == pdf_perm_group else 403
Esempio n. 4
0
    def test_export_csv(self):
        export_csv_url = reverse('inventory:export-csv')
        no_perm_group = user_factories.NoPermGroupFactory()
        csv_perm_group = user_factories.PermGroupFactory(permissions=['inventory.export_csv'])

        for group in [no_perm_group, csv_perm_group]:
            log_in_user(self.client, user_factories.UserFactory(groups=[group]))
            response = self.client.post(export_csv_url)

            if group == csv_perm_group:
                assert response.status_code == 200
                date_list = str(timezone.now().date()).split("-")
                formatted_date = f"{date_list[1]}/{date_list[2]}/{date_list[0][:2]}"
                self.assertEqual(response["Content-Disposition"],
                                 f"attachment; filename=drug-inventory-{formatted_date}.csv")
            else:
                 assert response.status_code == 403