forked from akynazh/tg-search-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
94 lines (68 loc) · 2.59 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# -*- coding: UTF-8 -*-
import jvav
import unittest
PROXY_ADDR = ''
#PROXY_ADDR = "http://127.0.0.1:7890"
def assert_code(code: int, res):
"""确认状态码是否为 200, 如果是则打印结果
:param int code: 状态码
:param any res: 结果
"""
assert code == 200, f"code={code}"
print(res)
def assert_res(res):
assert res != None, f"res=None"
print(res)
# python -m unittest discover -s tests -k JavBusUtilTest
class JavBusUtilTest(unittest.TestCase):
util = jvav.JavBusUtil(
proxy_addr=PROXY_ADDR, max_home_page_count=100, max_new_avs_count=10
)
def test_get_all_genres(self):
assert_code(*JavBusUtilTest.util.get_all_genres())
def test_get_id_by_genre_id(self):
assert_code(*JavBusUtilTest.util.get_id_by_genre_id("3s"))
# python -m unittest discover -s tests -k test_get_max_page
def test_get_max_page(self):
assert_code(
*JavBusUtilTest.util.get_max_page("https://www.javbus.com/star/okq")
)
def test_get_ids_from_page(self):
assert_code(
*JavBusUtilTest.util.get_ids_from_page(
base_page_url="https://www.javbus.com/star/okq"
)
)
def test_get_id_from_page(self):
assert_code(
*JavBusUtilTest.util.get_id_from_page(
base_page_url="https://www.javbus.com/star/okq"
)
)
def test_get_id_from_home(self):
assert_code(*JavBusUtilTest.util.get_id_from_home())
def test_get_id_by_star_name(self):
assert_code(*JavBusUtilTest.util.get_id_by_star_name(star_name="三上悠亜"))
def test_get_new_ids_by_star_name(self):
assert_code(*JavBusUtilTest.util.get_new_ids_by_star_name(star_name="三上悠亜"))
def test_get_id_by_star_id(self):
assert_code(*JavBusUtilTest.util.get_id_by_star_id(star_id="okq"))
def test_get_new_ids_by_star_id(self):
assert_code(*JavBusUtilTest.util.get_new_ids_by_star_id(star_id="okq"))
def test_get_samples_by_id(self):
assert_code(*JavBusUtilTest.util.get_samples_by_id(id="ipx-365"))
def test_check_star_exists(self):
assert_code(*JavBusUtilTest.util.check_star_exists(star_name="三上"))
def test_get_av_by_id(self):
assert_code(
*JavBusUtilTest.util.get_av_by_id(
id="ipx-365", is_nice=True, is_uncensored=False
)
)
assert_code(
*JavBusUtilTest.util.get_av_by_id(
id="NINE-078", is_nice=True, is_uncensored=False
)
)
if __name__ == "__main__":
unittest.main()