piccolo-orm / piccolo_admin

A powerful web admin for your database.
https://piccolo-orm.com/ecosystem/
MIT License
322 stars 39 forks source link

Fix tests for `Starlette==0.21.0` #254

Closed dantownsend closed 2 years ago

dantownsend commented 2 years ago

A lot of the test suite has blown up with the latest version of Starlette, which uses httpx instead of requests for its test client.

We will have to fix the tests, and make starlette=0.21.0 the minimum from now on, because supporting test suites for the older versions will be a massive pain.

sinisaos commented 2 years ago

@dantownsend If you want I can try to fix the tests. I haven't worked with the new Starlette TestClient yet, so I'd like to try it.

dantownsend commented 2 years ago

@sinisaos Yes, feel free to give it a go.

The TestClient is mostly the same, but has subtle differences for cookies and how it handles redirects.

For example, when calling the /login/ endpoint, you have to use follow_redirects=False, otherwise the response you get will be the redirected one, and it won't contain the session auth cookie. I hope that makes sense.

Also, the Response.cookies object is slightly different, which can cause some issues.

sinisaos commented 2 years ago

@dantownsend OK. I will try and use the Piccolo API tests as a reference. If I didn't succeed, I will reported here.

dantownsend commented 2 years ago

Fixed by https://github.com/piccolo-orm/piccolo_admin/pull/255