{ "info": { "author": "Petras Zdanavicius (petraszd)", "author_email": "petraszd@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Pytest", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Topic :: Software Development :: Testing" ], "description": "pytest_gae\n==========\n\nIt is `pytest `_ plugin that helps You to test\napplications written with Google's `AppEngine\n`_.\n\n\nOptions\n=======\n\n- --with-gae: Turns on this plugin\n- --gae-path: AppEngine's root (default *google_appengine*)\n- --gae-project-path: Your project's root (default *./*)\n\n\nLimitation\n==========\n\n\nPlugin does not prevent You from using code/modules that AppEngine's\nenvironment refuse to execute. So, You can easily do something like that::\n\n import socket\n import numpy\n\nAnd tests just pass. But You can not run this code on AppEngine environment,\nbecause of sandboxing. See: `AppEngine Docs\n`_\n\nThis plugin uses internal AppEngine's code and there is no guarantee that\nGoogle is not going to change it.\n\n\nOthers\n======\n\nThis project was inspired by nose-gae plugin for nose\n\n`http://code.google.com/p/nose-gae/ `_\n\n\nUsage example\n=============\n\nLet assume we have a directory that looks something like that ::\n\n ./\n |-- gae # AppEngine's root\n | |-- ...\n |-- src # Your project's root\n | |-- app.yaml\n | |-- index.yaml\n | |-- main.py\n |-- tests # Tests' dir\n |-- test_handlers.py\n |-- test_models.py\n\n\nmain.py::\n\n #!/usr/bin/env python\n from google.appengine.ext import webapp\n from google.appengine.ext.webapp import util\n from google.appengine.ext.webapp.util import login_required\n from google.appengine.api import users\n from google.appengine.ext import db\n\n\n class MyModel(db.Model):\n my_field = db.StringProperty(required=False)\n\n\n class IndexHandler(webapp.RequestHandler):\n def get(self):\n self.response.out.write('Index')\n\n\n class UsersHandler(webapp.RequestHandler):\n\n @login_required\n def get(self):\n if users.is_current_user_admin():\n self.response.out.write('Admin')\n else:\n self.response.out.write('User')\n\n\n def make_application():\n return webapp.WSGIApplication([('/index', IndexHandler),\n ('/users', UsersHandler)], debug=True)\n\n\n def main():\n application = make_application()\n util.run_wsgi_app(application)\n\n\n if __name__ == '__main__':\n main()\n\nTesting models\n--------------\n\ntest_models.py::\n\n from google.appengine.ext import db\n import pytest\n\n from main import MyModel\n\n\n def test_basic():\n m = MyModel(my_field='Foo')\n assert 'Foo' == m.my_field\n\n\n def test_new_model():\n m = MyModel(my_field='Foo')\n pytest.raises(db.NotSavedError, lambda: m.key())\n\n\n def test_saved_model():\n m = MyModel(my_field='Foo')\n m.put()\n assert m.key()\n\n\nUsing with WebTest\n------------------\n\nWe could test our handlers with the help of `WebTest\n`_ library.\n\n\nWe would create three funcargs' functions that allows us to test application:\n\n- From anonymous user perspective\n- From authorized user perspective\n- From admin perspective\n\nWe could do that by altering *os.enviroment*\n\n\ntest_handlers.py::\n\n import os\n\n from webtest import TestApp\n from main import make_application\n\n\n def pytest_funcarg__anon_app(request):\n os.environ.update({'USER_EMAIL': '',\n 'USER_ID': '',\n 'AUTH_DOMAIN': 'google',\n 'USER_IS_ADMIN': '0'})\n return TestApp(make_application())\n\n\n def pytest_funcarg__user_app(request):\n os.environ.update({'USER_EMAIL': 'simple@google.com',\n 'USER_ID': '1',\n 'AUTH_DOMAIN': 'google',\n 'USER_IS_ADMIN': '0'})\n return TestApp(make_application())\n\n\n def pytest_funcarg__admin_app(request):\n os.environ.update({'USER_EMAIL': 'admin@google.com',\n 'USER_ID': '2',\n 'AUTH_DOMAIN': 'google',\n 'USER_IS_ADMIN': '1'})\n return TestApp(make_application())\n\n\n def test_index(anon_app):\n assert \"Index\" in anon_app.get('/index')\n\n\n def test_user_with_user(user_app):\n assert \"User\" in user_app.get('/users')\n\n\n def test_user_with_anon(anon_app):\n assert '302 Moved Temporarily' == anon_app.get('/users').status\n\n\n def test_user_with_admin(admin_app):\n assert \"Admin\" in admin_app.get('/users')\n\nRunning\n-------\n\n::\n\n py.test tests --with-gae --gae-path=gae --gae-project-path=./src/ :\n platform linux2 -- Python 2.7.12, pytest-2.9.2, py-1.4.31, pluggy-0.3.1\n collected 7 items\n\n tests/test_handlers.py ....\n tests/test_models.py ...\n\n ============ 7 passed in 0.64 seconds ============", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://bitbucket.org/petraszd/pytest_gae/", "keywords": "py.test pytest google app engine", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "pytest_gae", "package_url": "https://pypi.org/project/pytest_gae/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pytest_gae/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://bitbucket.org/petraszd/pytest_gae/" }, "release_url": "https://pypi.org/project/pytest_gae/0.2.4/", "requires_dist": null, "requires_python": null, "summary": "pytest plugin for apps written with Google's AppEngine", "version": "0.2.4" }, "last_serial": 2260754, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "8815e98e70fb83228608ecb72ebc3eb2", "sha256": "54fbcf12d6812cd42a0cf111d72a7f8688977bdaeafdd30e076b064d21339b9c" }, "downloads": -1, "filename": "pytest_gae-0.2.tar.gz", "has_sig": false, "md5_digest": "8815e98e70fb83228608ecb72ebc3eb2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5288, "upload_time": "2011-01-17T00:42:03", "url": "https://files.pythonhosted.org/packages/74/3f/421f4b8e29323fea401b1578d4344b596a96425647c8d58bc2fa3a246f78/pytest_gae-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "7f7224d0208125ee6af73acb0fecc71c", "sha256": "a23f3441476f29928efaac17402cca0e8f94b3e32ee36c0edf1944c7070e0d46" }, "downloads": -1, "filename": "pytest_gae-0.2.1-py2.7.egg", "has_sig": false, "md5_digest": "7f7224d0208125ee6af73acb0fecc71c", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 6350, "upload_time": "2012-06-26T00:23:52", "url": "https://files.pythonhosted.org/packages/dc/f9/e9fb2e87896a94f1f1703f0ed4d40cab775f5086cdb4f2a1e418ed961c7e/pytest_gae-0.2.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "9a595d2764458136cbc67558c0107997", "sha256": "c6c59e484354832cc00e169422b7d50a9923f794d65b2daad9f0e0b383b4f74a" }, "downloads": -1, "filename": "pytest_gae-0.2.1.tar.gz", "has_sig": false, "md5_digest": "9a595d2764458136cbc67558c0107997", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4556, "upload_time": "2012-06-26T00:23:51", "url": "https://files.pythonhosted.org/packages/fa/c1/552f6c47e3dc14835e94b448a7100318ef2b90f4502119f245e6453f24e5/pytest_gae-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "217005a4f7730d0da59ebaeddd8b787b", "sha256": "77615dbde0c13c01189819a9b11cb9c5ae450ae071f65927665fd6677ce102ba" }, "downloads": -1, "filename": "pytest_gae-0.2.2.tar.gz", "has_sig": false, "md5_digest": "217005a4f7730d0da59ebaeddd8b787b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5214, "upload_time": "2012-09-12T11:47:43", "url": "https://files.pythonhosted.org/packages/b6/61/7d8e5199d8fd1974d97bb44a89b25c3bfbd85e9a25ced0d4d4b7d35fead5/pytest_gae-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "be72f52068ac45b66caa7148ccf0876a", "sha256": "fe0f3e85b154640d755e5e0c3f79a5605e429b93885e900117ecbda821fcfaba" }, "downloads": -1, "filename": "pytest_gae-0.2.3.tar.gz", "has_sig": false, "md5_digest": "be72f52068ac45b66caa7148ccf0876a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5451, "upload_time": "2014-05-09T18:56:33", "url": "https://files.pythonhosted.org/packages/c4/8c/074afda01e8efd70d6f98fe145fab5e7e4e207b6e33efdae682afcefdb49/pytest_gae-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "fa1c5b98891cc8b234546ebe5e5abe93", "sha256": "83b5fc8ef828aa64af9424234fd8c3800047f163a12e96cec13e3e1fe71e1dcd" }, "downloads": -1, "filename": "pytest_gae-0.2.4.tar.gz", "has_sig": false, "md5_digest": "fa1c5b98891cc8b234546ebe5e5abe93", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5037, "upload_time": "2016-08-03T20:55:34", "url": "https://files.pythonhosted.org/packages/49/2e/6f68cd958f753afb8eeee8c5cb75dc865014480e8c639a0db4f67f8fe059/pytest_gae-0.2.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fa1c5b98891cc8b234546ebe5e5abe93", "sha256": "83b5fc8ef828aa64af9424234fd8c3800047f163a12e96cec13e3e1fe71e1dcd" }, "downloads": -1, "filename": "pytest_gae-0.2.4.tar.gz", "has_sig": false, "md5_digest": "fa1c5b98891cc8b234546ebe5e5abe93", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5037, "upload_time": "2016-08-03T20:55:34", "url": "https://files.pythonhosted.org/packages/49/2e/6f68cd958f753afb8eeee8c5cb75dc865014480e8c639a0db4f67f8fe059/pytest_gae-0.2.4.tar.gz" } ] }