Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit d3db7c9

Browse files
committed
fix tests
1 parent 7fbeeda commit d3db7c9

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

tests/test_hashtagPager.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,40 @@ class TestHashtagPager:
55
"""Test the pager returned by getHashtagPager"""
66
def test_page_size(self):
77
"""Pages should be pretty close to the specified size"""
8-
api = TikTokApi()
8+
api = TikTokApi.get_instance()
99

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)
1112

1213
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
1415

1516
page = pager.__next__()
1617
assert abs(len(page)-5) <= 2
1718

19+
# clean up
20+
TikTokApi._instance = None
21+
del api
22+
1823
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()
2126

22-
pager = api.getHashtagPager('regal', max_pages=4)
27+
hashtag_info = api.getHashtagObject('regal')
28+
pager = api.getHashtagPager(hashtag_info['challengeInfo']['challenge']['id'])
2329

2430
pages = 0
31+
total_tiktoks = 0
2532
for page in pager:
2633
pages += 1
34+
total_tiktoks += len(page)
35+
if pages > 3:
36+
break
2737

2838
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

tests/test_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def test_user():
7-
assert api.getUser("charlidamelio")["user"]["uniqueId"] == "charlidamelio"
7+
assert api.getUser("charlidamelio")["userInfo"]["user"]["uniqueId"] == "charlidamelio"
88
assert api.getUserObject("charlidamelio")["uniqueId"] == "charlidamelio"
99
assert (
1010
abs(

0 commit comments

Comments
 (0)