我正在尝试在烧瓶中对我的应用程序进行单元测试,但是我对此有点卡住了。我想在我的应用程序路由中添加一个参数,但我不知道该怎么做。有谁能够帮我?
我现在在测试中设置了硬编码的空缺 id,但我将向数据库添加一个连接和一个查询。但我首先想让这个工作
这是路线:
@app.route('/add_application/<vacancy_id>')
def add_application(vacancy_id):
return render_template(
'addapplication.html')
这是我到目前为止的测试:
VACANCY_ID = '5f67bc3643f71774b981ebfc'
def test_addapplicationFromVacancy(self):
tester = app.test_client(self)
tester.post(
'/login',
data=dict(username=USERNAME_USER, password=SPW_TWO),
follow_redirects=True
)
response = tester.get(
'/add_application/',
data={'vacancy_id': VACANCY_ID},
content_type='html/text'
)
print()
self.assertEqual(response.status_code, 200)