Beispiel #1
0
    def test_delete_publication_removes_publication(self):
        publication_id = 1234
        test_utils.create_publication(publication_id=publication_id)

        self.post_to_delete_publications(publication_id=publication_id)

        publication = helpers.get_record_from_id(Publication, publication_id)

        assert not publication
Beispiel #2
0
    def test_delete_publication_requires_writer_privileges(self):
        publication_id = 1234
        test_utils.create_publication(publication_id=publication_id)

        self.post_to_delete_publications(publication_id=publication_id,
                                         token_type='viewer')

        publication = helpers.get_record_from_id(Publication, publication_id)

        assert publication
Beispiel #3
0
    def test_get_all_publications_returns_all_publications(self):
        test_utils.create_publication()

        publication_count = len(Publication.query.all())

        response = self.get_to_get_all_publications()
        response_dict = json.loads(response.data)
        response_count = len(response_dict['publications'])

        assert response.status_code == 200
        assert publication_count == response_count
Beispiel #4
0
    def test_add_contact_to_publication(self):
        contact_id = 42
        contact = test_utils.create_contact(contact_id=contact_id)

        report_id = 99
        test_utils.create_report(report_id=report_id)

        publication_id = 1234
        test_utils.create_publication(publication_id=publication_id,
                                      report_label='report1111')

        response = self.patch_to_edit_publication(
            publication_id=publication_id, contact_ids=[contact_id])

        publication = helpers.get_record_from_id(Publication, publication_id)

        assert response.status_code == 200
        assert len(publication.recipients) == 1
        assert publication.recipients[0].id == contact_id
Beispiel #5
0
    def test_add_recipient_to_publication_with_bad_contact_id(self):
        publication_id = 1234
        publication = test_utils.create_publication(
            publication_id=publication_id, report_label='report1111')

        response = self.patch_to_edit_publication(
            publication_id=publication_id, contact_ids=[9999])

        publication = helpers.get_record_from_id(Publication, publication_id)

        assert response.status_code == 400
        assert not publication.recipients