Skip to content

Commit

Permalink
Adding lucine compliance unit test for development
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-moessner committed Sep 27, 2024
1 parent 76d1678 commit e149a02
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/unit/filter/test_lucene_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,30 @@ def test_create_filter_success(self, testcase, input_str, cleaned_str):
def test_create_filter_error(self, testcase, input_str, message):
with raises(LuceneFilterError, match=re.escape(message)):
LuceneFilter.create(f'foo: "{input_str}"')

def test_creates_lucene_compliance_filter_two_matching_regex_keys_of_two(self):
lucene_filter = LuceneFilter.create(
'regex_key_one: "/.*value.*/" AND regex_key_two: "/.*value.*/"',
special_fields={"regex_fields": ["regex_key_one", "regex_key_two"]},
)

a = And(
RegExFilterExpression(["regex_key_one"], ".*value.*"),
RegExFilterExpression(["regex_key_two"], ".*value.*"),
)

assert lucene_filter == And(
RegExFilterExpression(["regex_key_one"], ".*value.*"),
RegExFilterExpression(["regex_key_two"], ".*value.*"),
)

def test_creates_lucene_compliance_filter_with_one_matching_and_one_missmatching_regex_key_of_two(self):
lucene_filter = LuceneFilter.create(
'regex_key_one: ".*value.*" AND key_two: "value"',
special_fields={"regex_fields": ["regex_key_one", "i_dont_exist"]},
)

assert lucene_filter == And(
RegExFilterExpression(["regex_key_one"], ".*value.*"),
StringFilterExpression(["key_two"], "value"),
)

0 comments on commit e149a02

Please sign in to comment.