{ "info": { "author": "SteelKiwi Development", "author_email": "sales@steelkiwi.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django :: 1.7", "Framework :: Django :: 1.8", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "================\ndjango-skd-smoke\n================\n\n.. image:: https://travis-ci.org/steelkiwi/django-skd-smoke.svg\n :target: https://travis-ci.org/steelkiwi/django-skd-smoke\n\n.. image:: https://coveralls.io/repos/steelkiwi/django-skd-smoke/badge.svg?branch=master&service=github\n :target: https://coveralls.io/github/steelkiwi/django-skd-smoke?branch=master\n\n.. image:: https://img.shields.io/pypi/l/django-skd-smoke.svg\n :target: https://pypi.python.org/pypi/django-skd-smoke\n\n.. image:: https://img.shields.io/pypi/v/django-skd-smoke.svg\n :target: https://pypi.python.org/pypi/django-skd-smoke\n\n.. image:: https://img.shields.io/pypi/pyversions/django-skd-smoke.svg\n :target: https://pypi.python.org/pypi/django-skd-smoke\n\nThis package is intended for simplification of smoke tests creation.\n\n.. contents::\n\nInstallation\n------------\n\nYou can get django-skd-smoke by using pip::\n\n $ pip install django-skd-smoke\n\n\nUsage\n-----\nAfter installation you should create new ``TestCase`` derived from\n``skd_smoke.SmokeTestCase`` and define your smoke tests configuration.\nPlease review `Examples`_ section which demonstrates different usecases.\nThey are related to ``example_project`` directory which contains common\ndjango project.\n\n\nConfiguration\n-------------\n``TESTS_CONFIGURATION`` of your ``TestCase`` should contain tuple/list of\ntuples for every request with the next structure:\n\n.. code-block:: python\n\n (url, status, method, {'comment': None, 'initialize': None,\n 'url_kwargs': None, 'request_data': None,\n 'user_credentials': None, 'redirect_to': None})\n\n\n.. list-table::\n :widths: 15 80 5\n :header-rows: 1\n\n * - Parameter\n - Description\n - Required\n * - url\n - plain url or urlname as string\n - Yes\n * - status\n - expected http status code (200, 404, etc.) as ``int``\n - Yes\n * - method\n - http request method (GET, POST, etc.) as string\n - Yes\n * - comment\n - string which is added to ``__doc__`` of generated test method\n - No\n * - initialize\n - callable object to do any required initialization\n - No\n * - url_args\n - list or callable object which returns args list to resolve url using ``django.shortcuts.resolve_url``\n - No\n * - url_kwargs\n - dict or callable object which returns kwargs dict to resolve url using ``django.shortcuts.resolve_url``\n - No\n * - request_data\n - dict or callable object which returns dict to pass it into http method request\n - No\n * - user_credentials\n - dict or callable object which returns dict to login user using ``django.test.TestCase.client.login``\n - No\n * - redirect_to\n - plain url as string which is checked if only status is one of the next: 301, 302, 303, 307\n - No\n\n**NOTE!** All callables take your ``TestCase`` as the first argument so\nyou can use it to transfer state between them. But take into account that\n**order of callbacks usage** is next:\n\n#. ``initialize``\n#. ``url_kwargs``\n#. ``user_credentials``\n#. ``request_data``\n\n\nExamples\n--------\n\nAll examples are taken from ``example_project`` package and can be run after\nrepository cloning.\n\n\\1. Demonstration of simple requests:\n 1. GET 200\n 2. GET 200 with request_data as dict\n 3. POST 200\n 4. POST 302 with request_data as callable\n 5. GET 302 (unauthorized access)\n 6. GET 200 (authorized access)\n 7. POST 405 (method not allowed)\n\n.. code-block:: python\n\n from django.contrib.auth import get_user_model\n\n from skd_smoke import SmokeTestCase\n\n\n def get_article_data(testcase):\n return {'headline': 'new article'}\n\n\n def get_user_credentials(testcase):\n username = 'test_user'\n password = '1234'\n credentials = {'username': username, 'password': password}\n User = get_user_model()\n new_user = User.objects.create(username=username)\n new_user.set_password(password)\n new_user.save()\n testcase.user = new_user\n return credentials\n\n\n class SimpleSmokeTestCase(SmokeTestCase):\n TESTS_CONFIGURATION = (\n ('home', 200, 'GET',), # 1\n ('home', 200, 'GET', {'request_data': {'scrollTop': 1}}), # 2\n ('articles:create', 200, 'POST',), # 3\n ('articles:create', 302, 'POST',\n {'request_data': get_article_data}), # 4\n ('is_authenticated', 302, 'GET',), # 5\n ('is_authenticated', 200, 'GET',\n {'user_credentials': get_user_credentials}), # 6\n ('/only_post_request/', 405, 'GET',), # 7\n )\n\n\n2. Usage of ``initialize`` callback to create several objects to test objects\nlist.\n\nSuppose you want to make smoke test for articles list page but initially your\ntest db does not contain any. You can use ``initialize`` callback here to\ncreate several articles.\n\n.. code-block:: python\n\n from skd_smoke import SmokeTestCase\n\n from articles.models import Article\n\n\n def create_articles(testcase):\n for i in range(3):\n Article.objects.create(headline='article #%s' % i)\n\n\n class ArticlesListSmokeTestCase(SmokeTestCase):\n TESTS_CONFIGURATION = (\n ('articles:articles', 200, 'GET',\n {'initialize': create_articles} # pass your func here\n ),\n )\n\n3. Usage of ``redirect_to`` setting to test anonymous access of login required\npages.\n\n\n.. code-block:: python\n\n from django.core.urlresolvers import reverse\n\n from skd_smoke import SmokeTestCase\n\n\n class RedirectToSmokeTestCase(SmokeTestCase):\n TESTS_CONFIGURATION = (\n ('is_authenticated', 302, 'GET', {\n 'redirect_to': '%s?next=%s' % (reverse('login'),\n reverse('is_authenticated')),\n 'comment': 'Anonymous profile access with check of redirect url'\n }),\n )\n\n4. Usage of ``url_kwargs`` and ``user_credentials`` callbacks to test\nauthorized access of owner to newly created object.\n\nSuppose you have a model Article which unpublished version can be viewed by\nits owner only. You can test this situation by creating of user in\n``url_kwargs`` callback and transfering user to ``user_credentials`` callback.\nUnfortunately, you cannot get password from user model cause it contains\nhashed password. So you should return password as plain text.\n\nLets smoke test two other situations when 404 page is showed. Finally we have\nthree testcases:\n\ni. Anonymous access should show 404 page.\nii. Some ordinary user access should also show 404 page.\niii. Only owner access returns actual article with status 200.\n\n.. code-block:: python\n\n from django.contrib.auth import get_user_model\n\n from skd_smoke import SmokeTestCase\n\n from articles.models import Article\n\n\n def create_user():\n UserModel = get_user_model()\n new_user = UserModel.objects.create(username='test_user')\n new_user.set_password('1234')\n new_user.save()\n return new_user\n\n\n def create_unpublished_article(commit=True):\n article = Article(headline='unpublished', published=False)\n if commit:\n article.save()\n return article\n\n\n def create_article_without_owner(testcase):\n return {'pk': create_unpublished_article().pk}\n\n\n def create_and_return_user_credentials(testcase):\n user = create_user()\n return {\n 'username': user.username,\n 'password': '1234' # User contains hashed password only so we should\n # return it as plain text\n }\n\n\n def create_article_with_its_owner(testcase):\n owner = create_user()\n testcase.owner = owner\n unpublished = create_unpublished_article(commit=False)\n unpublished.owner = owner\n unpublished.save()\n return {'pk': unpublished.pk}\n\n\n def get_owner_credentials(testcase):\n return {\n 'username': testcase.owner.username,\n 'password': '1234' # User contains hashed password only\n }\n\n\n class UnpublishedArticleSmokeTestCase(SmokeTestCase):\n TESTS_CONFIGURATION = (\n ('articles:article', 404, 'GET',\n {'url_kwargs': create_article_without_owner,\n 'comment': 'Anonymous access to unpublished article.'}), # 1\n\n ('articles:article', 404, 'GET',\n {'url_kwargs': create_article_without_owner,\n 'user_credentials': create_and_return_user_credentials,\n 'comment': 'Some user access to unpublished article.'}), # 2\n\n ('articles:article', 200, 'GET',\n {'url_kwargs': create_article_with_its_owner,\n 'user_credentials': get_owner_credentials,\n 'comment': 'Owner access to unpublished article.'}), # 3\n )\n\nLicense\n-------\n\nMIT", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/steelkiwi/django-skd-smoke", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-skd-smoke", "package_url": "https://pypi.org/project/django-skd-smoke/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-skd-smoke/", "project_urls": { "Homepage": "https://github.com/steelkiwi/django-skd-smoke" }, "release_url": "https://pypi.org/project/django-skd-smoke/0.2/", "requires_dist": null, "requires_python": "", "summary": "Smoke tests for django projects.", "version": "0.2" }, "last_serial": 1811446, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "adc045593ac30052243cd1e61b41e7a6", "sha256": "f8ecc438e5c1a81c7a0dd7cfdf53217d6d532c00b3474f62759fb8a4324aeb2e" }, "downloads": -1, "filename": "django_skd_smoke-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "adc045593ac30052243cd1e61b41e7a6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10205, "upload_time": "2015-10-08T15:09:51", "url": "https://files.pythonhosted.org/packages/3a/bd/5902f3e7829deb42d3470bf8456f94943cd16862134ba02a9641d04dfa66/django_skd_smoke-0.1-py2.py3-none-any.whl" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "97cace1ed2d387fca2e6ac908f88b200", "sha256": "b0d97d1544fe527fda57b27b2a85c2b7ab6697de0ebfc30cb29a8aa1ccf44a12" }, "downloads": -1, "filename": "django-skd-smoke-0.2.tar.gz", "has_sig": false, "md5_digest": "97cace1ed2d387fca2e6ac908f88b200", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9962, "upload_time": "2015-11-11T13:02:24", "url": "https://files.pythonhosted.org/packages/d9/77/9b7905d9dbd5b3d08ab1f856ecbac5a1f8296f12ec5540c3b4b173f863de/django-skd-smoke-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "97cace1ed2d387fca2e6ac908f88b200", "sha256": "b0d97d1544fe527fda57b27b2a85c2b7ab6697de0ebfc30cb29a8aa1ccf44a12" }, "downloads": -1, "filename": "django-skd-smoke-0.2.tar.gz", "has_sig": false, "md5_digest": "97cace1ed2d387fca2e6ac908f88b200", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9962, "upload_time": "2015-11-11T13:02:24", "url": "https://files.pythonhosted.org/packages/d9/77/9b7905d9dbd5b3d08ab1f856ecbac5a1f8296f12ec5540c3b4b173f863de/django-skd-smoke-0.2.tar.gz" } ] }