-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_autocomplete.py
More file actions
37 lines (32 loc) · 918 Bytes
/
Copy pathtest_autocomplete.py
File metadata and controls
37 lines (32 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pytest
from monggregate.search.operators.autocomplete import Autocomplete
from monggregate.search.commons import FuzzyOptions
def test_autocomplete_expression():
# Setup
query = "test"
path = "field"
fuzzy_options = FuzzyOptions(maxEdits=1, prefixLength=1, maxExpansions=10)
autocomplete = Autocomplete(
query=query,
path=path,
token_order="any",
fuzzy=fuzzy_options,
score={"boost": 2}
)
expected_expression = {
"autocomplete": {
"query": query,
"path": path,
"tokenOrder": "any",
"fuzzy": {
"maxEdits": 1,
"prefixLength": 1,
"maxExpansions": 10
},
"score": {"boost": 2}
}
}
# Act
actual_expression = autocomplete.expression
# Assert
assert actual_expression == expected_expression