1
0
mirror of https://github.com/zedeus/nitter synced 2024-12-01 05:50:30 +01:00
nitter/tests/base.py

103 lines
2.8 KiB
Python
Raw Normal View History

2019-06-28 04:56:02 +02:00
from seleniumbase import BaseCase
2019-08-13 00:29:48 +02:00
class Card(object):
def __init__(self, tweet=''):
card = tweet + '.card '
self.link = card + 'a'
self.title = card + '.card-title'
self.description = card + '.card-description'
self.destination = card + '.card-destination'
self.image = card + '.card-image'
2019-08-12 17:02:07 +02:00
class Quote(object):
def __init__(self, tweet=''):
quote = tweet + '.quote '
namerow = quote + '.fullname-and-username '
self.link = quote + '.quote-link'
self.fullname = namerow + '.fullname'
self.username = namerow + '.username'
self.text = quote + '.quote-text'
2020-06-01 02:25:56 +02:00
self.media = quote + '.quote-media-container'
2019-08-12 17:02:07 +02:00
self.unavailable = quote + '.quote.unavailable'
2019-06-28 04:56:02 +02:00
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'
2019-09-19 02:29:24 +02:00
self.text = tweet + '.tweet-content.media-body'
2019-09-24 15:38:42 +02:00
self.retweet = tweet + '.retweet-header'
2019-08-12 16:55:04 +02:00
self.reply = tweet + '.replying-to'
2019-06-28 04:56:02 +02:00
class Profile(object):
fullname = '.profile-card-fullname'
username = '.profile-card-username'
2020-11-08 04:27:34 +01:00
protected = '.icon-lock'
2019-06-28 04:56:02 +02:00
verified = '.verified-icon'
2019-06-29 00:41:57 +02:00
banner = '.profile-banner'
bio = '.profile-bio'
location = '.profile-location'
website = '.profile-website'
joinDate = '.profile-joindate'
mediaCount = '.photo-rail-header'
2019-06-28 04:56:02 +02:00
2019-06-29 00:42:53 +02:00
class Timeline(object):
2019-09-19 02:29:24 +02:00
newest = 'div[class="timeline-item show-more"]'
2019-06-29 00:42:53 +02:00
older = 'div[class="show-more"]'
end = '.timeline-end'
none = '.timeline-none'
protected = '.timeline-protected'
2020-06-07 07:56:28 +02:00
photo_rail = '.photo-rail-grid'
2019-06-29 00:42:53 +02:00
2019-07-01 07:12:46 +02:00
class Conversation(object):
main = '.main-tweet'
before = '.before-tweet'
after = '.after-tweet'
replies = '.replies'
thread = '.reply'
2019-09-19 02:29:24 +02:00
tweet = '.timeline-item'
tweet_text = '.tweet-content'
2019-07-01 07:12:46 +02:00
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=''):
2019-10-10 19:54:15 +02:00
self.open(f'http://localhost:8080/{page}')
2019-06-28 04:56:02 +02:00
def search_username(self, username):
self.open_nitter()
2019-09-19 02:29:24 +02:00
self.update_text('.search-bar input[type=text]', username)
self.submit('.search-bar form')
2019-06-28 04:56:02 +02:00
def get_timeline_tweet(num=1):
2019-09-19 02:29:24 +02:00
return Tweet(f'.timeline > div:nth-child({num}) ')