mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-12 02:56:29 +00:00
Add profile banner tests
This commit is contained in:
parent
f410720d1a
commit
c78ee6bca0
1 changed files with 28 additions and 8 deletions
|
@ -2,24 +2,33 @@ from base import BaseTestCase, Profile
|
||||||
from parameterized import parameterized
|
from parameterized import parameterized
|
||||||
|
|
||||||
profiles = [
|
profiles = [
|
||||||
['Test account', 'mobile_test',
|
['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', '']
|
['mobile_test_2', 'mobile test 2', '']
|
||||||
]
|
]
|
||||||
|
|
||||||
verified = [['jack'], ['elonmusk']]
|
verified = [['jack'], ['elonmusk']]
|
||||||
|
|
||||||
protected = [
|
protected = [
|
||||||
['mobile test 7', 'mobile_test_7', ''],
|
['mobile_test_7', 'mobile test 7', ''],
|
||||||
['Randy', 'Poop', 'Social media fanatic.']
|
['Poop', 'Randy', 'Social media fanatic.']
|
||||||
]
|
]
|
||||||
|
|
||||||
invalid = [['thisprofiledoesntexist'], ['%']]
|
invalid = [['thisprofiledoesntexist'], ['%']]
|
||||||
|
|
||||||
|
banner_color = [
|
||||||
|
['TheTwoffice', '29, 161, 242'],
|
||||||
|
['profiletest', '80, 176, 58']
|
||||||
|
]
|
||||||
|
|
||||||
class TestProfile(BaseTestCase):
|
banner_image = [
|
||||||
|
['mobile_test', 'profile_banners%2F82135242%2F1384108037%2F1500x500']
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class ProfileTest(BaseTestCase):
|
||||||
@parameterized.expand(profiles)
|
@parameterized.expand(profiles)
|
||||||
def test_data(self, fullname, username, bio):
|
def test_data(self, username, fullname, bio):
|
||||||
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)
|
||||||
|
@ -35,12 +44,11 @@ class TestProfile(BaseTestCase):
|
||||||
self.assert_element_visible(Profile.verified)
|
self.assert_element_visible(Profile.verified)
|
||||||
|
|
||||||
@parameterized.expand(protected)
|
@parameterized.expand(protected)
|
||||||
def test_protected(self, fullname, username, bio):
|
def test_protected(self, username, fullname, bio):
|
||||||
self.open_nitter(username)
|
self.open_nitter(username)
|
||||||
self.assert_element_visible(Profile.protected)
|
self.assert_element_visible(Profile.protected)
|
||||||
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)
|
||||||
self.assert_text('Tweets are protected')
|
|
||||||
|
|
||||||
if len(bio) > 0:
|
if len(bio) > 0:
|
||||||
self.assert_text(bio, Profile.bio)
|
self.assert_text(bio, Profile.bio)
|
||||||
|
@ -56,3 +64,15 @@ class TestProfile(BaseTestCase):
|
||||||
# TODO: detect suspended
|
# TODO: detect suspended
|
||||||
self.open_nitter('test')
|
self.open_nitter('test')
|
||||||
self.assert_text(f'User "test" not found')
|
self.assert_text(f'User "test" not found')
|
||||||
|
|
||||||
|
@parameterized.expand(banner_color)
|
||||||
|
def test_banner_color(self, username, color):
|
||||||
|
self.open_nitter(username)
|
||||||
|
banner = self.find_element(Profile.banner + '-color')
|
||||||
|
self.assertIn(color, banner.value_of_css_property('background-color'))
|
||||||
|
|
||||||
|
@parameterized.expand(banner_image)
|
||||||
|
def test_banner_image(self, username, url):
|
||||||
|
self.open_nitter(username)
|
||||||
|
banner = self.find_element(Profile.banner + ' img')
|
||||||
|
self.assertIn(url, banner.get_attribute('src'))
|
||||||
|
|
Loading…
Reference in a new issue