You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Taragolis (via GitHub)" <gi...@apache.org> on 2023/02/09 22:58:28 UTC

[GitHub] [airflow] Taragolis commented on a diff in pull request #29447: Remove non-public interface usage in EcsRunTaskOperator

Taragolis commented on code in PR #29447:
URL: https://github.com/apache/airflow/pull/29447#discussion_r1102108095


##########
tests/providers/amazon/aws/utils/test_identifiers.py:
##########
@@ -0,0 +1,74 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import random
+import string
+import uuid
+
+import pytest
+
+from airflow.providers.amazon.aws.utils.identifiers import generate_uuid
+from airflow.utils.types import NOTSET
+
+
+class TestGenerateUuid:
+    @pytest.fixture(
+        autouse=True,
+        params=[
+            pytest.param(NOTSET, id="default-namespace"),
+            pytest.param(uuid.UUID(int=42), id="custom-namespace"),
+        ],
+    )
+    def setup_namespace(self, request):
+        self.default_namespace = request.param is NOTSET
+        self.namespace = uuid.NAMESPACE_OID if self.default_namespace else request.param
+        self.kwargs = {"namespace": self.namespace} if not self.default_namespace else {}
+
+    def test_deterministic(self):
+        """Test that result deterministic and valid UUID object"""
+        args = [
+            "".join(random.choice(string.ascii_letters) for _ in range(random.randint(3, 13)))
+            for _ in range(100)
+        ]

Review Comment:
   That the basically a problem with any hashing algorithm and testing that.
   This case mostly for catch some changes in logic when two run with the same value could return different result (I hope it never happen).
   
   So static values here would be "foo", "bar", "spam", "egg", "airflow"



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org