def test_permalinks_work(self):
db = InMemoryDemoDatabase()
app = make_app(build_dir=self.TEST_DIR, demo_db=db)
predictor = CountingPredictor()
app.predictors = {"counting": predictor}
app.testing = True
client = app.test_client()
def post(endpoint: str, data: JsonDict) -> Response:
return client.post(endpoint, content_type="application/json", data=json.dumps(data))
data = {"some": "input"}
response = post("/predict/counting", data=data)
assert response.status_code == 200
result = json.loads(response.get_data())
slug = result.get("slug")
assert slug is not None
response = post("/permadata", data={"slug": "not the right slug"})
assert response.status_code == 400
response = post("/permadata", data={"slug": slug})
assert response.status_code == 200
result2 = json.loads(response.get_data())
assert set(result2.keys()) == {"modelName", "requestData", "responseData"}
assert result2["modelName"] == "counting"
assert result2["requestData"] == data
assert result2["responseData"] == result
评论列表
文章目录