Пример #1
0
 def test_should_render_binary_content(self, mocked__request):
     request = mocked__request()
     request.headers = {
         "Content-Length": "0",
         "Content-Type": "application/octet-stream",
     }
     request.body = b""
     assert "Binary content" == render_body(request)
Пример #2
0
 def test_should_render_json(self, mocked__request):
     request = mocked__request()
     request.headers = {
         "Content-Length": "21",
         "Content-Type": "application/json",
     }
     request.body = b'{"name": "bulbasaur"}'
     assert '{"name": "bulbasaur"}' == render_body(request)
Пример #3
0
 def test_should_render_plain_text(self, mocked__request):
     request = mocked__request()
     request.headers = {
         "Content-Length": "27",
         "Content-Type": "text/plain",
     }
     request.body = b"this is a custom plain text"
     assert "this is a custom plain text" == render_body(request)
Пример #4
0
 def test_should_not_render_unsuported_content_type(self, mocked__request):
     request = mocked__request()
     request.headers = {
         "Content-Length": "0",
         "Content-Type": "application/octet-stream",
     }
     request.body = b""
     assert (
         "Can not render. Unsuported content type: application/octet-stream."
         == render_body(request)
     )