diff --git a/tests/test_views.py b/tests/test_views.py index b01c5ed..4a5ebbe 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,3 +1,29 @@ +class TestIndexView: + def test_index(self, client): + resp = client.get('/tweet/') + assert '
Number of Tweets: 2
' 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'
@@ -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