Skip to content

Commit dd9588e

Browse files
add unit test to ensure all fields are exported
1 parent 2328072 commit dd9588e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test_elasticsearch/test_dsl/test_field.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import pytest
2424
from dateutil import tz
2525

26+
from elasticsearch import dsl
2627
from elasticsearch.dsl import InnerDoc, Range, ValidationException, field
2728

2829

@@ -232,3 +233,19 @@ class Inner(InnerDoc):
232233

233234
with pytest.raises(ValidationException):
234235
field.Object(doc_class=Inner, dynamic=False)
236+
237+
238+
def test_all_fields_exported() -> None:
239+
"""Make sure that all the generated field classes are exported at the top-level"""
240+
fields = [
241+
f
242+
for f in dir(field)
243+
if isinstance(getattr(field, f), type)
244+
and issubclass(getattr(field, f), field.Field)
245+
]
246+
all = dir(dsl)
247+
not_found = []
248+
for f in fields:
249+
if f not in all:
250+
not_found.append(f)
251+
assert not_found == []

0 commit comments

Comments
 (0)