pierrejeambrun commented on code in PR #43083:
URL: https://github.com/apache/airflow/pull/43083#discussion_r1803291940


##########
tests/api_fastapi/core_api/routes/public/test_variables.py:
##########
@@ -136,6 +136,34 @@ def test_get_should_respond_404(self, test_client):
         assert f"The Variable with key: `{TEST_VARIABLE_KEY}` was not found" 
== body["detail"]
 
 
+class TestGetVariables(TestVariableEndpoint):
+    @pytest.mark.enable_redact
+    @pytest.mark.parametrize(
+        "query_params, expected_total_entries, expected_keys",
+        [
+            # Filters
+            ({}, 3, [TEST_VARIABLE_KEY, TEST_VARIABLE_KEY2, 
TEST_VARIABLE_KEY3]),
+            ({"limit": 1}, 3, [TEST_VARIABLE_KEY]),
+            ({"limit": 1, "offset": 1}, 3, [TEST_VARIABLE_KEY2]),
+            # Sort
+            ({"order_by": "id"}, 3, [TEST_VARIABLE_KEY, TEST_VARIABLE_KEY2, 
TEST_VARIABLE_KEY3]),
+            ({"order_by": "-id"}, 3, [TEST_VARIABLE_KEY3, TEST_VARIABLE_KEY2, 
TEST_VARIABLE_KEY]),
+            ({"order_by": "key"}, 3, [TEST_VARIABLE_KEY3, TEST_VARIABLE_KEY2, 
TEST_VARIABLE_KEY]),
+            ({"order_by": "-key"}, 3, [TEST_VARIABLE_KEY, TEST_VARIABLE_KEY2, 
TEST_VARIABLE_KEY3]),

Review Comment:
   I scratched my head here for a while. I didn't test `-value` and `value` 
because it appears that the ordering is operating on the encoded value in the 
db (with the fernet key), and not with the original value.
   
   This does not appear to be the case when I run the server locally and test 
manually, just in tests, which I find really weird.
   
   If it really order on the encoded fernet key value then this sort doesn't 
accomplish much. And on top of that the FERNET_KEY is regenerated on each test 
run, therefore the ordering is not stable.
   
   If someone has an 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