ephraimbuddy commented on a change in pull request #9329:
URL: https://github.com/apache/airflow/pull/9329#discussion_r443242060
##########
File path: tests/api_connexion/endpoints/test_pool_endpoint.py
##########
@@ -136,7 +136,225 @@ def test_response_404(self):
{
"detail": None,
"status": 404,
- "title": "Pool not found",
+ "title": "Pool with name:'invalid_pool' not found",
+ "type": "about:blank",
+ },
+ response.json,
+ )
+
+
+class TestDeletePool(TestBasePoolEndpoints):
+ @provide_session
+ def test_response_204(self, session):
+ pool_name = "test_pool"
+ pool_instance = Pool(pool=pool_name, slots=3)
+ session.add(pool_instance)
+ session.commit()
+
+ response = self.client.delete(f"api/v1/pools/{pool_name}")
+ assert response.status_code == 204
+ # Check if the pool is deleted from the db
+ response = self.client.get(f"api/v1/pools/{pool_name}")
+ self.assertEqual(response.status_code, 404)
+
+ def test_response_404(self):
+ response = self.client.delete("api/v1/pools/invalid_pool")
+ self.assertEqual(response.status_code, 404)
+ self.assertEqual(
+ {
+ "detail": None,
+ "status": 404,
+ "title": "Pool with name:'invalid_pool' not found",
+ "type": "about:blank",
+ },
+ response.json,
+ )
+
+
+class TestPostPool(TestBasePoolEndpoints):
+ def test_response_200(self):
+ response = self.client.post(
+ "api/v1/pools", json={"name": "test_pool_a", "slots": 3}
+ )
+ assert response.status_code == 200
+ self.assertEqual(
+ {
+ "name": "test_pool_a",
+ "slots": 3,
+ "occupied_slots": 0,
+ "running_slots": 0,
+ "queued_slots": 0,
+ "open_slots": 3,
+ },
+ response.json,
+ )
+
+ @provide_session
+ def test_response_409(self, session):
+ pool_name = "test_pool_a"
+ pool_instance = Pool(pool=pool_name, slots=3)
+ session.add(pool_instance)
+ session.commit()
+ response = self.client.post(
+ "api/v1/pools", json={"name": "test_pool_a", "slots": 3}
+ )
+ assert response.status_code == 409
+ self.assertEqual(
+ {
+ "detail": None,
+ "status": 409,
+ "title": f"Pool: {pool_name} already exists",
+ "type": "about:blank",
+ },
+ response.json,
+ )
+
+ @parameterized.expand(
+ [
+ ("for missing pool name", {"slots": 3}, "name"),
+ ("for missing slots", {"name": "invalid_pool"}, "slots"),
+ ]
+ )
+ def test_response_400(self, name, request_json, missing_field):
+ del name
+ response = self.client.post("api/v1/pools", json=request_json)
+ assert response.status_code == 400
+ self.assertEqual(
+ {
+ "detail": f"'{missing_field}' is a required property",
+ "status": 400,
+ "title": "Bad Request",
+ "type": "about:blank",
+ },
+ response.json,
+ )
+
+
+class TestPatchPool(TestBasePoolEndpoints):
Review comment:
I actually mean to exclude name on your patch method test. That is, to
have the payload go with only slots. {"slots":3}.
Name is already on the path, the normal thing is that it shouldn't be on the
payload.
That's what most users would expect
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]