ashb commented on code in PR #55324:
URL: https://github.com/apache/airflow/pull/55324#discussion_r2333460873


##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_variables.py:
##########
@@ -114,6 +114,46 @@ def test_variable_get_access_denied(self, client, caplog):
 
         assert any(msg.startswith("Checking read access for task instance") 
for msg in caplog.messages)
 
+    def test_variable_get_with_slash_in_key(self, client, session):
+        """Test getting variables with slashes in key names."""
+        Variable.set(key="test/with_slash", value="slash_value", 
session=session)
+        session.commit()
+
+        response = client.get("/execution/variables/test/with_slash")
+
+        assert response.status_code == 200
+        assert response.json() == {"key": "test/with_slash", "value": 
"slash_value"}
+
+        # Clean up
+        Variable.delete(key="test/with_slash", session=session)
+        session.commit()
+
+    def test_variable_get_with_multiple_slashes_in_key(self, client, session):
+        """Test getting variables with multiple slashes in key names."""
+        Variable.set(key="path/to/nested/variable", value="nested_value", 
session=session)
+        session.commit()
+
+        response = client.get("/execution/variables/path/to/nested/variable")
+
+        assert response.status_code == 200
+        assert response.json() == {"key": "path/to/nested/variable", "value": 
"nested_value"}
+
+        # Clean up
+        Variable.delete(key="path/to/nested/variable", session=session)
+        session.commit()
+
+    def test_variable_get_slash_not_found(self, client):
+        """Test getting non-existent variables with slashes in key names."""
+        response = client.get("/execution/variables/non/existent/slash/var")
+
+        assert response.status_code == 404
+        assert response.json() == {
+            "detail": {
+                "message": "Variable with key 'non/existent/slash/var' not 
found",
+                "reason": "not_found",
+            }
+        }

Review Comment:
   Three extra tests seem un-necessary here.
   
   Either just change the existing tests to have a slash (as we get nothing by 
testing both with a slash and without it) or make the existing tests 
parameterized.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to