{ "info": { "author": "Martin Brochhaus", "author_email": "mbrochh@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 2.2", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "# Elasticsearch Fixtures\n\nThis tool is heavily inspired by [klen's Mixer](https://github.com/klen/mixer).\n\nThis tool is optimized to be used with `Django` and `pytest`.\n\nIt allows you to add documents to a test-index in yout Elasticsearch instance\nwhen you run your unittests.\n\nWith `elasticsearch_fixtures` you can do something like this:\n\n```py\nfrom elasticsearch_fixtures.es_mixer import ESMixer\n\nes_mixer = ESMixer(host='http://localhost:9200/')\n\ndef test_something():\n doc1 = es_mixer.blend('indexname', id=1, title='test')\n assert doc1['source']['title'] == 'test'\n```\n\nNote: If you provide an `id` and a document with that `id` already exists, that\ndocument will not be updated, but fully replaced.\n\nYou can also create documents without providing an `id`. Elasticsearch will then\nauto-create an `id`:\n\n```py\ndef test_something():\n doc1 = es_mixer.blend('indexname', title='test')\n print(doc1['id'])\n```\n\nAnd you can update an existing document that is already in the index:\n\n```py\ndef test_something():\n es_mixer.blend('indexname', id=1, title='test')\n doc1 = es_mixer.update('indexname', id=1, title='new title')\n assert doc1['source']['title'] == 'new_title'\n```\n\nBig word of warning: We are no ES experts. We have only started using ES around\nJune 2019 and one of the first problems that we had was that we did not know how\nto properly write unittests for our Django views and Graphene resolver\nfunctions. There are probably much better ways to do this. If you know one, we\nwould love to hear about it (just open an issue and tell us about it!).\n\n# Installation\n\n```\npip install elasticsearch-fixtures\n```\n\n# Configuration\n\nIn order to make sure that your tests wipe the index at the very beginning and\nalso after each test, create the following `conftest.py`:\n\n```py\n\"\"\"Global settings for pytest.\"\"\"\nimport pytest\n\nfrom django.conf import settings\n\nfrom elasticsearch_fixtures.es_mixer import ESMixer\n\nes_mixer = ESMixer(host=settings.ELASTICSEARCH_HOST)\nindex = settings.ELASTICSEARCH_INDEX\n\n\n@pytest.fixture(scope='session', autouse=True)\ndef setup_elasticsearch():\n es_mixer.wipe_index(index)\n\n\n@pytest.fixture(autouse=True)\ndef cleanup_elasticsearch():\n yield\n es_mixer.wipe_index(index)\n```\n\nAs you can see, in this example we also use a Django setting called\n`ELASTICSEARCH_HOST` (with a trailing slash) and `ELASTICSEARCH_INDEX`. Of\ncourse you can name your own settings however you like.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/theartling/elasticsearch-fixtures/", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "elasticsearch-fixtures", "package_url": "https://pypi.org/project/elasticsearch-fixtures/", "platform": "", "project_url": "https://pypi.org/project/elasticsearch-fixtures/", "project_urls": { "Homepage": "https://github.com/theartling/elasticsearch-fixtures/" }, "release_url": "https://pypi.org/project/elasticsearch-fixtures/0.1.1/", "requires_dist": [ "requests (==2.22.0)" ], "requires_python": "", "summary": "Mixer-like tool to create test-fixtures for an Elasticsearch index", "version": "0.1.1" }, "last_serial": 5566842, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "b7c4f07cd73c1ba1f0a6a028473d1d6c", "sha256": "159e6959c42812ffcb2b3918e0b6c28d905f564395c98d15ccd6f77178e9edee" }, "downloads": -1, "filename": "elasticsearch_fixtures-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "b7c4f07cd73c1ba1f0a6a028473d1d6c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4528, "upload_time": "2019-07-22T10:57:57", "url": "https://files.pythonhosted.org/packages/ee/ef/e5a4ce2b670f7fd2f839b3c2a59d7a01bdfcfebe73a70c313d2fd2fb58c5/elasticsearch_fixtures-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4c485e729498e7eb2b9a33981bdaaa86", "sha256": "85ed14d3c725b7fbd8b655425ffbefe179dc5f761d0513ea17fe4b5e3d80a45f" }, "downloads": -1, "filename": "elasticsearch-fixtures-0.1.1.tar.gz", "has_sig": false, "md5_digest": "4c485e729498e7eb2b9a33981bdaaa86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4131, "upload_time": "2019-07-22T10:58:00", "url": "https://files.pythonhosted.org/packages/c8/23/faf424f9aed12e80f40f52a7e3af896629d1480578cf56151f25a561ce35/elasticsearch-fixtures-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b7c4f07cd73c1ba1f0a6a028473d1d6c", "sha256": "159e6959c42812ffcb2b3918e0b6c28d905f564395c98d15ccd6f77178e9edee" }, "downloads": -1, "filename": "elasticsearch_fixtures-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "b7c4f07cd73c1ba1f0a6a028473d1d6c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4528, "upload_time": "2019-07-22T10:57:57", "url": "https://files.pythonhosted.org/packages/ee/ef/e5a4ce2b670f7fd2f839b3c2a59d7a01bdfcfebe73a70c313d2fd2fb58c5/elasticsearch_fixtures-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4c485e729498e7eb2b9a33981bdaaa86", "sha256": "85ed14d3c725b7fbd8b655425ffbefe179dc5f761d0513ea17fe4b5e3d80a45f" }, "downloads": -1, "filename": "elasticsearch-fixtures-0.1.1.tar.gz", "has_sig": false, "md5_digest": "4c485e729498e7eb2b9a33981bdaaa86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4131, "upload_time": "2019-07-22T10:58:00", "url": "https://files.pythonhosted.org/packages/c8/23/faf424f9aed12e80f40f52a7e3af896629d1480578cf56151f25a561ce35/elasticsearch-fixtures-0.1.1.tar.gz" } ] }