def test_search(self):
create_user()
setup_journal()
with self.app.test_client() as c:
with c.session_transaction() as sess:
sess['user_id'] = '1'
sess['_fresh'] = True
# trigger refresh of journal
rv = c.get('/admin/journal/refresh', follow_redirects=True)
rv = c.get('admin/journal/search?q={q}'.format(q="graduate"), follow_redirects=True)
six.assertRegex(self, str(rv.data), r'2012-10-03',
"search for a findable string finds something")
rv = c.get('admin/journal/search?q={q}'.format(q="zorkle"), follow_redirects=True)
if six.PY2:
self.assertNotRegexpMatches(rv.data, r'2012-10-03',
"search for a unfindable string finds nothing")
elif six.PY3:
self.assertNotRegex(str(rv.data), r'2012-10-03',
"search for a unfindable string finds nothing")
评论列表
文章目录