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(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)
示例#2
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(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)
示例#3
0
    def _build_and_run_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",
                                         REMOTE_ADDR="1.2.3.4",
                                         SERVER_NAME="test_server")
        req.user = user
        return views.submit_feedback(req)
    def _build_and_run_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",
            REMOTE_ADDR="1.2.3.4",
            SERVER_NAME="test_server",
        )
        req.user = user
        return views.submit_feedback(req)
    def _build_and_run_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_REQUEST_HEADERS["HTTP_REFERER"],
            HTTP_USER_AGENT=TEST_REQUEST_HEADERS["HTTP_USER_AGENT"],
            REMOTE_ADDR=TEST_REQUEST_HEADERS["REMOTE_ADDR"],
            SERVER_NAME=TEST_REQUEST_HEADERS["SERVER_NAME"],
        )
        req.user = user
        return views.submit_feedback(req)