Example #1
0
 def test_get_request(self, zendesk_mock_class):
     """Test that a GET results in a 405 even with all required fields"""
     req = self._request_factory.get("/submit_feedback", data=self._anon_fields)
     req.user = self._anon_user
     resp = views.submit_feedback_via_zendesk(req)
     self.assertEqual(resp.status_code, 405)
     self.assertIn("Allow", resp)
     self.assertEqual(resp["Allow"], "POST")
     # There should be absolutely no interaction with Zendesk
     self.assertFalse(zendesk_mock_class.mock_calls)
Example #2
0
    def _test_request(self, user, fields):
        """
        Generate a request and invoke the view, returning the response.

        The request will be a POST request from the given `user`, with the given
        `fields` in the POST body.
        """
        req = self._request_factory.post(
            "/submit_feedback",
            data=fields,
            HTTP_REFERER="test_referer",
            HTTP_USER_AGENT="test_user_agent"
        )
        req.user = user
        return views.submit_feedback_via_zendesk(req)