This repository was archived by the owner on Aug 12, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -5,24 +5,40 @@ class TestHashtagPager:
5
5
"""Test the pager returned by getHashtagPager"""
6
6
def test_page_size (self ):
7
7
"""Pages should be pretty close to the specified size"""
8
- api = TikTokApi ()
8
+ api = TikTokApi . get_instance ()
9
9
10
- pager = api .getHashtagPager ('regal' , page_size = 5 )
10
+ hashtag_info = api .getHashtagObject ('regal' )
11
+ pager = api .getHashtagPager (hashtag_info ['challengeInfo' ]['challenge' ]['id' ], page_size = 5 )
11
12
12
13
page = pager .__next__ ()
13
- assert abs (len (page )- 5 ) <= 2
14
+ assert abs (len (page )- 5 ) <= 2 # allow up to 2 fewer than max page size
14
15
15
16
page = pager .__next__ ()
16
17
assert abs (len (page )- 5 ) <= 2
17
18
19
+ # clean up
20
+ TikTokApi ._instance = None
21
+ del api
22
+
18
23
def test_max_pages (self ):
19
- """Should have x pages only """
20
- api = TikTokApi ()
24
+ """Pages should be pretty close to the specified size. """
25
+ api = TikTokApi . get_instance ()
21
26
22
- pager = api .getHashtagPager ('regal' , max_pages = 4 )
27
+ hashtag_info = api .getHashtagObject ('regal' )
28
+ pager = api .getHashtagPager (hashtag_info ['challengeInfo' ]['challenge' ]['id' ])
23
29
24
30
pages = 0
31
+ total_tiktoks = 0
25
32
for page in pager :
26
33
pages += 1
34
+ total_tiktoks += len (page )
35
+ if pages > 3 :
36
+ break
27
37
28
38
assert pages == 4
39
+
40
+ assert abs (total_tiktoks - pages * 30 ) <= 5 # allow for up to 5 fewer than expected
41
+
42
+ # clean up
43
+ TikTokApi ._instance = None
44
+ del api
Original file line number Diff line number Diff line change 4
4
5
5
6
6
def test_user ():
7
- assert api .getUser ("charlidamelio" )["user" ]["uniqueId" ] == "charlidamelio"
7
+ assert api .getUser ("charlidamelio" )["userInfo" ][ " user" ]["uniqueId" ] == "charlidamelio"
8
8
assert api .getUserObject ("charlidamelio" )["uniqueId" ] == "charlidamelio"
9
9
assert (
10
10
abs (
You can’t perform that action at this time.
0 commit comments