Пример #1
0
 def test_page_handler_is_called_for_json(self, *_):
     """Assert page handler is called when json without a task."""
     response = Response()
     response.status_code = 201
     response._content = b'{"foo": "1234"}'
     response.headers["Content-Type"] = "application/json"
     with mock.patch.object(api, "page_handler", lambda *_: "page_handler_called"):
         self.assertEqual(api.smart_handler(self.client, response), "page_handler_called")
Пример #2
0
 def test_task_handler_is_called_for_tasks(self, *_):
     """Assert task handler is called when 202 with task is response."""
     response = Response()
     response.status_code = 202
     response._content = b'{"task": "1234"}'
     response.headers["Content-Type"] = "application/json"
     with mock.patch.object(api, "task_handler", lambda *_: "task_handler_called"):
         self.assertEqual(api.smart_handler(self.client, response), "task_handler_called")
Пример #3
0
 def test_return_bare_response_when_not_json(self, *_):
     """Assert the passed-in ``response`` is returned."""
     response = Response()
     response.headers["Content-Type"] = "text/html"
     self.assertIs(response, api.smart_handler(self.client, response))
Пример #4
0
 def test_return_bare_response_when_pulp_2(self, *_):
     """Assert the passed-in ``response`` is returned if pulp is 2."""
     response = Response()
     client = api.Client(_get_pulp_smash_config(pulp_version="2.19"))
     self.assertIs(response, api.smart_handler(client, response))