cosven / cosven.github.io

个人零碎笔记,博客草稿,阅读笔记
10 stars 0 forks source link

10 月份第三周 #7

Closed cosven closed 8 years ago

cosven commented 8 years ago
cosven commented 8 years ago

防止需要被mock的对象在mock之前被初始化

cosven commented 8 years ago

坑爹的地方

原先的代码结构根本不能做 mock。

有多麻烦:

  1. 首先,把flask app初始化改成由函数创建,传入 zk_clients 参数进去。
1. 运行脚本要改
2. 所有的测试也要相似的改
3. 一些地方引用了 app ,就没办法
cosven commented 8 years ago

对API URL 设计的思考

以env为主体,service, profile 看成子资源 (目前已经实现的)

以 Service 为主体 (另一种方案,未实现)

env, profile 看成子资源

envprofile 看成属性。(感觉这种,大部分的逻辑都会集中到在一个controller中)

  1. 列出某个所有 Service

/api/services

/api/services

  1. 拿到服务的所有 profile

/api/services/<service>/<env>/profiles

/api/services/<service>?env=<env>

  1. CRUD profile的详细信息

/api/services/<service>/<env>/<profile_name>

/api/services/<service>?env=<env>&profile=<profile>

如果profile_name的名字是profiles,可能会出问题

  1. 创建、删除 service

/api/services/<service>

  1. 设置默认的 profile

/api/services/<service>/<env>/profiles/default

POST

/api/services/<service>/<env>/<profile>/history

cosven commented 8 years ago

raise_for_status: If we made a bad request (a 4XX client error or 5XX server error response), we can raise it with。

cosven commented 8 years ago

API 返回信息的思考

返回数据中的message应该是对错误的描述,不应该包含数据...