From ef2b47264d0b40467ceb559794b643a709f51fdc Mon Sep 17 00:00:00 2001 From: GUAN MING Date: Sun, 11 May 2025 19:34:02 +0800 Subject: [PATCH] Use `pytest.param.id` in connection, pool, and variable bulk tests --- .../routes/public/test_connections.py | 44 +++++++------- .../core_api/routes/public/test_pools.py | 60 +++++++++---------- .../core_api/routes/public/test_variables.py | 60 +++++++++---------- 3 files changed, 82 insertions(+), 82 deletions(-) diff --git a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_connections.py b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_connections.py index 502621169dbc4..6ddf188935249 100644 --- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_connections.py +++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_connections.py @@ -921,8 +921,7 @@ class TestBulkConnections(TestConnectionEndpoint): @pytest.mark.parametrize( "actions, expected_results", [ - # Test successful create - ( + pytest.param( { "actions": [ { @@ -943,9 +942,9 @@ class TestBulkConnections(TestConnectionEndpoint): "errors": [], } }, + id="test_successful_create", ), - # Test successful create with skip - ( + pytest.param( { "actions": [ { @@ -970,9 +969,9 @@ class TestBulkConnections(TestConnectionEndpoint): "errors": [], } }, + id="test_successful_create_with_skip", ), - # Test create with overwrite - ( + pytest.param( { "actions": [ { @@ -994,9 +993,9 @@ class TestBulkConnections(TestConnectionEndpoint): "errors": [], } }, + id="test_create_with_overwrite", ), - # Test create conflict - ( + pytest.param( { "actions": [ { @@ -1026,9 +1025,9 @@ class TestBulkConnections(TestConnectionEndpoint): ], } }, + id="test_create_conflict", ), - # Test successful update - ( + pytest.param( { "actions": [ { @@ -1050,9 +1049,9 @@ class TestBulkConnections(TestConnectionEndpoint): "errors": [], } }, + id="test_successful_update", ), - # Test update with skip - ( + pytest.param( { "actions": [ { @@ -1073,9 +1072,9 @@ class TestBulkConnections(TestConnectionEndpoint): "errors": [], } }, + id="test_update_with_skip", ), - # Test update with fail - ( + pytest.param( { "actions": [ { @@ -1101,9 +1100,9 @@ class TestBulkConnections(TestConnectionEndpoint): ], } }, + id="test_update_with_fail", ), - # Test successful delete - ( + pytest.param( { "actions": [ { @@ -1118,9 +1117,9 @@ class TestBulkConnections(TestConnectionEndpoint): "errors": [], } }, + id="test_successful_delete", ), - # Test delete with skip - ( + pytest.param( { "actions": [ { @@ -1136,9 +1135,9 @@ class TestBulkConnections(TestConnectionEndpoint): "errors": [], } }, + id="test_delete_with_skip", ), - # Test delete not found - ( + pytest.param( { "actions": [ { @@ -1159,9 +1158,9 @@ class TestBulkConnections(TestConnectionEndpoint): ], } }, + id="test_delete_not_found", ), - # Test Create, Update, Delete - ( + pytest.param( { "actions": [ { @@ -1206,6 +1205,7 @@ class TestBulkConnections(TestConnectionEndpoint): "errors": [], }, }, + id="test_create_update_delete", ), ], ) diff --git a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_pools.py b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_pools.py index fb27a1f4c911d..8f6ed1a7019be 100644 --- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_pools.py +++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_pools.py @@ -427,8 +427,7 @@ class TestBulkPools(TestPoolsEndpoint): @pytest.mark.parametrize( "actions, expected_results", [ - # Test successful create - ( + pytest.param( { "actions": [ { @@ -442,9 +441,9 @@ class TestBulkPools(TestPoolsEndpoint): ] }, {"create": {"success": ["pool3", "pool4"], "errors": []}}, + id="test_successful_create", ), - # Test successful create with skip - ( + pytest.param( { "actions": [ { @@ -458,9 +457,9 @@ class TestBulkPools(TestPoolsEndpoint): ] }, {"create": {"success": ["pool3"], "errors": []}}, + id="test_successful_create_with_skip", ), - # Test successful create with overwrite - ( + pytest.param( { "actions": [ { @@ -474,9 +473,9 @@ class TestBulkPools(TestPoolsEndpoint): ] }, {"create": {"success": ["pool3", "pool2"], "errors": []}}, + id="test_successful_create_with_overwrite", ), - # Test create conflict - ( + pytest.param( { "actions": [ { @@ -497,9 +496,9 @@ class TestBulkPools(TestPoolsEndpoint): ], } }, + id="test_create_conflict", ), - # Test successful update - ( + pytest.param( { "actions": [ { @@ -510,9 +509,9 @@ class TestBulkPools(TestPoolsEndpoint): ] }, {"update": {"success": ["pool2"], "errors": []}}, + id="test_successful_update", ), - # Test update with skip - ( + pytest.param( { "actions": [ { @@ -523,9 +522,9 @@ class TestBulkPools(TestPoolsEndpoint): ] }, {"update": {"success": [], "errors": []}}, + id="test_update_with_skip", ), - # Test update not found - ( + pytest.param( { "actions": [ { @@ -546,19 +545,19 @@ class TestBulkPools(TestPoolsEndpoint): ], } }, + id="test_update_not_found", ), - # Test successful delete - ( + pytest.param( {"actions": [{"action": "delete", "entities": ["pool1"], "action_on_non_existence": "skip"}]}, {"delete": {"success": ["pool1"], "errors": []}}, + id="test_successful_delete", ), - # Test delete with skip - ( + pytest.param( {"actions": [{"action": "delete", "entities": ["pool3"], "action_on_non_existence": "skip"}]}, {"delete": {"success": [], "errors": []}}, + id="test_delete_with_skip", ), - # Test delete not found - ( + pytest.param( {"actions": [{"action": "delete", "entities": ["pool4"], "action_on_non_existence": "fail"}]}, { "delete": { @@ -571,9 +570,9 @@ class TestBulkPools(TestPoolsEndpoint): ], } }, + id="test_delete_not_found", ), - # Test Create, Update, and Delete combined - ( + pytest.param( { "actions": [ { @@ -594,9 +593,9 @@ class TestBulkPools(TestPoolsEndpoint): "update": {"success": ["pool1"], "errors": []}, "delete": {"success": ["pool2"], "errors": []}, }, + id="test_create_update_delete", ), - # Test Fail on conflicting create and handle others - ( + pytest.param( { "actions": [ { @@ -625,9 +624,9 @@ class TestBulkPools(TestPoolsEndpoint): "update": {"success": ["pool1"], "errors": []}, "delete": {"success": [], "errors": []}, }, + id="test_create_update_delete_with_fail", ), - # Test all skipping actions - ( + pytest.param( { "actions": [ { @@ -648,9 +647,9 @@ class TestBulkPools(TestPoolsEndpoint): "update": {"success": [], "errors": []}, "delete": {"success": [], "errors": []}, }, + id="test_create_update_delete_with_skip", ), - # Test Dependent actions - ( + pytest.param( { "actions": [ { @@ -673,9 +672,9 @@ class TestBulkPools(TestPoolsEndpoint): "update": {"success": ["pool5"], "errors": []}, "delete": {"success": ["pool5"], "errors": []}, }, + id="test_dependent_actions", ), - # Test Repeated actions - ( + pytest.param( { "actions": [ { @@ -748,6 +747,7 @@ class TestBulkPools(TestPoolsEndpoint): }, "delete": {"success": ["pool2"], "errors": []}, }, + id="test_repeated_actions", ), ], ) diff --git a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_variables.py b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_variables.py index e6c359a3eb8e0..fd235b9758edf 100644 --- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_variables.py +++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_variables.py @@ -502,8 +502,7 @@ class TestBulkVariables(TestVariableEndpoint): @pytest.mark.parametrize( "actions, expected_results", [ - # Test successful create - ( + pytest.param( { "actions": [ { @@ -517,9 +516,9 @@ class TestBulkVariables(TestVariableEndpoint): ] }, {"create": {"success": ["new_var1", "new_var2"], "errors": []}}, + id="test_successful_create", ), - # Test successful create with skip - ( + pytest.param( { "actions": [ { @@ -537,9 +536,9 @@ class TestBulkVariables(TestVariableEndpoint): ] }, {"create": {"success": ["new_var2"], "errors": []}}, + id="test_successful_create_with_skip", ), - # Test successful create with overwrite - ( + pytest.param( { "actions": [ { @@ -557,9 +556,9 @@ class TestBulkVariables(TestVariableEndpoint): ] }, {"create": {"success": ["test_variable_key", "new_var2"], "errors": []}}, + id="test_successful_create_with_overwrite", ), - # Test create conflict - ( + pytest.param( { "actions": [ { @@ -586,9 +585,9 @@ class TestBulkVariables(TestVariableEndpoint): ], } }, + id="test_create_conflict", ), - # Test successful update - ( + pytest.param( { "actions": [ { @@ -605,9 +604,9 @@ class TestBulkVariables(TestVariableEndpoint): ] }, {"update": {"success": ["test_variable_key"], "errors": []}}, + id="test_successful_update", ), - # Test update with skip - ( + pytest.param( { "actions": [ { @@ -624,9 +623,9 @@ class TestBulkVariables(TestVariableEndpoint): ] }, {"update": {"success": [], "errors": []}}, + id="test_update_with_skip", ), - # Test update not found - ( + pytest.param( { "actions": [ { @@ -653,9 +652,9 @@ class TestBulkVariables(TestVariableEndpoint): ], } }, + id="test_update_not_found", ), - # Test successful delete - ( + pytest.param( { "actions": [ { @@ -666,9 +665,9 @@ class TestBulkVariables(TestVariableEndpoint): ] }, {"delete": {"success": ["test_variable_key"], "errors": []}}, + id="test_successful_delete", ), - # Test delete with skip - ( + pytest.param( { "actions": [ { @@ -679,9 +678,9 @@ class TestBulkVariables(TestVariableEndpoint): ] }, {"delete": {"success": [], "errors": []}}, + id="test_delete_with_skip", ), - # Test delete not found - ( + pytest.param( { "actions": [ { @@ -702,9 +701,9 @@ class TestBulkVariables(TestVariableEndpoint): ], } }, + id="test_delete_not_found", ), - # Test Create, Update, and Delete combined - ( + pytest.param( { "actions": [ { @@ -744,9 +743,9 @@ class TestBulkVariables(TestVariableEndpoint): "update": {"success": ["test_variable_key"], "errors": []}, "delete": {"success": ["dictionary_password"], "errors": []}, }, + id="test_create_update_delete_combined", ), - # Test Fail on conflicting create and handle others - ( + pytest.param( { "actions": [ { @@ -791,9 +790,9 @@ class TestBulkVariables(TestVariableEndpoint): "update": {"success": ["dictionary_password"], "errors": []}, "delete": {"success": [], "errors": []}, }, + id="test_fail_on_conflicting_create_and_handle_others", ), - # Test all skipping actions - ( + pytest.param( { "actions": [ { @@ -830,9 +829,9 @@ class TestBulkVariables(TestVariableEndpoint): "update": {"success": [], "errors": []}, "delete": {"success": [], "errors": []}, }, + id="test_all_skipping_actions", ), - # Test Dependent actions - ( + pytest.param( { "actions": [ { @@ -869,9 +868,9 @@ class TestBulkVariables(TestVariableEndpoint): "update": {"success": ["new_variable_key"], "errors": []}, "delete": {"success": ["new_variable_key"], "errors": []}, }, + id="test_dependent_actions", ), - # Test Repeated actions - ( + pytest.param( { "actions": [ { @@ -972,6 +971,7 @@ class TestBulkVariables(TestVariableEndpoint): }, "delete": {"success": ["dictionary_password"], "errors": []}, }, + id="test_repeated_actions", ), ], )