def test_controller_with_empty_db(self, db):
"""
Imitate situation when there is no any user available in the db and
sqlalchemy output becomes an empty list []. Message 'There are no
users in the database' instead of users table is expected as default
behavior in this case.
"""
db.session.query.return_value.all.return_value = []
with app.test_client() as test_client:
responce = test_client.get('/users/all')
data = responce.data
self.assertIn('There are no users in the database.', data)
test_all_users_listing.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录