Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Jun 2, 2020
1 parent 81d6d1a commit 12c8b26
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 52 deletions.
4 changes: 1 addition & 3 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ def __init__(self, tweet=''):
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):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
'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'],

]

Expand Down
3 changes: 2 additions & 1 deletion tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

banner_color = [
['TheTwoffice', '29, 161, 242'],
['profiletest', '80, 176, 58']
['profiletest', '80, 176, 58'],
['nim_lang', '24, 26, 36']
]

banner_image = [
Expand Down
17 changes: 7 additions & 10 deletions tests/test_quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
]

video = [
['bkuensting/status/1067316003200217088', 'IyCaQlzF0q8u9vBd', '1:05']
['bkuensting/status/1067316003200217088', 'IyCaQlzF0q8u9vBd']
]


Expand All @@ -46,21 +46,18 @@ def test_image(self, tweet, url):
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'))
33 changes: 7 additions & 26 deletions tests/test_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@

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):
Expand All @@ -27,35 +23,20 @@ def test_timeline(self, username):
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)
self.assert_text('No more items', Timeline.end)
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)
Expand Down
16 changes: 7 additions & 9 deletions tests/test_tweet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
[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 = [
Expand Down Expand Up @@ -87,8 +87,7 @@
]

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]
]


Expand Down Expand Up @@ -151,8 +150,7 @@ def test_invalid_id(self, tweet):
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')

0 comments on commit 12c8b26

Please sign in to comment.