{ "info": { "author": "jean-philippe serafin", "author_email": "serafinjp@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python" ], "description": "Distillery\n==========\n\n.. image:: https://secure.travis-ci.org/Birdback/distillery.png\n\n``distillery`` is another `factory_girl\n`_ like library for python\nORMs.\n\n\nInstallation\n------------\n\n``pip install distillery``\n\n\nDistilleries\n------------\n\nEach distillery has a ``__model__`` and a set of attributes and\nmethods. The ``__model__`` is the ORM model class from which instance\nwill be produced:\n\n.. code-block:: python\n\n class UserDistillery(MyOrmDistillery):\n __model__ = User\n\n\nAttributes\n~~~~~~~~~~\n\nA distillery class attribute defines default values for specific model\nfield:\n\n.. code-block:: python\n\n class UserDistillery(MyOrmDistillery):\n __model__ = User\n\n username = \"defaultusername\"\n\nThe distillery's attribute values act as *defaults*. If a ``User``\nobject is created using this distillery, its ``username`` attribute\nwill default to ``\"defaultusername\"``.\n\n\nLazy attributes\n~~~~~~~~~~~~~~~\n\nUsing the ``lazy`` decorator, you can provide dynamic attributes.\n\n.. code-block:: python\n\n from distillery import lazy\n\n class UserDistillery(MyOrmDistillery):\n __model__ = User\n\n username = \"defaultusername\"\n\n @lazy\n def email_address(cls, instance, sequence):\n return \"%s@%s\" % (instance.username, instance.company.domain)\n\nAll new ``User`` created from ``UserDistillery`` will have an\n``email_address`` computed from his username and his company domain.\n\nNote: all lazies received an ``instance`` and a ``sequence`` that are\nthe object instance and an auto-incremented sequence, respectively.\n\n\nHooks\n~~~~~\n\nA distillery can provide an ``_after_create`` class method to hook\ninto the factory machinery.\n\n.. code-block:: python\n\n class UserDistillery(MyOrmDistillery):\n __model__ = User\n\n username = \"defaultusername\"\n\n @classmethod\n def _after_create(cls, instance):\n # Do stuff after instance creation\n # ...\n\n\nDistillery.init()\n~~~~~~~~~~~~~~~~~\n\nThe ``init()`` method creates and populates a new instance.\n\n.. code-block:: python\n\n user = UserDistillery.init()\n assert user.username == \"defaultusername\"\n assert user.id is None\n\n user = UserDistillery.create(username=\"overriddenusername\")\n assert user.username == \"overriddenusername\"\n assert user.id is None\n\n\nDistillery.create()\n~~~~~~~~~~~~~~~~~~~\n\nThe ``create()`` method initializes the object using ``init()`` and\nsubsequently *saves* it.\n\n.. code-block:: python\n\n user = UserDistillery.create()\n assert user.username == \"defaultusername\"\n assert user.id is not None\n\n\nDistillery.bulk()\n~~~~~~~~~~~~~~~~~\n\nCreates instances in bulk.\n\n.. code-block:: python\n\n users = UserDistillery.bulk(12, username=\"user_%(i)%\")\n assert users[7].username = 'user_7'\n\n\nSets\n----\n\nThe ``distillery.Set`` class acts as a fixture container.\n\nIt's required to define a ``__distillery__`` attribute which is used\nto create objects.\n\n.. code-block:: python\n\n from distillery import Set\n\n class UserSet(Set):\n __distillery__ = UserDistillery\n\n class jeanphix:\n username = 'jeanphix'\n\n\nTo create the fixtures, simply instantiate the set.\n\n.. code-block:: python\n\n users = UserSet()\n assert users.jeanphix.username == 'jeanphix'\n\nImportantly, as long as a reference to the *instantiated set* is held\n(e.g. the ``users`` variable in this example), the set can be called\nagain and the same instance is returned:\n\n.. code-block:: python\n\n assert UserSet() is UserSet()\n\nYou can reference other sets, too. Note that you must reference using\nthe class, or use a lazy attribute (described later):\n\n.. code-block:: python\n\n from distillery import Set\n\n class CompanySet(Set):\n __distillery__ = CompanyDistillery\n\n class my_company:\n name = 'My company'\n\n class UserSet(Set):\n __distillery__ = UserDistillery\n\n class jeanphix:\n username = 'jeanphix'\n company = CompanySet.company\n\n\n users = UserSet()\n assert users.jeanphix.company == 'My company'\n\n\nIn addition to classes, methods can be defined; each will result in an\nobject which is added to the set.\n\n.. code-block:: python\n\n class ProfileSet(Set)\n class __distillery__:\n __model__ = Profile\n\n admin = lambda s: UserDistillery.create(username='admin').profile\n\nThis functionality extends to class-based references. Note that the\nreference must be resolvable at the point of creation; circular\nrelationships are currently not supported.\n\n.. code-block:: python\n\n class UserSet(Set):\n class peter:\n friend = None\n\n class paul:\n friend = classmethod(lambda c: UserSet.peter)\n\n\nIf the ``on_demand`` flag is set, objects are created only when first\naccessed.\n\n.. code-block:: python\n\n users = UserSet(on_demand=True)\n users.jeanphix # jeanphix will be created here.\n\nFinally, sets can be nested.\n\n.. code-block:: python\n\n class fixtures(Set):\n users = UserSet\n\n assert fixtures().users.jeanphix.username == 'jeanphix'\n\n\nHooks\n~~~~~\n\nEach fixture in a set can provide an ``_after_create`` listener:\n\n.. code-block:: python\n\n class ProfileSet(Set):\n class __distillery__:\n __model__ = Profile\n\n class admin:\n @classmethod\n def _after_create(cls, profile):\n profile.name = 'Full name'\n\n assert ProfileSet().admin.name == 'Full name'\n\n\nORMs\n----\n\nBoth Django and SQLAlchemy are supported.\n\n\nDjango\n~~~~~~\n\nDjango models could be distilled using ``DjangoDistillery`` that only\nrequires a ``__model__`` class member:\n\n.. code-block:: python\n\n from distillery import DjangoDistillery\n\n from django.auth.models import User\n\n class UserDistillery(DjangoDistillery):\n __model__ = User\n\n # ...\n\n\nSQLAlchemy\n~~~~~~~~~~\n\nSQLAlchemy distilleries require both the ``__model__`` and\n``__session__`` attributes.\n\n.. code-block:: python\n\n from distillery import SQLAlchemyDistillery\n\n from sqlalchemy import create_engine\n from sqlalchemy.orm import sessionmaker\n\n engine = create_engine('sqlite://', echo=False)\n Session = sessionmaker()\n Session.configure(bind=engine)\n session = Session()\n Base = declarative_base()\n\n class User(Base):\n # ...\n\n\n class UserDistillery(SQLAlchemyDistillery):\n __model__ = User\n __session__ = session\n\n # ...", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Birdback/distillery", "keywords": null, "license": "MIT licence", "maintainer": null, "maintainer_email": null, "name": "distillery", "package_url": "https://pypi.org/project/distillery/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/distillery/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/Birdback/distillery" }, "release_url": "https://pypi.org/project/distillery/0.5/", "requires_dist": null, "requires_python": null, "summary": "fixture utils for python ORMs", "version": "0.5" }, "last_serial": 1702915, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "efd7e291852f38383d529c07a6e6cf88", "sha256": "d0ee6ca61d82a434fe0d152fb9979c911decac0a5dd0359735d797488b31f163" }, "downloads": -1, "filename": "distillery-0.1.tar.gz", "has_sig": false, "md5_digest": "efd7e291852f38383d529c07a6e6cf88", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3908, "upload_time": "2012-10-14T13:21:12", "url": "https://files.pythonhosted.org/packages/d1/75/120eb9d6d52b058fb4fa1ec500db5071394055e93f84073e2bcdf718fb4d/distillery-0.1.tar.gz" } ], "0.1b": [ { "comment_text": "", "digests": { "md5": "e89fb9076cde7c89200f04dd2e8cf031", "sha256": "21c679fb03030e6d697bdc42a240e13489333486152c9f47db1afaca8b67442f" }, "downloads": -1, "filename": "distillery-0.1b.tar.gz", "has_sig": false, "md5_digest": "e89fb9076cde7c89200f04dd2e8cf031", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3439, "upload_time": "2012-10-07T19:44:11", "url": "https://files.pythonhosted.org/packages/49/1e/c77deb4b4909d0cca67bfd7e66688f83a8efe554d26d5e5fe65c5675997e/distillery-0.1b.tar.gz" } ], "0.1b2": [ { "comment_text": "", "digests": { "md5": "01e3038a5501e60f734aef4915226050", "sha256": "24e60c6a1a59e0f0d1fb229e2bf065f08bde5670e27c0e20e6402d1f117eb38d" }, "downloads": -1, "filename": "distillery-0.1b2.tar.gz", "has_sig": false, "md5_digest": "01e3038a5501e60f734aef4915226050", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3862, "upload_time": "2012-10-08T05:51:50", "url": "https://files.pythonhosted.org/packages/67/58/83d236339b4abdb12b9f66cc21af7a5917ee77b00df3fa57c86a316b32f1/distillery-0.1b2.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "91f3f319ea149d744902b7b60071b40f", "sha256": "a30e0f0ae200fc2ad59fabe3479c6e512fe3176c9d1af944db36494cd3b3f7c5" }, "downloads": -1, "filename": "distillery-0.2.tar.gz", "has_sig": false, "md5_digest": "91f3f319ea149d744902b7b60071b40f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4147, "upload_time": "2012-10-16T19:33:44", "url": "https://files.pythonhosted.org/packages/dc/07/53c9c524a3d5035b0d4b9e9e38b74d154e9b5aa93530a9222e7787255a31/distillery-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "5c4d379241deb48a286ee43df864f70e", "sha256": "35125924b1b3e1b4d823beae501a83984046ad5c586bd98aac5adec86379cc5b" }, "downloads": -1, "filename": "distillery-0.3.tar.gz", "has_sig": false, "md5_digest": "5c4d379241deb48a286ee43df864f70e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4207, "upload_time": "2012-10-18T14:27:16", "url": "https://files.pythonhosted.org/packages/0d/18/bfa45222b6e2d7d946861b62ba0c96c9c643ff0deb4c6fab2a60df49372d/distillery-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "9b5710635f6bd77853e8e89b17feae0c", "sha256": "8fe01e1b6c8c37c36f10438db178f3c8ff293b788ee9ca97e2635a628f17005b" }, "downloads": -1, "filename": "distillery-0.3.1.tar.gz", "has_sig": false, "md5_digest": "9b5710635f6bd77853e8e89b17feae0c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4393, "upload_time": "2012-10-18T16:39:43", "url": "https://files.pythonhosted.org/packages/54/38/9c46190f4d8ae50f7e405ce33d21ca9b242c813d1b6416b1c9fa124f2cdd/distillery-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "daea2e649501164ab14a4a60faba2adc", "sha256": "d604b1d1ced8c41ee98827fefb2453db8d18cb3589dedea25ff7355697560758" }, "downloads": -1, "filename": "distillery-0.3.2.tar.gz", "has_sig": false, "md5_digest": "daea2e649501164ab14a4a60faba2adc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4592, "upload_time": "2012-11-05T12:08:36", "url": "https://files.pythonhosted.org/packages/ae/1f/c3b1bf45a57bd0d6ef4fb78ff9516c76ae3f9f065e89e37b4a7c3cb6cf41/distillery-0.3.2.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "958415a5dd9ce1e3d763bd6eba96a40d", "sha256": "1ed79b3392fdd35d92159f1c156c61aa18bd10d40c174745910e9b05dc56ed30" }, "downloads": -1, "filename": "distillery-0.4.tar.gz", "has_sig": false, "md5_digest": "958415a5dd9ce1e3d763bd6eba96a40d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4743, "upload_time": "2013-03-05T08:47:54", "url": "https://files.pythonhosted.org/packages/b2/04/440792ca917300af62250abe4cbcc642df4abe1cfa704e2006c7d93bdeb6/distillery-0.4.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "c8bb4ad82b83cf55683e1c066754c69e", "sha256": "a0ce2b6235a813589ab963fd9e0bd670529031ef454cbecc651adfc7d4cabb74" }, "downloads": -1, "filename": "distillery-0.4.1.tar.gz", "has_sig": false, "md5_digest": "c8bb4ad82b83cf55683e1c066754c69e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4796, "upload_time": "2013-03-05T12:01:34", "url": "https://files.pythonhosted.org/packages/87/fd/82a3d9a54c74d40722dd8592ff985abbfec829c666aea54ed4a9f4423c9a/distillery-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "b6e5afba7a09e8c50493a8e08d052e99", "sha256": "b305757dde7d5ef7a00393f097c1e7d1948946ec29fc98a2fe5a2522e3e22582" }, "downloads": -1, "filename": "distillery-0.4.2.tar.gz", "has_sig": false, "md5_digest": "b6e5afba7a09e8c50493a8e08d052e99", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5228, "upload_time": "2013-11-25T06:56:12", "url": "https://files.pythonhosted.org/packages/ea/1e/35ac02912bbd53c53e8a4ed42a4e8f4e7e917645c93a4ebbb68b413d272e/distillery-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "9beee11765b3a7eed4d59f17e629c7db", "sha256": "17f8dc08aecc417dceee61c56491dfa0d69e927035f480af12a5ab22b3ae5d86" }, "downloads": -1, "filename": "distillery-0.4.3.tar.gz", "has_sig": false, "md5_digest": "9beee11765b3a7eed4d59f17e629c7db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5465, "upload_time": "2014-09-15T13:11:00", "url": "https://files.pythonhosted.org/packages/85/88/71a59fa491446a2c08b428cfea714ad31f054117bc07a5fff9885df61067/distillery-0.4.3.tar.gz" } ], "0.4.4": [ { "comment_text": "", "digests": { "md5": "4bf3ea3768e0107a1745d7184b413d08", "sha256": "947cd7b6107ca158ebf03fa18ec8162c3a440205b99acd9db406088e57fd51d1" }, "downloads": -1, "filename": "distillery-0.4.4.tar.gz", "has_sig": false, "md5_digest": "4bf3ea3768e0107a1745d7184b413d08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5544, "upload_time": "2014-09-16T05:55:49", "url": "https://files.pythonhosted.org/packages/e3/4e/b4485e51eec44022b09f0d0008f114a7cbbf34996a37972efa87285cf511/distillery-0.4.4.tar.gz" } ], "0.4.5": [ { "comment_text": "", "digests": { "md5": "bcd7710b7f4175156d77fd662e75a8ec", "sha256": "478956c13e1d709455b2d61cd30417313c2f306d144041bddbf35c32854c7fb8" }, "downloads": -1, "filename": "distillery-0.4.5.tar.gz", "has_sig": false, "md5_digest": "bcd7710b7f4175156d77fd662e75a8ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5545, "upload_time": "2014-11-25T05:55:35", "url": "https://files.pythonhosted.org/packages/5e/65/41bee2525927670282523144e802e6ecf8f0f02211aade68e8e4abf0acce/distillery-0.4.5.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "f57925d62d22a5bb1cb713208730325a", "sha256": "e861f0f333c936771ae568ade129488d670d7b0c67055d703e69a6b50965371f" }, "downloads": -1, "filename": "distillery-0.5.tar.gz", "has_sig": false, "md5_digest": "f57925d62d22a5bb1cb713208730325a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5649, "upload_time": "2015-09-01T11:28:02", "url": "https://files.pythonhosted.org/packages/64/c6/5b6e53eee9fd4af84c6a1dc9bc438976e69999163c7e3a44f48b896a119e/distillery-0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f57925d62d22a5bb1cb713208730325a", "sha256": "e861f0f333c936771ae568ade129488d670d7b0c67055d703e69a6b50965371f" }, "downloads": -1, "filename": "distillery-0.5.tar.gz", "has_sig": false, "md5_digest": "f57925d62d22a5bb1cb713208730325a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5649, "upload_time": "2015-09-01T11:28:02", "url": "https://files.pythonhosted.org/packages/64/c6/5b6e53eee9fd4af84c6a1dc9bc438976e69999163c7e3a44f48b896a119e/distillery-0.5.tar.gz" } ] }