{ "info": { "author": "Thomas Huang", "author_email": "lyanghwy@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "Natume\n###########\n\nNatume is a http dsl test tool help you easily build test for mobile application.\n\n\nHow to install\n==============\n\nFirstly download or fetch it form github then run the command in shell:\n\n.. code-block:: bash\n\n cd natume # the path to the project\n python setup.py install\n\n\nDevelopment\n===========\n\nFork or download it, then run:\n\n.. code-block:: bash \n\n cd natume # the path to the project\n python setup.py develop\n\n\n\nCompatibility\n=============\n\nBuilt and tested under Python 2.7 \n\n\nHow to write your dsl http test\n================================\n\n\nThe dsl rule most like ini file format.\n\n\ncomment\n--------------\n\nThe line begins with \"#\" is a comment line\n\n\n\n\n\nmethod section\n---------------\n\nThe line begins with a ``[`` and ends with ``]`` a test method section::\n\n\n\t[add friend]\n\t# comment\n\t> POST /request fid=1233 access_token=\"Blabla\"\n\tcode: 200\n\tcontent <- OK\n\n\nintialize your test instance variables\n-----------------------------------------\n\nYou can intialize or bind the variables use intialize method::\n\n\t[intialize]\n\n\t@key = \"key\"\n\t@page = 2\n\n\nAll key begins with \"@\" will build to testcase instance attributes, like @key is compiled to \"self.key\",\nand intialize method is called in SetUp method.\n\n\n\nhttp send command\n--------------------\n\n\nThe line begins with ``>`` is a http request::\n\n\t> GET /post key=\"Blabla\" page=1\n\t> POST /profile name=\"Blabla\" email=\"e@e.com\"\n\n\nset request header\n---------------------\n\n\nSometimes, the request requires to set headers, you can use \"=>\" command to set header ::\n\n\treferer => https://www.example.com/\n\tReferer => https://www.example.com/\n\tAccept-Encoding => gzip, deflate, sdch\n\tAccept_encoding => gzip, deflate, sdch\n\n\n.. Note:: the head key is caseinsentive and key parts can will auto trasfer to the http real key pattern.\n\nAssert the response\n----------------------\n\nCurrently, supports content regex match assert, json data assert, and response header assert.\nand supports three assert tokens.\n\n:\n^^^^^^^^^^\n\n\"\":\"\" assert token, it is compiled to assertEqual method, to check a header or response text, or response json data::\n\n\n\tcode: 200\n\tcontent_tpye : application/json\n\tcharset: utf-8\n\n\n<-\n^^^^^^^^^^\n\nit is compiled to assertIn method in response content test::\n\n\n\tcontent <- OK\n\tjson <- ['data']['title'] = \"Blabla\"\n\n=~\n^^^^^^^^^^\n\n\nit is compiled to to check a regex text in response content test, the regex value must begins and ends with \"/\", and can combine with the regex options::\n\n\tcontent =~ /OK/\n\tjson =~ ['data']['title'] = /Blabla/i\n\n.. Note:: Currently supports three regex compile options \"i\"(re.I), \"m\" (re.M), \"s\" (re.S).\n\nTest response header info\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nWhen set code command:\n\n\tcode: 200\n\nit will assert response status code.\n\nWhen set content_type command:\n\n\tcontent_tpye : application/json\n\nit will assert response content_type.\n\nWhen set charset command:\n\n\tcharset: utf-8\n\nit will assert response charset.\n\n\n.. Note:: When uses \":\" to test response info, if the assert key not in (content, json, code, content_type, charset)\uff0c it will test the response head info.\n\n\n\ncontent\n^^^^^^^^^^^\n\nwhen we test the response text, supports the commands as below::\n\n\tcontent: OK\n\tcontent <- OK\n\tcontent =~ /Ok/i\n\n\njson\n~~~~~~~~~\n\n\nWhen we test the response is json data, we can use json key to assert::\n\n\n\n\tjson <- ['data']['title'] = 'title'\n\tjson: ['data']['trackList'][0]['song_id'] = '1772167572'\n\tjson: ['data']['type_id'] = 1\n\n \t# date size\n\tjson ~~ ['data'] = 56\n\n\n\nDSLWebTestCase\n=================\n\n\nWhen you wanna write the dsl test in unittest testcase, please write test method in testcase class doc:\n\n\n\n.. code-block:: python\n\n\n\tfrom natume import DSLWebTestCase, WebClient\n\timport unittest\n\n\tclass DSLWebTestCaseTest(DSLWebTestCase):\n\t u\"\"\"\n\t [index]\n\t > GET /\n\n\t content <- \u867e\u7c73\u97f3\u4e50\u7f51(xiami.com)\n\n\n\t [song api]\n\t > GET /song/playlist/id/1772167572/type/0/cat/json\n\n\t content_type: application/json\n\t charset: utf-8\n\n\t json: ['data']['trackList'][0]['title'] = u'\u518d\u9047\u89c1'\n\t json: ['data']['trackList'][0]['song_id'] = '1772167572'\n\t json: ['data']['type_id'] = 1\n\n\t [search]\n\t > GET /search/collect key='\u82cf\u6253\u7eff'\n\n\t code: 200\n\t content <- \u82cf\u6253\u7eff\u6b4c\u66f2: \u6700\u597d\u542c\u7684\u82cf\u6253\u7eff\u97f3\u4e50\u8bd5\u542c\n\t content =~ /Xiami.com/i\n\n\n\t [search page 2]\n\t > GET /search/collect/page/2 key=@key order='weight'\n\n\t code: 200\n\t content <- \u82cf\u6253\u7eff\u6b4c\u66f2: \u6700\u597d\u542c\u7684\u82cf\u6253\u7eff\u97f3\u4e50\u8bd5\u542c\n\t content =~ /XiaMi.com/i\n\t \"\"\"\n\t @classmethod\n\t def setUpClass(self):\n\t self.client = WebClient('http://www.xiami.com')\n\t self.key = '\u82cf\u6253\u7eff'\n\n\t def test_t(self):\n\t self.t(u\"\"\"\n\t > GET /search/collect/page/2 key=@key order='weight'\n\n\t code: 200\n\t content <- \u82cf\u6253\u7eff\u6b4c\u66f2: \u6700\u597d\u542c\u7684\u82cf\u6253\u7eff\u97f3\u4e50\u8bd5\u542c\n\t \"\"\")\n\n\nYou can also use ``t`` method to build request section test.\n\n\n.. Note:: The WebClient will keep and fresh the cookies and etag when you use a same webclient to test your application.\n\n\n\nRun test in terminal\n==========================\n\n\nLike unittest, natume can run in terminal also, can test directories and files.\n\n.. code-block bash\n\n\tpython -m natume -h\n\tusage: natume [options] test_dirs (or files)...\n\n\tpositional arguments:\n\t test_dirs the test dirs\n\n\toptional arguments:\n\t -h, --help show this help message and exit\n\t -u URL, --url URL the url for test\n\t -d, --debug open debug mode (default False)\n\n\nHere are the demos, the test file in project examples directory:\n\n.. code-block:: bash\n\n\t$ python -m natume -u http://www.xiami.com examples/xiami.smoke -d\n\ttest_index (__builtin__.XiamiTest) ... ok\n\ttest_search (__builtin__.XiamiTest) ... ok\n\ttest_search_page_2 (__builtin__.XiamiTest) ... ok\n\ttest_song_api (__builtin__.XiamiTest) ... ok\n\n\t----------------------------------------------------------------------\n\tRan 4 tests in 0.674s\n\n\tOK\n\n\n.. code-block:: bash\n\n\t$ python -m natume -u http://www.xiami.com examples -d\n\ttest_index (__builtin__.XiamiTest) ... ok\n\ttest_search (__builtin__.XiamiTest) ... ok\n\ttest_search_page_2 (__builtin__.XiamiTest) ... ok\n\ttest_song_api (__builtin__.XiamiTest) ... ok\n\n\t----------------------------------------------------------------------\n\tRan 8 tests in 2.893s\n\n\tOK\n\n\nLICENSE\n=======\n\n Copyright (C) 2015 Thomas Huang\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, version 2 of the License.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see .", "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/whiteclover/natume", "keywords": "http,test", "license": "GPL 2", "maintainer": null, "maintainer_email": null, "name": "Natume", "package_url": "https://pypi.org/project/Natume/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Natume/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/whiteclover/natume" }, "release_url": "https://pypi.org/project/Natume/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "HTTP DSL Test Tool", "version": "0.1.0" }, "last_serial": 2055754, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "dce903ecceded8ac766c67bd84a9f5f3", "sha256": "cbad3a545e588ebf46e90145ced02999eb4ab1c074c007650088065cc955be30" }, "downloads": -1, "filename": "Natume-0.1.0.tar.gz", "has_sig": false, "md5_digest": "dce903ecceded8ac766c67bd84a9f5f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14339, "upload_time": "2016-04-10T03:13:11", "url": "https://files.pythonhosted.org/packages/e8/18/50e356da783ab39972e9d5a923e89374775522f880e5dd7a3c73c287a58f/Natume-0.1.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "7ed68f0223e7b3024ccf6aa68f5ce201", "sha256": "e9446df460c92733250e3041bf32147e555513731c2d07d90867090880adbeb3" }, "downloads": -1, "filename": "Natume-0.1.0.zip", "has_sig": false, "md5_digest": "7ed68f0223e7b3024ccf6aa68f5ce201", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26648, "upload_time": "2016-04-10T03:13:04", "url": "https://files.pythonhosted.org/packages/10/c7/85fd4434537b9dbca5816474d5b6e7b69c3383dd081744f5dde3f3b874a5/Natume-0.1.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dce903ecceded8ac766c67bd84a9f5f3", "sha256": "cbad3a545e588ebf46e90145ced02999eb4ab1c074c007650088065cc955be30" }, "downloads": -1, "filename": "Natume-0.1.0.tar.gz", "has_sig": false, "md5_digest": "dce903ecceded8ac766c67bd84a9f5f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14339, "upload_time": "2016-04-10T03:13:11", "url": "https://files.pythonhosted.org/packages/e8/18/50e356da783ab39972e9d5a923e89374775522f880e5dd7a3c73c287a58f/Natume-0.1.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "7ed68f0223e7b3024ccf6aa68f5ce201", "sha256": "e9446df460c92733250e3041bf32147e555513731c2d07d90867090880adbeb3" }, "downloads": -1, "filename": "Natume-0.1.0.zip", "has_sig": false, "md5_digest": "7ed68f0223e7b3024ccf6aa68f5ce201", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26648, "upload_time": "2016-04-10T03:13:04", "url": "https://files.pythonhosted.org/packages/10/c7/85fd4434537b9dbca5816474d5b6e7b69c3383dd081744f5dde3f3b874a5/Natume-0.1.0.zip" } ] }