Skip to content

Commit 831c473

Browse files
authored
test: Consolidate tests (#126)
1 parent a57ce99 commit 831c473

22 files changed

Lines changed: 2022 additions & 5709 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114

115115
services:
116116
paradedb:
117-
image: paradedb/paradedb:0.23.0-pg${{ matrix.postgres-version }}
117+
image: paradedb/paradedb:0.23.4-pg${{ matrix.postgres-version }}
118118
env:
119119
POSTGRES_USER: postgres
120120
POSTGRES_PASSWORD: postgres

paradedb/functions.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ def _validate_non_negative_int(name: str, value: int | None) -> None:
3838
raise ValueError(f"{name} must be zero or positive.")
3939

4040

41-
def _validate_sample_rate(sample_rate: float | None) -> None:
42-
if sample_rate is None:
43-
return
44-
if isinstance(sample_rate, bool) or not isinstance(sample_rate, int | float):
45-
raise TypeError("sample_rate must be a float between 0.0 and 1.0.")
46-
if sample_rate < 0 or sample_rate > 1:
47-
raise ValueError("sample_rate must be between 0.0 and 1.0.")
48-
49-
5041
class Score(Func):
5142
"""BM25 score annotation."""
5243

@@ -100,19 +91,9 @@ def as_sql( # type: ignore[override]
10091

10192

10293
class Snippets(Func):
103-
"""Multiple-snippets annotation.
104-
105-
Wraps ``pdb.snippets(column, ...)`` which returns a text array of all
106-
matching snippet fragments, with named SQL parameters.
107-
108-
See: https://docs.paradedb.com/documentation/full-text/highlight#multiple-snippets
109-
"""
110-
11194
function = FN_SNIPPETS
11295
output_field = ArrayField(base_field=CharField())
11396

114-
_VALID_SORT_BY = ("score", "position")
115-
11697
def __init__(
11798
self,
11899
field: str,
@@ -124,10 +105,6 @@ def __init__(
124105
offset: int | None = None,
125106
sort_by: Literal["score", "position"] | None = None,
126107
) -> None:
127-
if sort_by is not None and sort_by not in self._VALID_SORT_BY:
128-
raise ValueError(
129-
f"sort_by must be one of {self._VALID_SORT_BY!r}, got {sort_by!r}"
130-
)
131108
_validate_non_negative_int("max_num_chars", max_num_chars)
132109
_validate_non_negative_int("limit", limit)
133110
_validate_non_negative_int("offset", offset)
@@ -320,7 +297,6 @@ def paradedb_verify_index(
320297
using: str = DEFAULT_DB_ALIAS,
321298
) -> list[dict[str, Any]]:
322299
"""Run ``pdb.verify_index()`` for one BM25 index."""
323-
_validate_sample_rate(sample_rate)
324300
sql = [f"SELECT * FROM {FN_VERIFY_INDEX}(%s::regclass"]
325301
params: list[Any] = [index]
326302
if heapallindexed:
@@ -356,7 +332,6 @@ def paradedb_verify_all_indexes(
356332
using: str = DEFAULT_DB_ALIAS,
357333
) -> list[dict[str, Any]]:
358334
"""Run ``pdb.verify_all_indexes()`` across BM25 indexes."""
359-
_validate_sample_rate(sample_rate)
360335
sql = [f"SELECT * FROM {FN_VERIFY_ALL_INDEXES}("]
361336
params: list[Any] = []
362337
named_params: list[tuple[str, str, Any]] = []

paradedb/queryset.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,6 @@ def facets(
4343
include_rows: bool = True,
4444
exact: bool | None = None,
4545
) -> dict[str, object] | tuple[list[Any], dict[str, object]]:
46-
# Faceted queries require pdb.agg() OVER () with ORDER BY + LIMIT and a ParadeDB
47-
# search condition in the WHERE clause to trigger the custom scan.
48-
#
49-
# Example:
50-
# SELECT id, description, pdb.agg('{"value_count":{"field":"id"}}') OVER ()
51-
# FROM mock_items
52-
# WHERE description ||| 'running shoes'
53-
# ORDER BY id
54-
# LIMIT 5;
5546
if not fields and agg is None:
5647
raise ValueError("facets() requires fields or agg.")
5748

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ markers = [
138138
[tool.coverage.run]
139139
source = ["paradedb"]
140140
branch = true
141+
omit = ["api.py", "__init__.py"]
141142

142143
[tool.coverage.report]
143144
exclude_lines = [

0 commit comments

Comments
 (0)