From 49daad3930c7d252f4fb4ed027749255fe6f3b48 Mon Sep 17 00:00:00 2001 From: Zed Date: Sat, 29 Jun 2019 00:42:53 +0200 Subject: [PATCH] Add timeline tests --- tests/base.py | 8 +++++ tests/test_timeline.py | 73 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 tests/test_timeline.py diff --git a/tests/base.py b/tests/base.py index cceed17..f106f43 100644 --- a/tests/base.py +++ b/tests/base.py @@ -20,6 +20,14 @@ class Profile(object): bio = '.profile-bio' +class Timeline(object): + newest = 'div[class="show-more status-el"]' + older = 'div[class="show-more"]' + end = '.timeline-end' + none = '.timeline-none' + protected = '.timeline-protected' + + class BaseTestCase(BaseCase): def setUp(self): super(BaseTestCase, self).setUp() diff --git a/tests/test_timeline.py b/tests/test_timeline.py new file mode 100644 index 0000000..884350e --- /dev/null +++ b/tests/test_timeline.py @@ -0,0 +1,73 @@ +from base import BaseTestCase, Timeline +from parameterized import parameterized + +normal = [['mobile_test'], ['mobile_test_2']] + +after = [['mobile_test', '627635134573862912'], + ['mobile_test_2', '377196342281388032']] + +short = [['mobile_test_6'], ['mobile_test_8'], ['picman']] + +no_more = [['mobile_test_8?after=159455542543257601']] + +none_found = [['mobile_test_8?after=159455542543257600']] + +empty = [['maybethis'], ['mobile_test_10']] + +protected = [['mobile_test_7'], ['Poop']] + + +class TweetTest(BaseTestCase): + @parameterized.expand(normal) + def test_timeline(self, username): + self.open_nitter(username) + self.assert_element_present(Timeline.older) + self.assert_element_absent(Timeline.newest) + self.assert_element_absent(Timeline.end) + self.assert_element_absent(Timeline.none) + + @parameterized.expand(after) + def test_after(self, username, index): + self.open_nitter(f'{username}?after={index}') + 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 tweets.', 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 tweets.', 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 tweets 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) + self.assert_text('No tweets found.', Timeline.none) + self.assert_element_absent(Timeline.newest) + self.assert_element_absent(Timeline.older) + self.assert_element_absent(Timeline.end) + + @parameterized.expand(protected) + def test_protected(self, username): + self.open_nitter(username) + self.assert_text('This account\'s tweets are protected.', Timeline.protected) + self.assert_element_absent(Timeline.newest) + self.assert_element_absent(Timeline.older) + self.assert_element_absent(Timeline.end)