{"id":17809933,"url":"https://github.com/jong/testing.elasticsearch","last_synced_at":"2025-03-17T17:31:34.373Z","repository":{"id":29072730,"uuid":"32600765","full_name":"jong/testing.elasticsearch","owner":"jong","description":"Automatically sets up an elasticsearch instance in a temporary directory, and destroys it after testing.","archived":false,"fork":false,"pushed_at":"2016-05-16T22:35:02.000Z","size":24,"stargazers_count":12,"open_issues_count":4,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T03:14:18.612Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jong.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-20T18:38:56.000Z","updated_at":"2023-08-30T02:26:58.000Z","dependencies_parsed_at":"2022-09-10T02:20:12.351Z","dependency_job_id":null,"html_url":"https://github.com/jong/testing.elasticsearch","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jong%2Ftesting.elasticsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jong%2Ftesting.elasticsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jong%2Ftesting.elasticsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jong%2Ftesting.elasticsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jong","download_url":"https://codeload.github.com/jong/testing.elasticsearch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243878408,"owners_count":20362431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-27T15:24:05.609Z","updated_at":"2025-03-17T17:31:33.478Z","avatar_url":"https://github.com/jong.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"testing.elasticsearch\n=====================\n\n`testing.elasticsearch` automatically sets up an elasticsearch instance in a\ntemporary directory, and destroys it after testing. It's useful as a pytest\nfixture for testing interactions with elasticsearch in an isolated manner.\n\n\nImplementation is based off the awesome  `testing.redis \u003chttps://bitbucket.org/tk0miya/testing.redis\u003e`_ module.\n\nExample usage:\n\n.. code-block:: python\n\n    import testing.elasticsearch\n    import pyes.es import ES\n\n    # launch new elasticsearch server:\n    with testing.elasticsearch.ElasticSearchServer() es:\n        elasticsearch = ES(es.uri())\n        # perform any testing with elasticsearch here\n\n    # elasticsearch server is terminated and cleaned up here\n\n\nYou can change the server configuration by specifying a `config` dict:\n\n.. code-block:: python\n\n    with ElasticSearchServer(config={\n        'logger.level': 'DEBUG',\n        # Keep index in memory\n        'index.store.type': 'mmapfs',\n    }) as es:\n        ...\n\n\n...or by setting them on the `config` attribute before starting the server:\n\n.. code-block:: python\n\n    es = ElasticSearchServer()\n    es.config['logger.level'] = 'DEBUG'\n    es.start()\n\n\nYou can also setup a pytest fixture:\n\n.. code-block:: python\n\n    @pytest.fixture(scope='session')\n    def elasticsearch(request):\n        \"\"\"\n        A testing fixture that provides a running elasticsearch server.\n        \"\"\"\n        es = ElasticSearchServer()\n        es.start()\n        request.addfinalizer(es.stop)\n        return es\n\n\nTesting\n-------\n\nTo run tests you'll need to install the test requirements::\n\n    pip install -r src/tests/requirements.txt\n\nRun tests::\n\n    python src/tests/runtests.py\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjong%2Ftesting.elasticsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjong%2Ftesting.elasticsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjong%2Ftesting.elasticsearch/lists"}