Skip to content

Commit

Permalink
minor FastAPI tests fixes (apache#44429)
Browse files Browse the repository at this point in the history
* fix dag_run test

* fix trailing / from tests

* revert comments

* Update tests/api_fastapi/core_api/routes/public/test_plugins.py
  • Loading branch information
rawwar authored Nov 27, 2024
1 parent 43adccf commit cba9f7a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions tests/api_fastapi/core_api/routes/public/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ def test_get_config(self, test_client, section, headers, expected_status_code, e
query_params = {"section": section} if section else None
if expected_status_code == 403:
with conf_vars(AIRFLOW_CONFIG_DISABLE_EXPOSE_CONFIG):
response = test_client.get("/public/config/", headers=headers, params=query_params)
response = test_client.get("/public/config", headers=headers, params=query_params)
else:
response = test_client.get("/public/config/", headers=headers, params=query_params)
response = test_client.get("/public/config", headers=headers, params=query_params)
self._validate_response(headers, expected_response, expected_status_code, response)

@pytest.mark.parametrize(
Expand Down Expand Up @@ -300,7 +300,7 @@ def test_get_config_non_sensitive_only(
self, test_client, headers, expected_status_code, expected_response
):
with conf_vars(AIRFLOW_CONFIG_NON_SENSITIVE_ONLY_CONFIG):
response = test_client.get("/public/config/", headers=headers)
response = test_client.get("/public/config", headers=headers)
self._validate_response(headers, expected_response, expected_status_code, response)


Expand Down
12 changes: 6 additions & 6 deletions tests/api_fastapi/core_api/routes/public/test_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_should_respond_200(
self, test_client, session, query_params, expected_total_entries, expected_ids
):
self.create_connections()
response = test_client.get("/public/connections/", params=query_params)
response = test_client.get("/public/connections", params=query_params)
assert response.status_code == 200

body = response.json()
Expand Down Expand Up @@ -200,7 +200,7 @@ class TestPostConnection(TestConnectionEndpoint):
],
)
def test_post_should_respond_200(self, test_client, session, body):
response = test_client.post("/public/connections/", json=body)
response = test_client.post("/public/connections", json=body)
assert response.status_code == 201
connection = session.query(Connection).all()
assert len(connection) == 1
Expand All @@ -215,7 +215,7 @@ def test_post_should_respond_200(self, test_client, session, body):
],
)
def test_post_should_respond_400_for_invalid_conn_id(self, test_client, body):
response = test_client.post("/public/connections/", json=body)
response = test_client.post("/public/connections", json=body)
assert response.status_code == 400
connection_id = body["connection_id"]
assert response.json() == {
Expand All @@ -230,10 +230,10 @@ def test_post_should_respond_400_for_invalid_conn_id(self, test_client, body):
],
)
def test_post_should_respond_already_exist(self, test_client, body):
response = test_client.post("/public/connections/", json=body)
response = test_client.post("/public/connections", json=body)
assert response.status_code == 201
# Another request
response = test_client.post("/public/connections/", json=body)
response = test_client.post("/public/connections", json=body)
assert response.status_code == 409
assert response.json() == {
"detail": f"Connection with connection_id: `{TEST_CONN_ID}` already exists",
Expand Down Expand Up @@ -293,7 +293,7 @@ def test_post_should_respond_already_exist(self, test_client, body):
],
)
def test_post_should_response_201_redacted_password(self, test_client, body, expected_response):
response = test_client.post("/public/connections/", json=body)
response = test_client.post("/public/connections", json=body)
assert response.status_code == 201
assert response.json() == expected_response

Expand Down
2 changes: 1 addition & 1 deletion tests/api_fastapi/core_api/routes/public/test_dag_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def test_limit_and_offset(self, test_client, post_body, expected_dag_id_order):
],
),
(
{"page_limit": -1, "offset": 1},
{"page_limit": -1, "page_offset": 1},
[
{
"type": "greater_than_equal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class TestGetEventLogs(TestEventLogsEndpoint):
def test_get_event_logs(
self, test_client, query_params, expected_status_code, expected_total_entries, expected_events
):
response = test_client.get("/public/eventLogs/", params=query_params)
response = test_client.get("/public/eventLogs", params=query_params)
assert response.status_code == expected_status_code
if expected_status_code != 200:
return
Expand Down
2 changes: 1 addition & 1 deletion tests/api_fastapi/core_api/routes/public/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TestGetConnections:
def test_should_respond_200(
self, test_client, session, query_params, expected_total_entries, expected_names
):
response = test_client.get("/public/plugins/", params=query_params)
response = test_client.get("/public/plugins", params=query_params)
assert response.status_code == 200

body = response.json()
Expand Down
8 changes: 4 additions & 4 deletions tests/api_fastapi/core_api/routes/public/test_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_should_respond_200(
self, test_client, session, query_params, expected_total_entries, expected_ids
):
self.create_pools()
response = test_client.get("/public/pools/", params=query_params)
response = test_client.get("/public/pools", params=query_params)
assert response.status_code == 200

body = response.json()
Expand Down Expand Up @@ -324,7 +324,7 @@ class TestPostPool(TestPoolsEndpoint):
def test_should_respond_200(self, test_client, session, body, expected_status_code, expected_response):
self.create_pools()
n_pools = session.query(Pool).count()
response = test_client.post("/public/pools/", json=body)
response = test_client.post("/public/pools", json=body)
assert response.status_code == expected_status_code

assert response.json() == expected_response
Expand Down Expand Up @@ -365,11 +365,11 @@ def test_should_response_409(
):
self.create_pools()
n_pools = session.query(Pool).count()
response = test_client.post("/public/pools/", json=body)
response = test_client.post("/public/pools", json=body)
assert response.status_code == first_expected_status_code
assert response.json() == first_expected_response
assert session.query(Pool).count() == n_pools + 1
response = test_client.post("/public/pools/", json=body)
response = test_client.post("/public/pools", json=body)
assert response.status_code == second_expected_status_code
assert response.json() == second_expected_response
assert session.query(Pool).count() == n_pools + 1
Expand Down
4 changes: 2 additions & 2 deletions tests/api_fastapi/core_api/routes/public/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_should_respond_200(
self, session, test_client, query_params, expected_total_entries, expected_keys
):
self.create_variables()
response = test_client.get("/public/variables/", params=query_params)
response = test_client.get("/public/variables", params=query_params)

assert response.status_code == 200
body = response.json()
Expand Down Expand Up @@ -298,6 +298,6 @@ class TestPostVariable(TestVariableEndpoint):
)
def test_post_should_respond_201(self, test_client, session, body, expected_response):
self.create_variables()
response = test_client.post("/public/variables/", json=body)
response = test_client.post("/public/variables", json=body)
assert response.status_code == 201
assert response.json() == expected_response

0 comments on commit cba9f7a

Please sign in to comment.