Skip to content

Commit

Permalink
test: index and search view
Browse files Browse the repository at this point in the history
  • Loading branch information
wzyboy committed Jul 9, 2023
1 parent ebe013e commit 784e460
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
class TestIndexView:
def test_index(self, client):
resp = client.get('/tweet/')
assert '<p>Number of Tweets: <code>2</code>' in resp.text
assert 'wzyboy' in resp.text
assert 'Uucky_Lee' in resp.text

def test_index_with_default_user(self, client):
client.application.config['T_DEFAULT_USER'] = 'wzyboy'
resp = client.get('/tweet/')
assert 'wzyboy' in resp.text
assert 'Uucky_Lee' not 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


class TestMediaReplacement:
tweet_id = '1615425412921987074'
media_filename = 'Fmsk2gHacAAJGL0.jpg'
Expand All @@ -22,15 +48,3 @@ 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 784e460

Please sign in to comment.