Exemplo n.º 1
0
def user_index(app):
    """Initialize the `User` doc type."""
    test_index = Index(uuid4().hex)
    test_index.create()
    app.cluster.health(wait_for_status='yellow')

    # monkey patch `auth_index`
    original_auth_index = auth_models.auth_index
    auth_models.auth_index = test_index

    User.init(index=test_index._name)

    yield test_index

    auth_models.auth_index = original_auth_index
    # Remove all `User`s.
    #
    # [Don't use delete-by-query to clean out all or most documents in an
    # index. Rather create a new index...]
    # (https://www.elastic.co/guide/en/elasticsearch/plugins/2.2/plugins-delete-by-query.html)
    #
    # [It is no longer possible to delete the mapping for a type. Instead you
    # should delete the index and recreate it with the new mappings.]
    # (https://www.elastic.co/guide/en/elasticsearch/reference/2.2/indices-delete-mapping.html)
    test_index.delete()
Exemplo n.º 2
0
def auth_index():
    index = Index('auth')
    index.create()

    Customer.init(index=index._name)
    User.init(index=index._name)

    yield index

    index.delete()