{ "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::\n $ pip install flaskeztest\n\nMake sure you set the environemnt variable FLASK_APP to the file path of your main app module\n\n.. code::\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::\n $ eztest\n\nOther options\n~~~~~~~~~~~~~\n\nfor running one testcase under a suite\n\n.. code::\n\n $ eztest [suite] [testcase]\n\nor\n\nfor running one whole suite\n\n.. code::\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 # suites/__init__.py\n suite_names = ['index']\n\nAnd then in normal config module\n\n.. code:: python\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 # 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::\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::\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/Srokit/flask-eztest", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "flaskeztest", "package_url": "https://pypi.org/project/flaskeztest/", "platform": "", "project_url": "https://pypi.org/project/flaskeztest/", "project_urls": { "Homepage": "https://github.com/Srokit/flask-eztest" }, "release_url": "https://pypi.org/project/flaskeztest/0.2.2/", "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.2.2" }, "last_serial": 4356777, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "a1f50ce2b952cc6dddfbeb64203bf56a", "sha256": "2e1d164c481213c5d9f8a95b1b56153595f8ea39cd7e40fedd0e78d0a9b0f1f6" }, "downloads": -1, "filename": "flaskeztest-0.1.tar.gz", "has_sig": false, "md5_digest": "a1f50ce2b952cc6dddfbeb64203bf56a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8174, "upload_time": "2018-05-31T18:00:43", "url": "https://files.pythonhosted.org/packages/34/88/60a2d8205870b791429d6d9b5610f141a867a59b46d3c24fe574574b6b68/flaskeztest-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "0dea75ba7a50aae157269ab0118073e1", "sha256": "b5502f09f5b939facaf675ebbe6ddeac73ce9e1d951445dd8d1e0bfde16d0037" }, "downloads": -1, "filename": "flaskeztest-0.1.1.tar.gz", "has_sig": false, "md5_digest": "0dea75ba7a50aae157269ab0118073e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8193, "upload_time": "2018-05-31T18:02:03", "url": "https://files.pythonhosted.org/packages/45/c8/340fb308334410eb2ddc757f07a9380829867f087fde36f9563be05ab373/flaskeztest-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "2067c90257237da66a0ccb6be80b6090", "sha256": "12b775302d9f506b6dc0c1beaf21d339182d01576eeaa997f5d5307e45f210a5" }, "downloads": -1, "filename": "flaskeztest-0.1.2.tar.gz", "has_sig": false, "md5_digest": "2067c90257237da66a0ccb6be80b6090", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8566, "upload_time": "2018-05-31T18:25:01", "url": "https://files.pythonhosted.org/packages/4a/fb/9885170f1a625e27ae9f4a6f807a1de79a972dbf818d471944f8ceccc5db/flaskeztest-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "21fead40135aefce6bbf7cdd52006d54", "sha256": "a26dd20af36d3e2b630840fb1afce46a042ec26060a00ae98440acd8bcb5a2aa" }, "downloads": -1, "filename": "flaskeztest-0.1.3.tar.gz", "has_sig": false, "md5_digest": "21fead40135aefce6bbf7cdd52006d54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8387, "upload_time": "2018-05-31T18:30:35", "url": "https://files.pythonhosted.org/packages/95/cd/a3b5f9208b5031b64120ad0c35b34afdd6694c419b9fcf713f805f53e852/flaskeztest-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "bb126913b2038ac11ba918eaf14bc4e2", "sha256": "b39744f33c94279d977f526872d5b3fff1c7aa640d409ebef2fb0efa77d4eed3" }, "downloads": -1, "filename": "flaskeztest-0.1.4.tar.gz", "has_sig": false, "md5_digest": "bb126913b2038ac11ba918eaf14bc4e2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8622, "upload_time": "2018-05-31T19:27:44", "url": "https://files.pythonhosted.org/packages/8e/a6/2b8ac33af4dddaf25bdb3f17795d6ed452023cd5186327d8490e7b93bd33/flaskeztest-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "19df2c6e1e09cd1c0375b8e85f0b054b", "sha256": "5625b57da4284997f611376bd48f3dd903aa0b9bf1efd65166d22ac4a64f651b" }, "downloads": -1, "filename": "flaskeztest-0.1.5.tar.gz", "has_sig": false, "md5_digest": "19df2c6e1e09cd1c0375b8e85f0b054b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8615, "upload_time": "2018-05-31T19:59:58", "url": "https://files.pythonhosted.org/packages/a9/aa/a9b87efeb978b5c4ae6fb89718f79d55a0e3705093357ceaee0c592d7820/flaskeztest-0.1.5.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "e7c437813f2b6f530f604a268e4e3a32", "sha256": "e74cc5ab9e5dc5d244c5d0e39c92acfb49660dbea1e8a86670b226b8fefad81c" }, "downloads": -1, "filename": "flaskeztest-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e7c437813f2b6f530f604a268e4e3a32", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9275, "upload_time": "2018-06-01T15:41:15", "url": "https://files.pythonhosted.org/packages/97/f3/e6060e3c2e50f40835fe1ad648c04d3e07702152d9b1d47d02f4b8fdf321/flaskeztest-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "e858d0b42e05ac876848f0ee06307300", "sha256": "897c006c3ae3c2ba03a52ee902c806f79c11269aadb5e551bc39d68502e0f2a4" }, "downloads": -1, "filename": "flaskeztest-0.2.1-py2-none-any.whl", "has_sig": false, "md5_digest": "e858d0b42e05ac876848f0ee06307300", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 12433, "upload_time": "2018-10-09T17:31:43", "url": "https://files.pythonhosted.org/packages/fa/bc/e9b75d3e685769fc785132cfa92b658827e1722f30249a9276efd50bdec3/flaskeztest-0.2.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "25ab600fd730efdcfdfac1119909fb54", "sha256": "65c8868653cc9556d3dc8670b027fa4ed349ffba762ed22fa60d7488329dcfdf" }, "downloads": -1, "filename": "flaskeztest-0.2.1.tar.gz", "has_sig": false, "md5_digest": "25ab600fd730efdcfdfac1119909fb54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9273, "upload_time": "2018-06-01T15:53:46", "url": "https://files.pythonhosted.org/packages/f5/52/be5ca4f31f34d03cabdfa9325fe573cb4c3c72bcc1e6f1dbacd125810ef9/flaskeztest-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "ab4ab6b6c0fe6f7a9ad19b19d2bb4ee2", "sha256": "0c3a169c39d80001fc087640f86a902e1854ae9512ba95d6d1257b62d76fdc14" }, "downloads": -1, "filename": "flaskeztest-0.2.2-py2-none-any.whl", "has_sig": false, "md5_digest": "ab4ab6b6c0fe6f7a9ad19b19d2bb4ee2", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9717, "upload_time": "2018-10-09T17:32:39", "url": "https://files.pythonhosted.org/packages/32/8a/e5ff74afb253e9d8d8bda74b3371d01ffc2d2db2e9a9f691a66691ee34e7/flaskeztest-0.2.2-py2-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ab4ab6b6c0fe6f7a9ad19b19d2bb4ee2", "sha256": "0c3a169c39d80001fc087640f86a902e1854ae9512ba95d6d1257b62d76fdc14" }, "downloads": -1, "filename": "flaskeztest-0.2.2-py2-none-any.whl", "has_sig": false, "md5_digest": "ab4ab6b6c0fe6f7a9ad19b19d2bb4ee2", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9717, "upload_time": "2018-10-09T17:32:39", "url": "https://files.pythonhosted.org/packages/32/8a/e5ff74afb253e9d8d8bda74b3371d01ffc2d2db2e9a9f691a66691ee34e7/flaskeztest-0.2.2-py2-none-any.whl" } ] }