{ "info": { "author": "Stanley Rokita", "author_email": "srok35@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Flask EZ Test\n=============\n\nMaking flask app's that serve html and use a flasksqlalchemy backend engine easier to test\n\nSetup\n-----\n.. code:: bash\n\n $ pip install flaskeztest3\n\nMake sure you set the environemnt variable FLASK_APP to the file path of your main app module\n\n.. code:: bash\n\n $ export FLASK_APP=myapp/app.py\n\nflaskeztest will expect there to be a variable named 'app' under this module and another named 'db'.\n'app' should be a Flask object and 'db' should be an SQLAlchemy object.\n\n.. code:: python\n\n # myapp/app.py\n from model import db\n app = Flask(__name__)\n db.init_app(app)\n ...\n\n # myapp/model.py\n from flask_sqlalchemy import SQLAlchemy\n db = SQLAlchemy()\n ...\n\nThen run all test suites with eztest command\n\n.. code:: bash\n\n $ eztest\n\nOther options\n~~~~~~~~~~~~~\n\nfor running one testcase under a suite\n\n.. code:: bash\n\n $ eztest [suite] [testcase]\n\nor\n\nfor running one whole suite\n\n.. code:: bash\n\n $ eztest [suite]\n\nwhere suite is the same as a suite module without .py and testcase is the same as the classname of the testcase\n\nIn General, the eztest object get's its settings from a special test config module which is set in app.config\nas EZTEST_CONFIG_MODULE\n\ni.e:\n\n.. code:: python\n\n # test/config.py\n\n EZTEST_FIXTURES_DIR = 'test/fixtures'\n EZTEST_SUITES_PACKAGE = 'test/suites'\n\nMake sure that the suites package has a ```suite_names``` list in its __init__.py'\n\n.. code:: python\n\n # suites/__init__.py\n suite_names = ['index']\n\nAnd then in normal config module\n\n.. code:: python\n\n # config.py\n\n EZTEST_CONFIG_MODULE='test/config'\n ...\n\nThen in flask app module set config from normal config module\n\n.. code:: python\n\n # myapp.py\n app = Flask(__name__)\n app.from_object('config')\n\n\nDeveloping Testcases\n--------------------\n\nTest cases are pacakged in modules that expose a 'suite' object in its global scope\n\nExample suite 'index':\n\n.. code:: python\n\n # test/suites/index.py\n from flaskeztest import EZTestSuite, EZTestCase\n\n class SimpleTestCase(EZTestCase):\n\n FIXTURE = 'myfixture' # json filename without .json\n\n def runTest(self):\n self.assertTrue(...the truth...)\n\n ...\n\n suite = EZTestSuite('index', __name__)\n\nUsing Fixtures\n--------------\n\nFixtures are a json file representing data to insert into the database before a test case runs\n\nExample:\n\nmyfix.json\n\n.. code:: json\n\n [\n {\n \"model\": \"User\",\n \"row\": {\n \"name\": \"Bob\",\n \"email: \"bob@example.com\"\n }\n }\n ]\n\nor with multiple entries for one model:\n\nmyfix2.json\n\n.. code:: json\n\n [\n {\n \"model\": \"User\",\n \"rows\": [\n {\n \"name\": \"Bob\",\n \"email: \"bob@example.com\"\n },\n {\n \"name\": \"Alice\",\n \"email: \"alice@example.com\"\n }\n ]\n }\n ]\n\nThe EZTestCase class\n--------------------\n\nEZTestCase's setUp method loads the fixture named in its FIXTURE class variable which places the data for each field\ninto the expected_models dict.\n\nFor instance:\n\n.. code:: python\n\n class TC(EZTestCase):\n\n FIXTURE = 'myfix' # Referring to the first fixture above\n\n def runTest(self):\n\n # Passes\n self.assertEqual(self.expected_models['User']['name'], 'Bob')\n\n.. code:: python\n\n class TC2(EZTestCase):\n\n FIXTURE = 'myfix2' # Referring to the second fixture above\n\n def runTest(self):\n\n # Passes as well, but would give index error on first test case\n self.assertEqual(self.expected_models['User'][1]['name], 'Alice')\n\nTwo other useful method of the EZTestCase class is 'get_endpoint' and 'does_field_exist'.\n\nExample:\n\n.. code:: python\n\n class TC(EZTestCase):\n FIXTURE = 'myfix2'\n def runTest(self):\n # Pull up user details for Alice\n self.get_endpoint('index.users', user_id=2) # Assume that index.users take user primary key as argument\n\n # Assert we see second user on page\n self.assertTrue(self.does_field_exist('User', 'name', 1))\n\nIn general most of the methods defined for EZTestCase are useful to include in your own test case classes.\nCheck out flaskeztest/eztestcase.py for more of them.\n\n\nUsing capybara\n--------------\n\nFlaskeztest allows for querying the html returned from pages using capybara.\nCheck out the docs at https://elliterate.github.io/capybara.py/ for all the useful methods that can be applied to the\nthe EZTestCase.page object.\n\nRunning with a reflected SQL database\n-------------------------------------\n\nSometimes flaskeztest may be used with a flask app that is not using declarative models with sqlalchemy, but instead\nwant to simply use a database whose schema is contained within the remote database itself.\n\nOne can specify the remote database that flask-eztest should reflect by setting the EZTEST_REFLECTED_DB_URI in the test config module\n\ni.e\n\n.. code:: python\n\n # test/config.py\n ...\n EZTEST_REFLECTED_DB_URI = 'mysql://...\"\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/cmorterud/flask-eztest", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "flaskeztest3", "package_url": "https://pypi.org/project/flaskeztest3/", "platform": "", "project_url": "https://pypi.org/project/flaskeztest3/", "project_urls": { "Homepage": "https://github.com/cmorterud/flask-eztest" }, "release_url": "https://pypi.org/project/flaskeztest3/0.3.5/", "requires_dist": [ "Flask", "capybara-py", "selenium", "Flask-SQLAlchemy", "termcolor" ], "requires_python": "", "summary": "Tool to make integration testing flask app's using flask_sqlalchemy package easy to set up and organized", "version": "0.3.5" }, "last_serial": 5613765, "releases": { "0.3.1": [ { "comment_text": "", "digests": { "md5": "5224c39b8b46b266ed832a006772c6d9", "sha256": "25ce145f18d65a19e790175a24dcf1193fea3a22b7d472d708cfd796d2ea5db1" }, "downloads": -1, "filename": "flaskeztest3-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5224c39b8b46b266ed832a006772c6d9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10532, "upload_time": "2019-06-20T17:45:10", "url": "https://files.pythonhosted.org/packages/44/67/aa207097508f4d5be16cb3c24c4d069e5e804916161bab00bc649924be56/flaskeztest3-0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d9328cceaee9b9834e4b8d6d5def9544", "sha256": "ca854a65cfd350958758e212ff2d533ebdbb72b367282f5e356d5fca9ec23e43" }, "downloads": -1, "filename": "flaskeztest3-0.3.1.tar.gz", "has_sig": false, "md5_digest": "d9328cceaee9b9834e4b8d6d5def9544", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8789, "upload_time": "2019-06-20T17:45:17", "url": "https://files.pythonhosted.org/packages/02/7e/97da7439a24efd799a35c7be6a7516e2633152ca0b2024981511eb471fbe/flaskeztest3-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "8b32ad1ec3f88cffccc129c4e7a91b50", "sha256": "aaf706191792148e7e36e0628e4b13b624d7a5c0793ecfe227e59bb45102dbd9" }, "downloads": -1, "filename": "flaskeztest3-0.3.2-py3-none-any.whl", "has_sig": false, "md5_digest": "8b32ad1ec3f88cffccc129c4e7a91b50", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10531, "upload_time": "2019-06-20T17:45:13", "url": "https://files.pythonhosted.org/packages/3a/4f/bb4b936eb60e3cbb01bbd1eab404d6a338b0df27476bf637dc4395d2a90f/flaskeztest3-0.3.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "105df9a1bdaa37ef6103520a173de494", "sha256": "d705fb1b7b76dbe49a13c1368ab840da1f918ef760cb363c838cd36aacfe68f2" }, "downloads": -1, "filename": "flaskeztest3-0.3.2.tar.gz", "has_sig": false, "md5_digest": "105df9a1bdaa37ef6103520a173de494", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8793, "upload_time": "2019-06-20T17:45:19", "url": "https://files.pythonhosted.org/packages/a7/88/8353f85d4bcaa67e33666cff1fb1e6a06e5ac619274cbd4e823d2864915d/flaskeztest3-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "156ad54c8c3ba463628e066eee4c8fde", "sha256": "ddd5016b065b46e2119bbb6457e2d68b1e2d1b014c5f4d348674cb50e9fe652b" }, "downloads": -1, "filename": "flaskeztest3-0.3.3-py3-none-any.whl", "has_sig": false, "md5_digest": "156ad54c8c3ba463628e066eee4c8fde", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10533, "upload_time": "2019-06-20T17:45:14", "url": "https://files.pythonhosted.org/packages/99/bf/ec424658611dfef20753a6b3681addeb0bb5004d07289aeff71768afc72d/flaskeztest3-0.3.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "686bf0d766b8e7646af5c4423036af36", "sha256": "9142d609eef4a719acc90dbd01c44e6a8c97c1a49a29decb4c3837c3cf831424" }, "downloads": -1, "filename": "flaskeztest3-0.3.3.tar.gz", "has_sig": false, "md5_digest": "686bf0d766b8e7646af5c4423036af36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8788, "upload_time": "2019-06-20T17:45:21", "url": "https://files.pythonhosted.org/packages/a1/96/bcd94d971f82bc076bd316d581eb07a9799c5c4ad8bc5bef7717b8a7e27e/flaskeztest3-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "a33e4e98e3f1eba599d96cc946cdd8f4", "sha256": "feb32151109a4a5d737f00fb8d9288e5736b24beb34d1d194d967977c482f01f" }, "downloads": -1, "filename": "flaskeztest3-0.3.4-py3-none-any.whl", "has_sig": false, "md5_digest": "a33e4e98e3f1eba599d96cc946cdd8f4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10529, "upload_time": "2019-06-20T17:45:16", "url": "https://files.pythonhosted.org/packages/7b/46/717cb303b6deaa8f1cb84dd930ba9acf6ce2cda540f1df3528dfd2cee964/flaskeztest3-0.3.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5d420575d0d54bea1f7aaa528c3ab056", "sha256": "3b260809b0bc1c5b5912f906496f508cb76b107fb79a97d11acf1878cf4f345f" }, "downloads": -1, "filename": "flaskeztest3-0.3.4.tar.gz", "has_sig": false, "md5_digest": "5d420575d0d54bea1f7aaa528c3ab056", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8080, "upload_time": "2019-06-20T17:45:22", "url": "https://files.pythonhosted.org/packages/df/40/a1b10c1e3c95944d26e41f2129090668eb73bd58b36af1454a06ae9e2619/flaskeztest3-0.3.4.tar.gz" } ], "0.3.5": [ { "comment_text": "", "digests": { "md5": "21b28b46e5197cee76c14b58082c5122", "sha256": "973a338f203bcd048e13e6ef125445c1daf583bffe3f20bf7d69552e2a597f7d" }, "downloads": -1, "filename": "flaskeztest3-0.3.5-py3-none-any.whl", "has_sig": false, "md5_digest": "21b28b46e5197cee76c14b58082c5122", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10580, "upload_time": "2019-07-31T14:26:56", "url": "https://files.pythonhosted.org/packages/c1/6b/f60c9867bdc3073514b8de4364dad11fc4fd3489ef4a126e5668fa1b9ebc/flaskeztest3-0.3.5-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "21b28b46e5197cee76c14b58082c5122", "sha256": "973a338f203bcd048e13e6ef125445c1daf583bffe3f20bf7d69552e2a597f7d" }, "downloads": -1, "filename": "flaskeztest3-0.3.5-py3-none-any.whl", "has_sig": false, "md5_digest": "21b28b46e5197cee76c14b58082c5122", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10580, "upload_time": "2019-07-31T14:26:56", "url": "https://files.pythonhosted.org/packages/c1/6b/f60c9867bdc3073514b8de4364dad11fc4fd3489ef4a126e5668fa1b9ebc/flaskeztest3-0.3.5-py3-none-any.whl" } ] }