Skip to content

Commit

Permalink
Add photo rail test
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Jun 7, 2020
1 parent 47c87f7 commit 34dd02d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ proc getMediaTimeline*(id: string; after=""): Future[Timeline] {.async.} =
result = parseTimeline(await fetch(url), after)

proc getPhotoRail*(id: string): Future[PhotoRail] {.async.} =
result = parsePhotoRail(await getMediaTimeline(id))
let url = mediaTimeline / (id & ".json") ? genParams()
result = parsePhotoRail(await fetch(url))

proc getSearch*[T](query: Query; after=""): Future[Result[T]] {.async.} =
when T is Profile:
Expand Down
1 change: 1 addition & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Timeline(object):
end = '.timeline-end'
none = '.timeline-none'
protected = '.timeline-protected'
photo_rail = '.photo-rail-grid'


class Conversation(object):
Expand Down
15 changes: 15 additions & 0 deletions tests/test_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

protected = [['mobile_test_7'], ['Empty_user']]

photo_rail = [['mobile_test', [
'BzUnaDFCUAAmrjs', 'Bo0nDsYIYAIjqVn', 'Bos--KNIQAAA7Li', 'Boq1sDJIYAAxaoi',
'BonISmPIEAAhP3G', 'BoQbwJAIUAA0QCY', 'BoQbRQxIIAA3FWD', 'Bn8Qh8iIIAABXrG',
'Bn8QIG3IYAA0IGT', 'Bn8O3QeIUAAONai', 'Bn8NGViIAAATNG4', 'BkKovdrCUAAEz79',
'BkKoe_oCIAASAqr', 'BkKoRLNCAAAYfDf', 'BkKndxoCQAE1vFt', 'BPEmIbYCMAE44dl'
]]]


class TweetTest(BaseTestCase):
@parameterized.expand(normal)
Expand Down Expand Up @@ -52,3 +59,11 @@ def test_protected(self, username):
self.assert_element_absent(Timeline.newest)
self.assert_element_absent(Timeline.older)
self.assert_element_absent(Timeline.end)

@parameterized.expand(photo_rail)
def test_photo_rail(self, username, images):
self.open_nitter(username)
self.assert_element_visible(Timeline.photo_rail)
for i, url in enumerate(images):
img = self.get_attribute(Timeline.photo_rail + f' a:nth-child({i + 1}) img', 'src')
self.assertIn(url, img)

0 comments on commit 34dd02d

Please sign in to comment.