V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
lianghui
V2EX  ›  Python

一个 dsl 的 smoke tool for mobile app 的想法

  •  
  •   lianghui ·
    whiteclover · 2015-01-31 13:34:14 +08:00 · 1846 次点击
    这是一个创建于 3382 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近有个想法,想造一个dsl 用来做简单的移动应用的http 冒烟测试。不知大家是否有这种需求,或者提议

    [initialize]

    @limit = 12
    @offset = 24

    [index]

    > GET /
    accept_encoding => gzip, deflate, sdch

    code: 200
    content <- LoginModal


    [item]


    > GET /api/channels/1/items limit=@limit offset=@offset

    code: 200

    json: ['code']=200
    json: ['data']['items'][1]['type'] = "post"



    上面的dsl将会生成下面的code




    class Testtest(WebTestCase):

    def setUp(self):
    self.client = client
    self.initialize()

    def initialize(self):
    self.limit=12
    self.offset=24

    def test_index(self):
    headers = {}
    headers['Accept-Encoding'] = 'gzip, deflate, sdch'
    data = {}
    self.client.do_request('GET', '/', data, headers)

    self.assertCode('200')
    self.assertContent('<-', 'LoginModal()')

    def test_item(self):
    headers = {}
    data = {}
    data['limit'] = self.limit
    data['offset'] = self.offset
    self.client.do_request('GET', '/api/channels/1/items', data, headers)

    self.assertCode('200')
    json = self.client.json
    json = json['code']
    self.assertJson(json, ':', 200)
    json = self.client.json
    json = json['data']['items'][1]['type']
    self.assertJson(json, ':', "po1st")
    3 条回复    2015-02-02 12:02:26 +08:00
    reorx
        1
    reorx  
       2015-02-01 22:48:20 +08:00
    好想法,不过我觉得 DSL 语法不需要自己生造,用已有语法比如 yaml 就好,方便做解析。另外,稍微往远想一点,既然现在已经有一些 web api descriptions language (api blueprint, swagger etc.),不如作为他们的插件存在,这样一份文件既可以描述 API,作为文档,又同时可以生成测试代码,执行测试,就像 doctest 那样,岂不一举两得。

    refs:
    - https://apiblueprint.org/
    - http://swagger.io/
    lianghui
        2
    lianghui  
    OP
       2015-02-02 09:31:21 +08:00
    @reorx 解析倒不难,基本已经写好了,不过不想做成doc的,因为本身关心的是测试。
    reorx
        3
    reorx  
       2015-02-02 12:02:26 +08:00
    嗯,专注做一件事也不错,希望可以提供生成 nose 写法的选项 XD
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1350 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:05 · PVG 01:05 · LAX 10:05 · JFK 13:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.