@@ -0,0 +1,2259 @@
+import json%0Aimport mock%0Aimport six%0A%0Afrom celery.exceptions import Retry, MaxRetriesExceededError%0Afrom requests.exceptions import RequestException%0Afrom django.test import SimpleTestCase, override_settings%0A%0Afrom regulations.tasks import submit_comment%0A%0A%0A@mock.patch('regulations.models.FailedCommentSubmission.objects')%0A@mock.patch('regulations.tasks.submit_comment.retry')%0A@mock.patch('requests.post')%0A@mock.patch('regulations.tasks.html_to_pdf')%0A@override_settings(%0A    ATTACHMENT_BUCKET='test-bucket',%0A    ATTACHMENT_ACCESS_KEY_ID='test-access-key',%0A    ATTACHMENT_SECRET_ACCESS_KEY='test-secret-key',%0A    ATTACHMENT_MAX_SIZE=42,%0A    REGS_GOV_API_URL='test-url',%0A    REGS_GOV_API_KEY='test-key',%0A)%0Aclass TestSubmitComment(SimpleTestCase):%0A%0A    def test_submit_comment(self, html_to_pdf, post, retry, query_set):%0A        file_handle = six.BytesIO(%22foobar%22)%0A        html_to_pdf.return_value.__enter__ = mock.Mock(%0A            return_value=file_handle)%0A%0A        expected_result = %7B'tracking_number': '133321'%7D%0A        post.return_value.status_code = 201%0A        post.return_value.json.return_value = expected_result%0A%0A        body = %7B'assembled_comment': %7B'sections': %5B%5D%7D%7D%0A        result = submit_comment(body)%0A%0A        self.assertEqual(result, expected_result)%0A%0A    def test_failed_submit_raises_retry(self, html_to_pdf, post, retry,%0A                                        query_set):%0A        file_handle = six.BytesIO(%22foobar%22)%0A        html_to_pdf.return_value.__enter__ = mock.Mock(%0A            return_value=file_handle)%0A%0A        post.side_effect = %5BRequestException%5D%0A%0A        retry.return_value = Retry()%0A%0A        body = %7B'assembled_comment': %7B'sections': %5B%5D%7D%7D%0A        with self.assertRaises(Retry):%0A            submit_comment(body)%0A%0A    def test_failed_submit_maximum_retries(self, html_to_pdf, post, retry,%0A                                           query_set):%0A        file_handle = six.BytesIO(%22foobar%22)%0A        html_to_pdf.return_value.__enter__ = mock.Mock(%0A            return_value=file_handle)%0A%0A        post.side_effect = %5BRequestException%5D%0A%0A        retry.return_value = MaxRetriesExceededError()%0A%0A        body = %7B'assembled_comment': %7B'sections': %5B%5D%7D%7D%0A        submit_comment(body)%0A        query_set.create.assert_called_with(body=json.dumps(body))%0A

Add unit tests for the submit_comment task