From 12c8b2659cc9641bbc4e678eefe806bcb5fec8e3 Mon Sep 17 00:00:00 2001 From: Zed Date: Mon, 1 Jun 2020 02:25:56 +0200 Subject: [PATCH] Update tests --- tests/base.py | 4 +--- tests/test_card.py | 6 +++--- tests/test_profile.py | 3 ++- tests/test_quote.py | 17 +++++++---------- tests/test_timeline.py | 33 +++++++-------------------------- tests/test_tweet.py | 16 +++++++--------- 6 files changed, 27 insertions(+), 52 deletions(-) diff --git a/tests/base.py b/tests/base.py index dd1e625..efa1441 100644 --- a/tests/base.py +++ b/tests/base.py @@ -19,10 +19,8 @@ class Quote(object): self.fullname = namerow + '.fullname' self.username = namerow + '.username' self.text = quote + '.quote-text' - self.media = quote + '.quote-media' + self.media = quote + '.quote-media-container' self.unavailable = quote + '.quote.unavailable' - self.sensitive = quote + '.quote-sensitive' - self.badge = quote + '.quote-badge' class Tweet(object): diff --git a/tests/test_card.py b/tests/test_card.py index b3bc6e5..e194fc3 100644 --- a/tests/test_card.py +++ b/tests/test_card.py @@ -71,9 +71,9 @@ no_thumb = [ 'reddit.com'], ['lorenlugosch/status/1115440394148487168', - 'lorenlugosch/end-to-end-SLU', - 'PyTorch code for end-to-end spoken language understanding (SLU) with ASR-based transfer learning - lorenlugosch/end-to-end-SLU', - 'github.com'], + 'Fluent Speech Commands: A dataset for spoken language understanding research', + 'In recent years, with the advent of deep neural networks, the accuracy of speech recognition models have been notably improved which have made possible the production of speech-to-text systems that...', + 'fluent.ai'], ] diff --git a/tests/test_profile.py b/tests/test_profile.py index b07d32b..4f08552 100644 --- a/tests/test_profile.py +++ b/tests/test_profile.py @@ -19,7 +19,8 @@ invalid = [['thisprofiledoesntexist'], ['%']] banner_color = [ ['TheTwoffice', '29, 161, 242'], - ['profiletest', '80, 176, 58'] + ['profiletest', '80, 176, 58'], + ['nim_lang', '24, 26, 36'] ] banner_image = [ diff --git a/tests/test_quote.py b/tests/test_quote.py index dde1cc8..4727f4d 100644 --- a/tests/test_quote.py +++ b/tests/test_quote.py @@ -28,7 +28,7 @@ gif = [ ] video = [ - ['bkuensting/status/1067316003200217088', 'IyCaQlzF0q8u9vBd', '1:05'] + ['bkuensting/status/1067316003200217088', 'IyCaQlzF0q8u9vBd'] ] @@ -46,21 +46,18 @@ class QuoteTest(BaseTestCase): self.open_nitter(tweet) quote = Quote(Conversation.main + " ") self.assert_element_visible(quote.media) - self.assert_element_not_visible(quote.badge) self.assertIn(url, self.get_image_url(quote.media + ' img')) @parameterized.expand(gif) - def test_gif(self, tweet, thumb): + def test_gif(self, tweet, url): self.open_nitter(tweet) quote = Quote(Conversation.main + " ") - self.assert_element_visible(quote.badge) - self.assert_text('GIF', quote.badge) - self.assertIn(thumb, self.get_image_url(quote.media + ' img')) + self.assert_element_visible(quote.media) + self.assertIn(url, self.get_attribute(quote.media + ' source', 'src')) @parameterized.expand(video) - def test_video(self, tweet, thumb, length): + def test_video(self, tweet, url): self.open_nitter(tweet) quote = Quote(Conversation.main + " ") - self.assert_element_visible(quote.badge) - self.assert_text(length, quote.badge) - self.assertIn(thumb, self.get_image_url(quote.media + ' img')) + self.assert_element_visible(quote.media) + self.assertIn(url, self.get_image_url(quote.media + ' img')) diff --git a/tests/test_timeline.py b/tests/test_timeline.py index 1116d9e..e3000c4 100644 --- a/tests/test_timeline.py +++ b/tests/test_timeline.py @@ -3,18 +3,14 @@ from parameterized import parameterized normal = [['mobile_test'], ['mobile_test_2']] -after = [['mobile_test', '627635134573862912'], - ['mobile_test_2', '377196342281388032']] +after = [['mobile_test', 'HBaAgJPsqtGNhA0AAA%3D%3D'], + ['mobile_test_2', 'HBaAgJPsqtGNhA0AAA%3D%3D']] -short = [['mobile_test_8'], ['picman']] +no_more = [['mobile_test_8?cursor=HBaAwJCsk%2F6%2FtgQAAA%3D%3D']] -no_more = [['mobile_test_8?max_position=159455542543257601']] +empty = [['emptyuser'], ['mobile_test_10']] -none_found = [['mobile_test_8?max_position=159455542543257600']] - -empty = [['maybethis'], ['mobile_test_10']] - -protected = [['mobile_test_7'], ['Poop']] +protected = [['mobile_test_7'], ['Empty_user']] class TweetTest(BaseTestCase): @@ -27,20 +23,13 @@ class TweetTest(BaseTestCase): self.assert_element_absent(Timeline.none) @parameterized.expand(after) - def test_after(self, username, index): - self.open_nitter(f'{username}?max_position={index}') + def test_after(self, username, cursor): + self.open_nitter(f'{username}?cursor={cursor}') self.assert_element_present(Timeline.newest) self.assert_element_present(Timeline.older) self.assert_element_absent(Timeline.end) self.assert_element_absent(Timeline.none) - @parameterized.expand(short) - def test_short(self, username): - self.open_nitter(username) - self.assert_text('No more items', Timeline.end) - self.assert_element_absent(Timeline.newest) - self.assert_element_absent(Timeline.older) - @parameterized.expand(no_more) def test_no_more(self, username): self.open_nitter(username) @@ -48,14 +37,6 @@ class TweetTest(BaseTestCase): self.assert_element_present(Timeline.newest) self.assert_element_absent(Timeline.older) - @parameterized.expand(none_found) - def test_none_found(self, username): - self.open_nitter(username) - self.assert_text('No items found', Timeline.none) - self.assert_element_present(Timeline.newest) - self.assert_element_absent(Timeline.older) - self.assert_element_absent(Timeline.end) - @parameterized.expand(empty) def test_empty(self, username): self.open_nitter(username) diff --git a/tests/test_tweet.py b/tests/test_tweet.py index c49d979..c33dab7 100644 --- a/tests/test_tweet.py +++ b/tests/test_tweet.py @@ -11,15 +11,15 @@ timeline = [ [3, 'Test account', 'mobile_test', '3 Mar 2016', '705522133443571712', 'LIVE on #Periscope pscp.tv/w/aadiTzF6dkVOTXZSbX…'], - [6, 'mobile test 2', 'mobile_test_2', '1 Oct 2014', '517449200045277184', + [6, 'mobile test 2', 'mobile_test_2', '2 Oct 2014', '517449200045277184', 'Testing. One two three four. Test.'] ] status = [ [20, 'jack', 'jack', '21 Mar 2006', 'just setting up my twttr'], - [134849778302464000, 'The Twoffice', 'TheTwoffice', '10 Nov 2011', 'test'], + [134849778302464000, 'The Twoffice', 'TheTwoffice', '11 Nov 2011', 'test'], [105685475985080322, 'The Twoffice', 'TheTwoffice', '22 Aug 2011', 'regular tweet'], - [572593440719912960, 'Test account', 'mobile_test', '2 Mar 2015', 'testing test'] + [572593440719912960, 'Test account', 'mobile_test', '3 Mar 2015', 'testing test'] ] invalid = [ @@ -87,8 +87,7 @@ retweet = [ ] reply = [ - ['mobile_test?max_position=471336696307392513', '@mobile_test', '@mobile_test'], - ['mobile_test_2?max_position=375101899214561280', '@mobile_test_2', '@mobile_test'] + ['mobile_test/with_replies', 15] ] @@ -151,8 +150,7 @@ class TweetTest(BaseTestCase): self.assert_text('Tweet not found', '.error-panel') @parameterized.expand(reply) - def test_reply(self, tweet, username, reply): + def test_thread(self, tweet, num): self.open_nitter(tweet) - tweet = get_timeline_tweet(2) - self.assert_text(username, tweet.username) - self.assert_text('Replying to ' + reply, tweet.reply) + thread = self.find_element(f'.timeline > div:nth-child({num})') + self.assertIn(thread.get_attribute('class'), 'thread-line')