Expand profile tests to cover new metadata

This commit is contained in:
Zed 2019-08-12 17:01:45 +02:00
parent 17c187ea15
commit 07cca94916
2 changed files with 21 additions and 7 deletions

View file

@ -19,6 +19,10 @@ class Profile(object):
verified = '.verified-icon' verified = '.verified-icon'
banner = '.profile-banner' banner = '.profile-banner'
bio = '.profile-bio' bio = '.profile-bio'
location = '.profile-location'
website = '.profile-website'
joinDate = '.profile-joindate'
mediaCount = '.photo-rail-header'
class Timeline(object): class Timeline(object):

View file

@ -3,8 +3,9 @@ from parameterized import parameterized
profiles = [ profiles = [
['mobile_test', 'Test account', ['mobile_test', 'Test account',
'Test Account. test test Testing username with @mobile_test_2 and a #hashtag'], 'Test Account. test test Testing username with @mobile_test_2 and a #hashtag',
['mobile_test_2', 'mobile test 2', ''] '📍 San Francisco, CA', '🔗 example.com/foobar', '📅 Joined October 2009', '100'],
['mobile_test_2', 'mobile test 2', '', '', '', '📅 Joined January 2011', '13']
] ]
verified = [['jack'], ['elonmusk']] verified = [['jack'], ['elonmusk']]
@ -28,15 +29,24 @@ banner_image = [
class ProfileTest(BaseTestCase): class ProfileTest(BaseTestCase):
@parameterized.expand(profiles) @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.open_nitter(username)
self.assert_exact_text(fullname, Profile.fullname) self.assert_exact_text(fullname, Profile.fullname)
self.assert_exact_text(f'@{username}', Profile.username) self.assert_exact_text(f'@{username}', Profile.username)
if len(bio) > 0: tests = [
self.assert_exact_text(bio, Profile.bio) (bio, Profile.bio),
else: (location, Profile.location),
self.assert_element_absent(Profile.bio) (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) @parameterized.expand(verified)
def test_verified(self, username): def test_verified(self, username):