Skip to content

Commit f678a22

Browse files
committed
RDBC-780 IndexesFromClientTest::getTerms
1 parent 13fe4e5 commit f678a22

File tree

3 files changed

+56
-11
lines changed

3 files changed

+56
-11
lines changed

ravendb/documents/indexes/stats.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
from datetime import datetime
33
from typing import Dict, Any
44

5-
from ravendb.documents.indexes.definitions import IndexState, IndexPriority, IndexLockMode, IndexType, IndexSourceType, \
6-
IndexRunningStatus
5+
from ravendb.documents.indexes.definitions import (
6+
IndexState,
7+
IndexPriority,
8+
IndexLockMode,
9+
IndexType,
10+
IndexSourceType,
11+
IndexRunningStatus,
12+
)
713
from ravendb.tools.utils import Utils
814

915

ravendb/documents/operations/indexes.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66

77
from ravendb.exceptions import exceptions
88
from ravendb.exceptions.exceptions import ErrorResponseException
9-
from ravendb.documents.indexes.definitions import IndexDefinition, IndexErrors, IndexLockMode, IndexPriority, \
10-
IndexRunningStatus
9+
from ravendb.documents.indexes.definitions import (
10+
IndexDefinition,
11+
IndexErrors,
12+
IndexLockMode,
13+
IndexPriority,
14+
IndexRunningStatus,
15+
)
1116
from ravendb.documents.operations.definitions import MaintenanceOperation, VoidMaintenanceOperation
1217
from ravendb.http.raven_command import RavenCommand, VoidRavenCommand
1318
from ravendb.http.server_node import ServerNode
@@ -282,9 +287,7 @@ def from_json(cls, json_dict: dict) -> IndexStatus:
282287

283288

284289
class IndexingStatus:
285-
def __init__(
286-
self, status: IndexRunningStatus = None, indexes: List[IndexStatus] = None
287-
):
290+
def __init__(self, status: IndexRunningStatus = None, indexes: List[IndexStatus] = None):
288291
self.status = status
289292
self.indexes = indexes
290293

ravendb/tests/jvm_migrated_tests/client_tests/indexing_tests/test_indexes_from_client.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@
1616
StartIndexingOperation,
1717
StopIndexOperation,
1818
GetIndexesOperation,
19-
GetIndexStatisticsOperation, SetIndexesLockOperation, SetIndexesPriorityOperation,
19+
GetIndexStatisticsOperation,
20+
SetIndexesLockOperation,
21+
SetIndexesPriorityOperation,
22+
GetTermsOperation,
23+
)
24+
from ravendb.documents.indexes.definitions import (
25+
FieldIndexing,
26+
FieldStorage,
27+
IndexLockMode,
28+
IndexRunningStatus,
29+
IndexPriority,
2030
)
21-
from ravendb.documents.indexes.definitions import FieldIndexing, FieldStorage, IndexLockMode, IndexRunningStatus, \
22-
IndexPriority
2331
from ravendb.documents.indexes.abstract_index_creation_tasks import AbstractIndexCreationTask
2432
from ravendb.infrastructure.entities import User, Post
2533
from ravendb.tests.test_base import TestBase
@@ -271,9 +279,37 @@ def test_set_lock_mode_and_set_priority(self):
271279
self.assertEqual(stats.priority, IndexPriority.NORMAL)
272280

273281
self.store.maintenance.send(SetIndexesLockOperation(IndexLockMode.LOCKED_IGNORE, index.name))
274-
self.store.maintenance.send(SetIndexesPriorityOperation(IndexPriority.LOW,index.name ))
282+
self.store.maintenance.send(SetIndexesPriorityOperation(IndexPriority.LOW, index.name))
275283

276284
stats = self.store.maintenance.send(GetIndexStatisticsOperation(index.name))
277285

278286
self.assertEqual(IndexLockMode.LOCKED_IGNORE, stats.lock_mode)
279287
self.assertEqual(IndexPriority.LOW, stats.priority)
288+
289+
def test_get_terms(self):
290+
with self.store.open_session() as session:
291+
session.store(User(name="Fitzchak"))
292+
session.store(User(name="Arek"))
293+
session.save_changes()
294+
295+
with self.store.open_session() as session:
296+
stats: Optional[QueryStatistics] = None
297+
298+
def _stats(s: QueryStatistics):
299+
nonlocal stats
300+
stats = s
301+
302+
users = list(
303+
session.query(object_type=User)
304+
.wait_for_non_stale_results()
305+
.statistics(_stats)
306+
.where_equals("name", "Arek")
307+
)
308+
index_name = stats.index_name
309+
310+
terms = self.store.maintenance.send(GetTermsOperation(index_name, "name", None, 128))
311+
312+
self.assertEqual(2, len(terms))
313+
314+
self.assertIn("arek", terms)
315+
self.assertIn("fitzchak", terms)

0 commit comments

Comments
 (0)