Skip to content

Commit d603e6c

Browse files
authored
fix: add __call__ to MockOptional for WTForms validator compatibility (apache#63823)
Closes: apache#63803
1 parent 51e4316 commit d603e6c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

airflow-core/src/airflow/api_fastapi/core_api/services/ui/connections.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def __init__(
4848
):
4949
pass
5050

51+
def __call__(self, form, field):
52+
pass
53+
5154
class MockEnum:
5255
"""Mock for wtforms.validators.Optional."""
5356

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
from airflow.api_fastapi.core_api.services.ui.connections import HookMetaService
20+
21+
22+
class TestMockOptional:
23+
def test_mock_optional_is_callable(self):
24+
"""MockOptional instances must be callable to satisfy WTForms validator checks."""
25+
validator = HookMetaService.MockOptional()
26+
assert callable(validator)
27+
28+
def test_mock_optional_call_is_noop(self):
29+
"""Calling MockOptional should be a no-op (returns None)."""
30+
validator = HookMetaService.MockOptional()
31+
result = validator(None, None)
32+
assert result is None

0 commit comments

Comments
 (0)