{ "info": { "author": "George Macon", "author_email": "george.macon@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Testing" ], "description": "Hypothesis Strategy for MongoEngine\n===================================\n\n.. image:: https://travis-ci.org/gmacon/hypothesis-mongoengine.svg?branch=master\n\nThis package contains a `Hypothesis `_ strategy for generating example documents from a `MongoEngine `_ model.\n\nHere's a minimal example:\n\n.. code:: python\n\n from hypothesis import given, note\n from hypothesis_mongoengine.strategies import documents\n from mongoengine import Document, StringField\n\n\n class Foo(Document):\n foo = StringField()\n\n\n @given(documents(Foo))\n def test_something(foo):\n # Handy since the default __repr__ is unhelpful:\n note(foo.to_json())\n\n assert hasattr(foo, 'id')\n\n\nYou can customize the generation of examples by passing alternate strategies for each field as keyword arguments:\n\n.. code:: python\n\n @given(documents(Foo, foo=strategies.strings(max_size=7)))\n def test_another thing(foo):\n pass\n\nBy default, all examples that would validate against the built-in MongoEngine restrictions are generated.\nIf the field is not required, ``None`` will also be generated.\nIf ``choices`` is specified, only those values will be generated.\n\nIf ``validation`` is specified, the default strategy will be filtered by the validation function.\nIf the custom validation function accepts too few values, Hypothesis may fail the health check.\nIn that case, supply a custom validator that generates acceptable examples more efficiently.\n\nWhat's Not Supported\n--------------------\n\n``ReferenceField`` is not generically supported and probably will never be.\nYou can, and should, provide an application-specific strategy for these fields.\nThis permits you to ensure that the referential-integrity constraints needed by your application are satisfied.\nDon't forget that MongoEngine expects the documents to have been saved to the database before you try to reference them.\nYou can use the ``hypothesis_mongoengine.helpers.mark_saved`` function to make a document appear as if saved.\n\n``DictField`` is not generically supported and probably will never be.\n``MapField`` is supported generically and should be preferred to ``DictField`` when the values are homogenous.\nWhen writing custom strategies for a ``DictField``,\nyou can use the ``hypothesis_mongoengine.strategies.mongodb_keys`` strategy to generate the keys in the absence of more specific application knowledge about the keys.\n\n``DynamicDocument`` (and ``DynamicEmbeddedDocument``) currently generate only the explicitly-specified fields.\n\n``DynamicField`` is normally used internally by ``DynamicDocument``,\nbut if you have a model which references it explicitly, it won't be handled generically.\n\nHandling Custom Fields\n----------------------\n\nIf you have a custom field in use in your application,\nyou can register a strategy to generate examples for it using the ``field_strat`` decorator.\n\nFor example, a strategy for the ``EnumField`` from `extras-mongoengine `_ could look like this:\n\n.. code:: python\n\n from extras_mongoengine.fields import EnumField\n from hypothesis import strategies\n from hypothesis_mongoengine.strategies import field_strat\n\n @field_strat(EnumField)\n def my_custom_strat(field):\n return strategies.sampled_from(field.enum)\n\nThe fields are looked up in the registry by equality of the classes,\nso if you have a hierarchy of custom fields, you must register the leaf types.\nYou can, however, stack the decorator several times if you need to:\n\n.. code:: python\n\n from extras_mongoengine.fields import EnumField, IntEnumField, StringEnumField\n from hypothesis import strategies\n from hypothesis_mongoengine.strategies import field_strat\n\n @field_strat(EnumField)\n @field_strat(IntEnumField)\n @field_strat(StringEnumField)\n def my_custom_strat(field):\n return strategies.sampled_from(field.enum)\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gmacon/hypothesis-mongoengine", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "hypothesis-mongoengine", "package_url": "https://pypi.org/project/hypothesis-mongoengine/", "platform": "", "project_url": "https://pypi.org/project/hypothesis-mongoengine/", "project_urls": { "Homepage": "https://github.com/gmacon/hypothesis-mongoengine" }, "release_url": "https://pypi.org/project/hypothesis-mongoengine/1.1.0/", "requires_dist": [ "hypothesis", "mongoengine" ], "requires_python": "", "summary": "Hypothesis strategy for MongoEngine models", "version": "1.1.0" }, "last_serial": 3701972, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "82dea2dd9753390f76b02d94307184e8", "sha256": "94e438ada3ed7195237c19cd79d3266ec9f0de6435b3d281c11bf0e420ce6219" }, "downloads": -1, "filename": "hypothesis_mongoengine-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "82dea2dd9753390f76b02d94307184e8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4742, "upload_time": "2017-12-18T16:43:07", "url": "https://files.pythonhosted.org/packages/83/62/8bf348ae1f53e939369856dc0eae4fcdb6c0bf413b7ef404e92684bd7b11/hypothesis_mongoengine-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0a9a42c2cfce60221593d5508ca8bad5", "sha256": "e7ca1b5b90b245d3d229b4045b248fbc44326ee0a6c727dfaa4b99a9164da32f" }, "downloads": -1, "filename": "hypothesis-mongoengine-1.0.0.tar.gz", "has_sig": false, "md5_digest": "0a9a42c2cfce60221593d5508ca8bad5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2735, "upload_time": "2017-12-18T16:43:09", "url": "https://files.pythonhosted.org/packages/ec/f5/bebff2118168c4df5032cee5e6192df166c873fa9fbf2ebfe4b8448ea9b0/hypothesis-mongoengine-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "7da37c1ef949b8cbfdb771849474d585", "sha256": "ad18d98c9a7f218a6b508dfde86268bad02ccf77f883dd6ba5e646717149a1ce" }, "downloads": -1, "filename": "hypothesis_mongoengine-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7da37c1ef949b8cbfdb771849474d585", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6746, "upload_time": "2018-02-13T22:54:49", "url": "https://files.pythonhosted.org/packages/ea/9b/bcfb40f04b02ecf8606a77282f8c17af1bb10801766fb63b77c7eaa440ea/hypothesis_mongoengine-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "644449eaad89c9db8a8d6f235bf7b465", "sha256": "1f94b82e0bcbe0047ab29a5519c21a0eb53c8fa9cd704c1269f72abc81b1b6eb" }, "downloads": -1, "filename": "hypothesis-mongoengine-1.0.1.tar.gz", "has_sig": false, "md5_digest": "644449eaad89c9db8a8d6f235bf7b465", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4083, "upload_time": "2018-02-13T22:54:51", "url": "https://files.pythonhosted.org/packages/ae/14/0a0c0ece2c8f8f7644f669ef0b4212066fbdcc314e6e47a1fe07df997090/hypothesis-mongoengine-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "998c5df29cd8d0cbe50aaba19f8bc301", "sha256": "ab872719813d2d4fe6f9f327c7225f2a437d41ffa17413134d3c8e8b36727fb2" }, "downloads": -1, "filename": "hypothesis_mongoengine-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "998c5df29cd8d0cbe50aaba19f8bc301", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7790, "upload_time": "2018-03-24T18:15:53", "url": "https://files.pythonhosted.org/packages/41/fd/a4d7712b855ff1277c368a77e4e016dc1b9a139d4c7f9b6ee017b20f5f24/hypothesis_mongoengine-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "367203b4f01eca9a18718f58aea226f1", "sha256": "70421e3d3741c1ebb20716ed89c39c0df914c7070283ef6d7c7271d94a1761a4" }, "downloads": -1, "filename": "hypothesis-mongoengine-1.1.0.tar.gz", "has_sig": false, "md5_digest": "367203b4f01eca9a18718f58aea226f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4691, "upload_time": "2018-03-24T18:15:55", "url": "https://files.pythonhosted.org/packages/ce/ee/e46d2a0d71561a28f0dbb3f3f674a7e96f1447ce492d807357754f88852a/hypothesis-mongoengine-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "998c5df29cd8d0cbe50aaba19f8bc301", "sha256": "ab872719813d2d4fe6f9f327c7225f2a437d41ffa17413134d3c8e8b36727fb2" }, "downloads": -1, "filename": "hypothesis_mongoengine-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "998c5df29cd8d0cbe50aaba19f8bc301", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7790, "upload_time": "2018-03-24T18:15:53", "url": "https://files.pythonhosted.org/packages/41/fd/a4d7712b855ff1277c368a77e4e016dc1b9a139d4c7f9b6ee017b20f5f24/hypothesis_mongoengine-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "367203b4f01eca9a18718f58aea226f1", "sha256": "70421e3d3741c1ebb20716ed89c39c0df914c7070283ef6d7c7271d94a1761a4" }, "downloads": -1, "filename": "hypothesis-mongoengine-1.1.0.tar.gz", "has_sig": false, "md5_digest": "367203b4f01eca9a18718f58aea226f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4691, "upload_time": "2018-03-24T18:15:55", "url": "https://files.pythonhosted.org/packages/ce/ee/e46d2a0d71561a28f0dbb3f3f674a7e96f1447ce492d807357754f88852a/hypothesis-mongoengine-1.1.0.tar.gz" } ] }