Example #1
0
 def parse_json_body__invalid_encoding(self) -> None:
     response = FakeResponse(
         "200 OK", [("Content-Type", "application/json; charset=utf-8")]
     )
     response.body = '{"föo": 5}'.encode("iso-8859-1")
     with assert_raises(AssertionError):
         response.parse_json_body()
Example #2
0
 def parse_json_body__invalid_json(self) -> None:
     response = FakeResponse(
         "200 OK", [("Content-Type", "application/json")]
     )
     response.body = b'{"foo":'
     with assert_raises(AssertionError):
         response.parse_json_body()
Example #3
0
 def parse_json_body__wrong_content_encoding(self) -> None:
     response = FakeResponse(
         "200 OK", [("Content-Type", "application/json; charset=latin1")]
     )
     response.body = b"{}"
     with assert_raises(AssertionError):
         response.parse_json_body()
Example #4
0
 def parse_json_body(self) -> None:
     response = FakeResponse(
         "200 OK", [("Content-Type", "application/json")]
     )
     response.body = b'{"foo": 5}'
     json = response.parse_json_body()
     assert_equal({"foo": 5}, json)
Example #5
0
 def parse_json_body__wrong_content_type(self) -> None:
     response = FakeResponse("200 OK", [("Content-Type", "text/plain")])
     response.body = b"{}"
     with assert_raises(AssertionError):
         response.parse_json_body()