Skip to content

Commit cb71472

Browse files
committed
add basic openapi test
1 parent d0879fd commit cb71472

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

lib/collection/src/operations/verification/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl Query {
2828
format!(
2929
"Index required but not found for \"{key}\" of one of the following types: [{possible_schemas_str}]",
3030
),
31-
"Create an index for this key or use a different expression.",
31+
"Create an index for this key or use a different formula expression.",
3232
));
3333
}
3434
}

tests/openapi/test_strictmode.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,43 @@ def search_request(condition_size: int = 2):
13231323
assert not search_fail.ok
13241324

13251325

1326+
def test_strict_mode_formula_expression(collection_name):
1327+
set_strict_mode(collection_name, {
1328+
"enabled": True,
1329+
"condition_max_size": 1000000, # Disabled
1330+
"unindexed_filtering_retrieve": False,
1331+
})
1332+
1333+
def query_request():
1334+
expression = {
1335+
"sum": [
1336+
"discount_price",
1337+
"$score",
1338+
]
1339+
}
1340+
1341+
return request_with_validation(
1342+
api='/collections/{collection_name}/points/query',
1343+
method="POST",
1344+
path_params={'collection_name': collection_name},
1345+
body={
1346+
"prefetch": {
1347+
"query": [0.1, 0.2, 0.3, 0.4],
1348+
},
1349+
"query": {
1350+
"formula": expression,
1351+
"defaults": { "discount_price": 0 } # Even with default, it should still be restricted
1352+
}
1353+
}
1354+
)
1355+
1356+
query_fail = query_request()
1357+
print(query_fail.json())
1358+
assert not query_fail.ok
1359+
assert "discount_price" in query_fail.json()['status']['error']
1360+
assert "formula expression" in query_fail.json()['status']['error']
1361+
1362+
13261363
def test_strict_mode_read_rate_limiting_small_replenish(collection_name):
13271364
"""
13281365
If our read rate limit capacity is larger, test that when exhausting it
@@ -1418,4 +1455,4 @@ def test_strict_mode_unset_rate_limiting_config(collection_name):
14181455
assert new_strict_mode_config['enabled']
14191456
assert new_strict_mode_config['read_rate_limit'] == 2
14201457
# assert write rate limit is not unset because it is currently not supported
1421-
assert new_strict_mode_config['write_rate_limit'] == 1
1458+
assert new_strict_mode_config['write_rate_limit'] == 1

0 commit comments

Comments
 (0)