|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | +from __future__ import annotations |
| 18 | + |
| 19 | +import sys |
| 20 | + |
| 21 | + |
| 22 | +class TestExceptions: |
| 23 | + def setup_method(self): |
| 24 | + self.old_modules = dict(sys.modules) |
| 25 | + |
| 26 | + def teardown_method(self): |
| 27 | + # Remove any new modules imported during the test run. This lets us |
| 28 | + # import the same source files for more than one test. |
| 29 | + for mod in [m for m in sys.modules if m not in self.old_modules]: |
| 30 | + del sys.modules[mod] |
| 31 | + |
| 32 | + def test_pod_mutation_hook_exceptions_compatibility( |
| 33 | + self, |
| 34 | + ): |
| 35 | + from airflow.exceptions import ( |
| 36 | + PodMutationHookException as CoreMutationHookException, |
| 37 | + ) |
| 38 | + from airflow.providers.cncf.kubernetes.exceptions import ( |
| 39 | + PodMutationHookException as ProviderMutationHookException, |
| 40 | + ) |
| 41 | + from airflow.providers.cncf.kubernetes.pod_generator import ( |
| 42 | + PodMutationHookException as ProviderGeneratorMutationHookException, |
| 43 | + ) |
| 44 | + |
| 45 | + assert ProviderMutationHookException == CoreMutationHookException |
| 46 | + assert ProviderMutationHookException == ProviderGeneratorMutationHookException |
| 47 | + |
| 48 | + def test_pod_reconciliation_error_exceptions_compatibility( |
| 49 | + self, |
| 50 | + ): |
| 51 | + from airflow.exceptions import ( |
| 52 | + PodReconciliationError as CoreReconciliationError, |
| 53 | + ) |
| 54 | + from airflow.providers.cncf.kubernetes.exceptions import ( |
| 55 | + PodReconciliationError as ProviderReconciliationError, |
| 56 | + ) |
| 57 | + from airflow.providers.cncf.kubernetes.pod_generator import ( |
| 58 | + PodReconciliationError as ProviderGeneratorReconciliationError, |
| 59 | + ) |
| 60 | + |
| 61 | + assert ProviderReconciliationError == CoreReconciliationError |
| 62 | + assert ProviderReconciliationError == ProviderGeneratorReconciliationError |
0 commit comments