From 07cca94916fdf4050548915c6e57f5ff543514fe Mon Sep 17 00:00:00 2001 From: Zed Date: Mon, 12 Aug 2019 17:01:45 +0200 Subject: [PATCH] Expand profile tests to cover new metadata --- tests/base.py | 4 ++++ tests/test_profile.py | 24 +++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/base.py b/tests/base.py index d909aa5..3ef80b7 100644 --- a/tests/base.py +++ b/tests/base.py @@ -19,6 +19,10 @@ class Profile(object): verified = '.verified-icon' banner = '.profile-banner' bio = '.profile-bio' + location = '.profile-location' + website = '.profile-website' + joinDate = '.profile-joindate' + mediaCount = '.photo-rail-header' class Timeline(object): diff --git a/tests/test_profile.py b/tests/test_profile.py index 8d3ebae..6441a7a 100644 --- a/tests/test_profile.py +++ b/tests/test_profile.py @@ -3,8 +3,9 @@ from parameterized import parameterized profiles = [ ['mobile_test', 'Test account', - 'Test Account. test test Testing username with @mobile_test_2 and a #hashtag'], - ['mobile_test_2', 'mobile test 2', ''] + 'Test Account. test test Testing username with @mobile_test_2 and a #hashtag', + '📍 San Francisco, CA', '🔗 example.com/foobar', '📅 Joined October 2009', '100'], + ['mobile_test_2', 'mobile test 2', '', '', '', '📅 Joined January 2011', '13'] ] verified = [['jack'], ['elonmusk']] @@ -28,15 +29,24 @@ banner_image = [ class ProfileTest(BaseTestCase): @parameterized.expand(profiles) - def test_data(self, username, fullname, bio): + def test_data(self, username, fullname, bio, location, website, joinDate, mediaCount): self.open_nitter(username) self.assert_exact_text(fullname, Profile.fullname) self.assert_exact_text(f'@{username}', Profile.username) - if len(bio) > 0: - self.assert_exact_text(bio, Profile.bio) - else: - self.assert_element_absent(Profile.bio) + tests = [ + (bio, Profile.bio), + (location, Profile.location), + (website, Profile.website), + (joinDate, Profile.joinDate), + (f"🖼 {mediaCount} Photos and videos", Profile.mediaCount) + ] + + for text, selector in tests: + if len(text) > 0: + self.assert_exact_text(text, selector) + else: + self.assert_element_absent(selector) @parameterized.expand(verified) def test_verified(self, username):