Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
Default bucket integration (fixes #25)
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed May 23, 2017
1 parent 0ac59d3 commit 3a21cbe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kinto_elasticsearch/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
@search.post()
def get_search(request):
bucket_id = request.matchdict['bucket_id']
if bucket_id == "default":
try:
bucket_id = request.default_bucket_id
except AttributeError as e: # pragma: no cover
pass # `default` bucket without default_bucket plugin.

collection_id = request.matchdict['collection_id']

query = request.body
Expand Down
1 change: 1 addition & 0 deletions tests/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use = egg:kinto
kinto.userid_hmac_secret = some-secret-string

kinto.includes = kinto_elasticsearch
kinto.plugins.default_bucket
kinto.plugins.flush
# We need indices to be refreshed immediately for assertions.
kinto.elasticsearch.force_refresh = true
7 changes: 7 additions & 0 deletions tests/test_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,10 @@ def test_search_on_empty_collection_returns_empty_list(self):
headers=self.headers)
result = resp.json
assert len(result["hits"]["hits"]) == 0

def test_search_on_default_bucket_implicit_collection_returns_empty_list(self):
self.app.get("/buckets/default/collections/yeah/records", headers=self.headers)
resp = self.app.post("/buckets/default/collections/yeah/search",
headers=self.headers)
result = resp.json
assert len(result["hits"]["hits"]) == 0

0 comments on commit 3a21cbe

Please sign in to comment.