miaou


Namemiaou JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/philip1134/miaou
Summarypyzentao spec generator.
upload_time2023-03-14 05:56:05
maintainer
docs_urlNone
authorPhilip CHAN
requires_python
licenseMIT
keywords python sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =====
miaou
=====

.. image:: https://img.shields.io/pypi/v/miaou.svg?color=orange
   :target: https://pypi.python.org/pypi/miaou
   :alt: PyPI Version

.. image:: https://img.shields.io/pypi/pyversions/miaou.svg
   :target: https://pypi.org/project/miaou/
   :alt: Supported Python versions


``miaou`` 是 `pyzentao <https://github.com/philip1134/pyzentao>`__ 规格文件的自助生成工具。

宋朝的严羽在《沧浪诗话·诗辨》中说:"大抵禅道惟在妙悟,诗道亦在妙悟",于是取名 "妙悟 (miaou)"。


安装
----

.. code:: text

    $ pip install -U miaou

使用
----

调用 ``miaou.generate()`` 方法生成规格文件

.. code:: python

    import miaou

    miaou.generate(
        site_url="http://my.zentao.site/zentao",
        username="admin",
        password="123456",
        scanner="selenium",
        combined_print=True,
        output_path="."
    )

结果放在 /output_path/pyzentao_specs_timestamp 下面

参数说明

- site_url
    你家禅道的域名,一般需要加上 zentao 这个前缀,如 "http://my.zentao.site/zentao",
    注意在禅道 v18 版本后默认没有这个前缀

- username
    登录用户名,用于禅道授权

- password
    登录密码,用于禅道授权

- scanner
    扫描器类型,目前自带扫描器支持 "selenium" 和 "api",也可以自定义扫描器,详见下文

- combined_print
    合并打印规格,默认是 True ,会将规格打印到一个 yaml 文件,否则按 module 打印到不同文件

- output_path
    输出的目录,默认是当前目录

- config
    传给 scanner 的配置参数,应为 dict 类型

扫描器
-------

扫描禅道页面以获得规格,目前支持 ``selenium`` 和 ``api``,也可以自定义扫描器。

selenium
~~~~~~~~~

使用 ``selenium 4.8.0`` 版本以上,默认使用 chromedriver,可根据你的 Chrome 版本,在
`chromedriver <http://chromedriver.storage.googleapis.com/index.html>`__ 下载,并
添加到 path 中。如果要使用 firefox 可在参数中指定,例如

.. code:: python

    import miaou

    miaou.generate(
        ...
        scanner="selenium",
        config={"driver": "firefox"},
    )

api
~~~~

使用禅道对应的 API 生成规格。调用时指定扫描器类型即可

.. code:: python

    import miaou

    miaou.generate(
        ...
        scanner="api",
        ...
    )

注意,使用此扫描器生成的规格与禅道文档有一些不同,比如禅道文档中描述的查询 testsuite 的 API 为

.. code:: text

    GET  /zentao/testsuite.json

使用 ``selenium`` 扫描器生成的规格即为

.. code:: yaml

    testsuite:
        method: GET
        path: testsuite

而禅道 API 查询到的格式类似于

.. code:: text

    GET  /zentao/testsuite-index.json

所以使用 ``api`` 扫描器生成的规格为

.. code:: yaml

    testsuite_index:
        method: GET
        path: testsuite-index

这两种 API 得到的数据是相同的,在转换成 ``pyzentao`` 方法时请以你使用的规格文件为准。

自定义扫描器
~~~~~~~~~~~~~

也可以自定义扫描器,从 miaou.Scanner 继承

.. code:: python

    import miaou

    class MyScanner(miaou.Scanner):
        """doc string"""

        def __init__(self, config):
            ...


然后需要实现如下方法:

- open(self, site_url, username, password)
    一般是获得禅道授权

- close(self)
    清扫工作,没有就不写

- get_module_groups(self, dev_url)
    获得 API 模块页面链接,也就是 ``后台 - 二次开发 - API`` 页面左边栏 ``模块列表`` 下的那些链接。返回模块链接数组 [url...]

- get_apis(self, api_url)
    在指定的模块页面,即 api_url 中获取 API 规格,返回包含dict的数组类似 [{name, method, path, params}]

使用自定义扫描器

.. code:: python

    import miaou

    miaou.generate(
        ...
        scanner=MyScanner(config),
        ...
    )

另,此工具的功能仅在 ``Linux/Python3.10`` 环境下测试,使用其他环境的宝子请自娱自乐 ╮(╯▽╰)╭



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/philip1134/miaou",
    "name": "miaou",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Python SDK",
    "author": "Philip CHAN",
    "author_email": "philip1134@imior.com",
    "download_url": "https://files.pythonhosted.org/packages/72/4a/fd378f9cbffd9cea52dc6620e9b2c639133fc27dc28bdea02476060066e4/miaou-0.2.1.tar.gz",
    "platform": "any",
    "description": "=====\nmiaou\n=====\n\n.. image:: https://img.shields.io/pypi/v/miaou.svg?color=orange\n   :target: https://pypi.python.org/pypi/miaou\n   :alt: PyPI Version\n\n.. image:: https://img.shields.io/pypi/pyversions/miaou.svg\n   :target: https://pypi.org/project/miaou/\n   :alt: Supported Python versions\n\n\n``miaou`` \u662f `pyzentao <https://github.com/philip1134/pyzentao>`__ \u89c4\u683c\u6587\u4ef6\u7684\u81ea\u52a9\u751f\u6210\u5de5\u5177\u3002\n\n\u5b8b\u671d\u7684\u4e25\u7fbd\u5728\u300a\u6ca7\u6d6a\u8bd7\u8bdd\u00b7\u8bd7\u8fa8\u300b\u4e2d\u8bf4\uff1a\"\u5927\u62b5\u7985\u9053\u60df\u5728\u5999\u609f\uff0c\u8bd7\u9053\u4ea6\u5728\u5999\u609f\"\uff0c\u4e8e\u662f\u53d6\u540d \"\u5999\u609f (miaou)\"\u3002\n\n\n\u5b89\u88c5\n----\n\n.. code:: text\n\n    $ pip install -U miaou\n\n\u4f7f\u7528\n----\n\n\u8c03\u7528 ``miaou.generate()`` \u65b9\u6cd5\u751f\u6210\u89c4\u683c\u6587\u4ef6\n\n.. code:: python\n\n    import miaou\n\n    miaou.generate(\n        site_url=\"http://my.zentao.site/zentao\",\n        username=\"admin\",\n        password=\"123456\",\n        scanner=\"selenium\",\n        combined_print=True,\n        output_path=\".\"\n    )\n\n\u7ed3\u679c\u653e\u5728 /output_path/pyzentao_specs_timestamp \u4e0b\u9762\n\n\u53c2\u6570\u8bf4\u660e\n\n- site_url\n    \u4f60\u5bb6\u7985\u9053\u7684\u57df\u540d\uff0c\u4e00\u822c\u9700\u8981\u52a0\u4e0a zentao \u8fd9\u4e2a\u524d\u7f00\uff0c\u5982 \"http://my.zentao.site/zentao\"\uff0c\n    \u6ce8\u610f\u5728\u7985\u9053 v18 \u7248\u672c\u540e\u9ed8\u8ba4\u6ca1\u6709\u8fd9\u4e2a\u524d\u7f00\n\n- username\n    \u767b\u5f55\u7528\u6237\u540d\uff0c\u7528\u4e8e\u7985\u9053\u6388\u6743\n\n- password\n    \u767b\u5f55\u5bc6\u7801\uff0c\u7528\u4e8e\u7985\u9053\u6388\u6743\n\n- scanner\n    \u626b\u63cf\u5668\u7c7b\u578b\uff0c\u76ee\u524d\u81ea\u5e26\u626b\u63cf\u5668\u652f\u6301 \"selenium\" \u548c \"api\"\uff0c\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u626b\u63cf\u5668\uff0c\u8be6\u89c1\u4e0b\u6587\n\n- combined_print\n    \u5408\u5e76\u6253\u5370\u89c4\u683c\uff0c\u9ed8\u8ba4\u662f True \uff0c\u4f1a\u5c06\u89c4\u683c\u6253\u5370\u5230\u4e00\u4e2a yaml \u6587\u4ef6\uff0c\u5426\u5219\u6309 module \u6253\u5370\u5230\u4e0d\u540c\u6587\u4ef6\n\n- output_path\n    \u8f93\u51fa\u7684\u76ee\u5f55\uff0c\u9ed8\u8ba4\u662f\u5f53\u524d\u76ee\u5f55\n\n- config\n    \u4f20\u7ed9 scanner \u7684\u914d\u7f6e\u53c2\u6570\uff0c\u5e94\u4e3a dict \u7c7b\u578b\n\n\u626b\u63cf\u5668\n-------\n\n\u626b\u63cf\u7985\u9053\u9875\u9762\u4ee5\u83b7\u5f97\u89c4\u683c\uff0c\u76ee\u524d\u652f\u6301 ``selenium`` \u548c ``api``\uff0c\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u626b\u63cf\u5668\u3002\n\nselenium\n~~~~~~~~~\n\n\u4f7f\u7528 ``selenium 4.8.0`` \u7248\u672c\u4ee5\u4e0a\uff0c\u9ed8\u8ba4\u4f7f\u7528 chromedriver\uff0c\u53ef\u6839\u636e\u4f60\u7684 Chrome \u7248\u672c\uff0c\u5728\n`chromedriver <http://chromedriver.storage.googleapis.com/index.html>`__ \u4e0b\u8f7d\uff0c\u5e76\n\u6dfb\u52a0\u5230 path \u4e2d\u3002\u5982\u679c\u8981\u4f7f\u7528 firefox \u53ef\u5728\u53c2\u6570\u4e2d\u6307\u5b9a\uff0c\u4f8b\u5982\n\n.. code:: python\n\n    import miaou\n\n    miaou.generate(\n        ...\n        scanner=\"selenium\",\n        config={\"driver\": \"firefox\"},\n    )\n\napi\n~~~~\n\n\u4f7f\u7528\u7985\u9053\u5bf9\u5e94\u7684 API \u751f\u6210\u89c4\u683c\u3002\u8c03\u7528\u65f6\u6307\u5b9a\u626b\u63cf\u5668\u7c7b\u578b\u5373\u53ef\n\n.. code:: python\n\n    import miaou\n\n    miaou.generate(\n        ...\n        scanner=\"api\",\n        ...\n    )\n\n\u6ce8\u610f\uff0c\u4f7f\u7528\u6b64\u626b\u63cf\u5668\u751f\u6210\u7684\u89c4\u683c\u4e0e\u7985\u9053\u6587\u6863\u6709\u4e00\u4e9b\u4e0d\u540c\uff0c\u6bd4\u5982\u7985\u9053\u6587\u6863\u4e2d\u63cf\u8ff0\u7684\u67e5\u8be2 testsuite \u7684 API \u4e3a\n\n.. code:: text\n\n    GET  /zentao/testsuite.json\n\n\u4f7f\u7528 ``selenium`` \u626b\u63cf\u5668\u751f\u6210\u7684\u89c4\u683c\u5373\u4e3a\n\n.. code:: yaml\n\n    testsuite:\n        method: GET\n        path: testsuite\n\n\u800c\u7985\u9053 API \u67e5\u8be2\u5230\u7684\u683c\u5f0f\u7c7b\u4f3c\u4e8e\n\n.. code:: text\n\n    GET  /zentao/testsuite-index.json\n\n\u6240\u4ee5\u4f7f\u7528 ``api`` \u626b\u63cf\u5668\u751f\u6210\u7684\u89c4\u683c\u4e3a\n\n.. code:: yaml\n\n    testsuite_index:\n        method: GET\n        path: testsuite-index\n\n\u8fd9\u4e24\u79cd API \u5f97\u5230\u7684\u6570\u636e\u662f\u76f8\u540c\u7684\uff0c\u5728\u8f6c\u6362\u6210 ``pyzentao`` \u65b9\u6cd5\u65f6\u8bf7\u4ee5\u4f60\u4f7f\u7528\u7684\u89c4\u683c\u6587\u4ef6\u4e3a\u51c6\u3002\n\n\u81ea\u5b9a\u4e49\u626b\u63cf\u5668\n~~~~~~~~~~~~~\n\n\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u626b\u63cf\u5668\uff0c\u4ece miaou.Scanner \u7ee7\u627f\n\n.. code:: python\n\n    import miaou\n\n    class MyScanner(miaou.Scanner):\n        \"\"\"doc string\"\"\"\n\n        def __init__(self, config):\n            ...\n\n\n\u7136\u540e\u9700\u8981\u5b9e\u73b0\u5982\u4e0b\u65b9\u6cd5\uff1a\n\n- open(self, site_url, username, password)\n    \u4e00\u822c\u662f\u83b7\u5f97\u7985\u9053\u6388\u6743\n\n- close(self)\n    \u6e05\u626b\u5de5\u4f5c\uff0c\u6ca1\u6709\u5c31\u4e0d\u5199\n\n- get_module_groups(self, dev_url)\n    \u83b7\u5f97 API \u6a21\u5757\u9875\u9762\u94fe\u63a5\uff0c\u4e5f\u5c31\u662f ``\u540e\u53f0 - \u4e8c\u6b21\u5f00\u53d1 - API`` \u9875\u9762\u5de6\u8fb9\u680f ``\u6a21\u5757\u5217\u8868`` \u4e0b\u7684\u90a3\u4e9b\u94fe\u63a5\u3002\u8fd4\u56de\u6a21\u5757\u94fe\u63a5\u6570\u7ec4 [url...]\n\n- get_apis(self, api_url)\n    \u5728\u6307\u5b9a\u7684\u6a21\u5757\u9875\u9762\uff0c\u5373 api_url \u4e2d\u83b7\u53d6 API \u89c4\u683c\uff0c\u8fd4\u56de\u5305\u542bdict\u7684\u6570\u7ec4\u7c7b\u4f3c [{name, method, path, params}]\n\n\u4f7f\u7528\u81ea\u5b9a\u4e49\u626b\u63cf\u5668\n\n.. code:: python\n\n    import miaou\n\n    miaou.generate(\n        ...\n        scanner=MyScanner(config),\n        ...\n    )\n\n\u53e6\uff0c\u6b64\u5de5\u5177\u7684\u529f\u80fd\u4ec5\u5728 ``Linux/Python3.10`` \u73af\u5883\u4e0b\u6d4b\u8bd5\uff0c\u4f7f\u7528\u5176\u4ed6\u73af\u5883\u7684\u5b9d\u5b50\u8bf7\u81ea\u5a31\u81ea\u4e50 \u256e(\u256f\u25bd\u2570)\u256d\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "pyzentao spec generator.",
    "version": "0.2.1",
    "split_keywords": [
        "python",
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "724afd378f9cbffd9cea52dc6620e9b2c639133fc27dc28bdea02476060066e4",
                "md5": "4d9cca8ffb5ac6ae63667abb17894fbd",
                "sha256": "c85dd660944bab658b4291d9a69c316523280be7f7291429e1e708651c32c481"
            },
            "downloads": -1,
            "filename": "miaou-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4d9cca8ffb5ac6ae63667abb17894fbd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11696,
            "upload_time": "2023-03-14T05:56:05",
            "upload_time_iso_8601": "2023-03-14T05:56:05.757794Z",
            "url": "https://files.pythonhosted.org/packages/72/4a/fd378f9cbffd9cea52dc6620e9b2c639133fc27dc28bdea02476060066e4/miaou-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-14 05:56:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "philip1134",
    "github_project": "miaou",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "miaou"
}
        
Elapsed time: 0.05469s