Repository: piccolo-orm/piccolo_admin (language: python)

Issue:
Fix tests for `Starlette==0.21.0`
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.


Discussion / hints:
@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.
@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.
@dantownsend OK. I will try and use the Piccolo API tests as a reference. If I didn't succeed, I will reported here.

Fix patch:
diff --git a/requirements/requirements.txt b/requirements/requirements.txt
index d3102977..5779fb01 100644
--- a/requirements/requirements.txt
+++ b/requirements/requirements.txt
@@ -4,4 +4,4 @@ uvicorn
 aiofiles>=0.5.0
 Hypercorn
 targ>=0.1.9
-fastapi>=0.62.0
+fastapi>=0.87.0


Test patch:
diff --git a/requirements/test-requirements.txt b/requirements/test-requirements.txt
index 0693fa2d..4623fdf8 100644
--- a/requirements/test-requirements.txt
+++ b/requirements/test-requirements.txt
@@ -2,5 +2,5 @@ pytest==7.1.3
 pytest-cov==3.0.0
 flake8==4.0.1
 piccolo[postgres,sqlite]>=0.30.0
-requests==2.27.1
 pytest-playwright==0.3.0
+httpx>=0.20.0
diff --git a/tests/test_endpoints.py b/tests/test_endpoints.py
index 60af10e8..0c500b61 100644
--- a/tests/test_endpoints.py
+++ b/tests/test_endpoints.py
@@ -456,7 +456,7 @@ def test_store_file_read_only(self):
         response = client.post(
             "/api/media/",
             data={"table_name": "movie", "column_name": "poster"},
-            files={"file": ("bulb.jpg", "file", "image/jpeg")},
+            files={"file": ("bulb.jpg", b"file", "image/jpeg")},
             headers={"X-CSRFToken": csrftoken},
         )
         self.assertEqual(response.status_code, 405)