1
0
mirror of https://github.com/zedeus/nitter synced 2024-11-10 21:00:19 +01:00
nitter/tests/base.py

75 lines
1.8 KiB
Python
Raw Normal View History

2019-06-28 04:56:02 +02:00
from seleniumbase import BaseCase
class Tweet(object):
def __init__(self, tweet=''):
namerow = tweet + '.tweet-header '
2019-06-28 04:56:02 +02:00
self.fullname = namerow + '.fullname'
self.username = namerow + '.username'
self.date = namerow + '.tweet-date'
self.text = tweet + '.status-content.media-body'
2019-06-29 00:41:57 +02:00
self.retweet = tweet = '.retweet'
2019-06-28 04:56:02 +02:00
class Profile(object):
fullname = '.profile-card-fullname'
username = '.profile-card-username'
protected = '.protected-icon'
verified = '.verified-icon'
2019-06-29 00:41:57 +02:00
banner = '.profile-banner'
bio = '.profile-bio'
2019-06-28 04:56:02 +02:00
2019-06-29 00:42:53 +02:00
class Timeline(object):
newest = 'div[class="status-el show-more"]'
2019-06-29 00:42:53 +02:00
older = 'div[class="show-more"]'
end = '.timeline-end'
none = '.timeline-none'
protected = '.timeline-protected'
2019-07-01 07:12:46 +02:00
class Conversation(object):
main = '.main-tweet'
before = '.before-tweet'
after = '.after-tweet'
replies = '.replies'
thread = '.reply'
tweet = '.status-el'
tweet_text = '.status-content'
2019-06-30 00:53:07 +02:00
class Poll(object):
votes = '.poll-info'
choice = '.poll-meter'
value = 'poll-choice-value'
option = 'poll-choice-option'
leader = 'leader'
2019-07-01 00:29:40 +02:00
class Media(object):
container = '.attachments'
row = '.gallery-row'
image = '.still-image'
video = '.gallery-video'
gif = '.gallery-gif'
2019-06-28 04:56:02 +02:00
class BaseTestCase(BaseCase):
def setUp(self):
super(BaseTestCase, self).setUp()
def tearDown(self):
super(BaseTestCase, self).tearDown()
def open_nitter(self, page=''):
self.open(f'http://localhost:5000/{page}')
def search_username(self, username):
self.open_nitter()
self.update_text('input', username)
self.submit('form')
def get_timeline_tweet(num=1):
return Tweet(f'#posts > div:nth-child({num}) ')