mercredi 13 novembre 2019

How to send body to simulate_post in Falcon

def test_with_invalid_param(self):
        body = urlencode({
            "email":"jit",
            "password":"ewr"
        })
        result = self.simulate_post(self.path, body=body, headers=self.headers)
        print(result.json)
        self.assertEqual(result.status, "201 OK")

I am getting json decode error from Falcon server.

I am have implemented a middleware to decode json.

try:
                req.data = json.loads(req.stream.read().decode("utf-8"))
                return
            except:
                raise falcon.HTTPBadRequest(
                    "Bad request", "Invalid body. Unable to parse the given content"
                )

Can anyone spot what is going wrong here?

Aucun commentaire:

Enregistrer un commentaire