Skip to content

Commit

Permalink
fix: search view not working
Browse files Browse the repository at this point in the history
  • Loading branch information
wzyboy committed Jul 9, 2023
1 parent 98d4f93 commit ebe013e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ash.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,11 @@ def search_tweet(ext: str):
user = flask.request.args.get('u', '')
index = flask.request.args.get('i', '')
if keyword := flask.request.args.get('q', ''):
tweets = tdb.search(
tweets = list(tdb.search(
keyword=keyword,
user_screen_name=user,
index=index,
)
))
else:
tweets = []

Expand Down
12 changes: 12 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@ def test_fs_media(self, client):
client.application.config['T_MEDIA_FS_PATH'] = './media'
resp = client.get(f'/tweet/{self.tweet_id}.html')
assert f'/tweet/media/pbs.twimg.com/media/{self.media_filename}' in resp.text


class TestSearchView:
keywords = ('please connect a keyboard', 'This guy found a starving dog')

def test_search(self, client):
resp = client.get(
'/tweet/search.html',
query_string={'q': '*'}
)
for kw in self.keywords:
assert kw in resp.text

0 comments on commit ebe013e

Please sign in to comment.