Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Sep 8, 2017
1 parent 0b141fd commit 6ac688f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
12 changes: 6 additions & 6 deletions kinto_elasticsearch/command_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def main(cli_args=None):
try:
indexer = registry.indexer
except AttributeError:
print("kinto-elasticsearch not available.")
return 22
logger.error("kinto-elasticsearch not available.")
return 62

bucket_id = args.bucket
collection_id = args.collection
Expand All @@ -51,13 +51,13 @@ def main(cli_args=None):
try:
schema = get_index_schema(registry.storage, bucket_id, collection_id)
except RecordNotFoundError:
print("No collection '%s' in bucket '%s'" % (collection_id, bucket_id))
return 32
logger.error("No collection '%s' in bucket '%s'" % (collection_id, bucket_id))
return 63

# Give up if collection has no index mapping.
if schema is None:
print("No `index:schema` attribute found in collection metadata.")
return 42
logger.error("No `index:schema` attribute found in collection metadata.")
return 64

# XXX: Are you sure?
recreate_index(indexer, bucket_id, collection_id, schema)
Expand Down
7 changes: 7 additions & 0 deletions tests/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
use = egg:kinto
kinto.userid_hmac_secret = some-secret-string

kinto.storage_backend = kinto.core.storage.postgresql
kinto.storage_url = postgres://postgres:postgres@localhost:5432/postgres

kinto.permission_backend = kinto.core.permission.postgresql
kinto.permission_url = postgres://postgres:postgres@localhost:5432/postgres

kinto.includes = kinto_elasticsearch
kinto.plugins.flush

# We need indices to be refreshed immediately for assertions.
kinto.elasticsearch.force_refresh = true
9 changes: 0 additions & 9 deletions tests/test_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ def test_returns_false_if_connection_fails(self):

class PostActivation(BaseWebTest, unittest.TestCase):

@classmethod
def get_app_settings(cls, extras=None):
settings = super().get_app_settings(extras)
settings['storage_backend'] = 'kinto.core.storage.postgresql'
settings['storage_url'] = 'postgres://postgres:postgres@localhost:5432/postgres'
settings['permission_backend'] = 'kinto.core.permission.postgresql'
settings['permission_url'] = settings['storage_url']
return settings

def setUp(self):
app = self.make_app(settings={"kinto.includes": ""})
capabilities = app.get("/").json["capabilities"]
Expand Down

0 comments on commit 6ac688f

Please sign in to comment.