shivaam commented on code in PR #72046: URL: https://github.com/apache/airflow/pull/72046#discussion_r3997446607
########## task-sdk/tests/task_sdk/coordinators/node/test_bundle_reader.py: ########## @@ -0,0 +1,417 @@ +# +# 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 base64 +import io +import json +import os +import pathlib +from unittest import mock + +import pytest +from task_sdk.coordinators.node._bundle_test_utils import ( + METADATA_PREFIX, + OFFSET_WIDTH, + SCHEMA_VERSION, + metadata_json as _metadata_json, + mutate_byte as _mutate_byte, + read_layout as _read_layout, + replace_layout_payload as _replace_layout_payload, + rewrite_layout as _rewrite_layout, + write_bundle, +) + +from airflow.sdk.coordinators.node import _bundle_reader as _reader +from airflow.sdk.coordinators.node._bundle_reader import _digest_cache, _hash_region, read_bundle + +from tests_common.test_utils.paths import AIRFLOW_ROOT_PATH + +TYPESCRIPT_V1_FIXTURE = AIRFLOW_ROOT_PATH / "ts-sdk" / "tests" / "cli" / "fixtures" / "bundle-v1.mjs" + + [email protected](autouse=True) +def clear_digest_cache(): + _digest_cache.clear() + + +class TestBundleReader: + def test_reader_returns_verified_bundle_metadata(self): + metadata = read_bundle(TYPESCRIPT_V1_FIXTURE) + + assert metadata.dag_ids == frozenset({"test_dag"}) + assert metadata.supervisor_schema_version == SCHEMA_VERSION + + def test_reads_bundle_produced_by_typescript_encoder(self, tmp_path): + bundle = tmp_path / "bundle.mjs" + bundle.write_bytes(TYPESCRIPT_V1_FIXTURE.read_bytes()) + + metadata = read_bundle(bundle) + + assert metadata.dag_ids == frozenset({"test_dag"}) + assert metadata.supervisor_schema_version == SCHEMA_VERSION Review Comment: Combined the tests -- 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]
