Tag: RESTful
-
Model-Based Testing for RESTful API
工作需要,要寫 API 相關的 test cases。目前只有先測 API interface 的部份,寫著寫著發現我根本在造重複的輪子,幾乎在做複製貼上跟填空的工作,程式碼大概長的像下面這樣: class Foo_0000: “”” POST /login/token “”” def __init__(self): self.REST_PATH = “/login/token” self.headers = {“content-type”: “application/json”} self.parse_response = {{ 200: self.parse_response_200, 400: self.parse_response_400, 500: self.parse_response_500 }} def post_api(self, payload): payload = json.dumps(payload) r = requests.post(CONFIG.HOST + self.REST_PATH, data=payload, headers=self.headers) return r def parse_response_200(self, payload, r): if self.expect_status_code !=…