1
0
mirror of https://github.com/zedeus/nitter synced 2024-11-25 03:09:22 +01:00
nitter/tests/test_thread.py

53 lines
1.9 KiB
Python
Raw Normal View History

2019-07-01 07:12:46 +02:00
from base import BaseTestCase, Conversation
from parameterized import parameterized
thread = [
['octonion/status/975253897697611777', [], 'Based', ['Crystal', 'Julia'], [
2019-09-13 12:38:41 +02:00
['For', 'Then', 'Okay,', 'Python', 'Speed', 'Java', 'Coding', 'I', 'You'],
2019-07-01 07:12:46 +02:00
['yeah,']
]],
['octonion/status/975254452625002496', ['Based'], 'Crystal', ['Julia'], []],
['octonion/status/975256058384887808', ['Based', 'Crystal'], 'Julia', [], []],
['gauravssnl/status/975364889039417344',
['Based', 'For', 'Then', 'Okay,', 'Python'], 'Speed', [], [
2019-09-13 12:38:41 +02:00
['Java', 'Coding', 'I', 'You'], ['JAVA!']
2019-07-01 07:12:46 +02:00
]],
['d0m96/status/1141811379407425537', [], 'I\'m',
['The', 'The', 'Today', 'Some', 'If', 'There', 'Above'],
2019-11-14 07:27:39 +01:00
[['Thank', 'Also,']]],
2019-07-01 07:12:46 +02:00
['gmpreussner/status/999766552546299904', [], 'A', [],
2020-01-03 16:29:47 +01:00
[['I', 'Especially'], ['I']]]
2019-07-01 07:12:46 +02:00
]
class ThreadTest(BaseTestCase):
def find_tweets(self, selector):
return self.find_elements(f"{selector} {Conversation.tweet_text}")
def compare_first_word(self, tweets, selector):
if len(tweets) > 0:
self.assert_element_visible(selector)
for i, tweet in enumerate(self.find_tweets(selector)):
text = tweet.text.split(" ")[0]
self.assert_equal(tweets[i], text)
@parameterized.expand(thread)
def test_thread(self, tweet, before, main, after, replies):
self.open_nitter(tweet)
self.assert_element_visible(Conversation.main)
self.assert_text(main, Conversation.main)
self.assert_text(main, Conversation.main)
self.compare_first_word(before, Conversation.before)
self.compare_first_word(after, Conversation.after)
for i, reply in enumerate(self.find_elements(Conversation.thread)):
selector = Conversation.replies + f" > div:nth-child({i + 1})"
self.compare_first_word(replies[i], selector)