amoghrajesh commented on code in PR #44449:
URL: https://github.com/apache/airflow/pull/44449#discussion_r1861974672


##########
tests/api_fastapi/execution_api/routes/test_variables.py:
##########
@@ -75,3 +86,60 @@ def test_variable_get_access_denied(self, client):
                 "message": "Task does not have access to variable key1",
             }
         }
+
+
+class TestPostVariable(TestVariableEndpoint):
+    def test_should_create_variable(self, client, session):
+        payload = {"key": "var_create", "value": "{}"}
+        response = client.post(
+            "/execution/variables",
+            json=payload,
+        )
+        assert response.status_code == 200
+        response = client.get(f"/execution/variables/{payload['key']}")
+        assert response.json() == {
+            "key": "var_create",
+            "value": "{}",
+        }
+
+    @pytest.mark.parametrize(
+        "payload, status_code",
+        [
+            pytest.param(
+                {"key": "var_create", "value": "{}", "description": 
"description"}, 200, id="valid-payload"
+            ),
+            pytest.param({"value": "{}", "description": "description"}, 422, 
id="missing-key"),
+            pytest.param({"key": "var_create", "description": "description"}, 
422, id="missing-value"),
+            pytest.param({"value": "{}", "key": "var_create"}, 200, 
id="missing-description"),

Review Comment:
   Added test cases to `test_should_create_variable` instead. Good idea



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