Skip to content

Commit 5bcb050

Browse files
committed
test: add unit tests for BaseEnum membership support
1 parent 17a9887 commit 5bcb050

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

test/test_str_enum.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from weaviate.str_enum import BaseEnum
2+
3+
4+
class _Color(BaseEnum):
5+
RED = "red"
6+
GREEN = "green"
7+
8+
9+
def test_member_name_string_is_contained():
10+
# `in` matches by member *name*, so the uppercase name is found.
11+
assert "RED" in _Color
12+
assert "GREEN" in _Color
13+
14+
15+
def test_unknown_string_is_not_contained():
16+
assert "PURPLE" not in _Color
17+
18+
19+
def test_member_value_string_is_not_a_membership_match():
20+
# The lowercase *value* is not a member name, so it is not contained.
21+
assert "red" not in _Color
22+
23+
24+
def test_enum_member_is_contained():
25+
assert _Color.RED in _Color
26+
27+
28+
def test_non_string_non_member_is_not_contained():
29+
# A non-string that lacks a ``.name`` falls back to the string check
30+
# and is therefore not contained.
31+
assert 12345 not in _Color

0 commit comments

Comments
 (0)