forked from fm4d/KickassAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
73 lines (57 loc) · 2.26 KB
/
tests.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
import KickassAPI
import pytest
BASE_URL = "http://" + KickassAPI.BASE.domain
"""
This submodule uses pytest framework: http://pytest.org
"""
class TestURL:
"""
Url, LatestUrl, UserUrl, and SearchUrl tests
"""
def setup_method(self, method):
self.url = KickassAPI.Url()
self.url.page = 2
self.url.max_page = 3
def test_inc(self):
self.url.inc_page()
assert self.url.page == 3
with pytest.raises(IndexError):
self.url.inc_page()
def test_dec(self):
self.url.dec_page()
assert self.url.page == 1
with pytest.raises(IndexError):
self.url.dec_page()
def test_set(self):
self.url.set_page(3)
assert self.url.page == 3
self.url.set_page(1)
assert self.url.page == 1
with pytest.raises(IndexError):
self.url.set_page(8)
def test_latest_build(self):
latest = KickassAPI.LatestUrl(1, None)
res = BASE_URL + "/new/1/"
assert latest.build(update=False) == res
latest2 = KickassAPI.LatestUrl(1, (KickassAPI.ORDER.AGE,
KickassAPI.ORDER.ASC))
res2 = BASE_URL + "/new/1/?field=time_add&sorder=asc"
assert latest2.build(update=False) == res2
def test_search_build(self):
search = KickassAPI.SearchUrl("test", 1, None, None)
res = BASE_URL + "/usearch/test/1/"
assert search.build(update=False) == res
search2 = KickassAPI.SearchUrl("test", 1, KickassAPI.CATEGORY.GAMES,
(KickassAPI.ORDER.SIZE, KickassAPI.ORDER.DESC))
res2 = (BASE_URL + "/usearch/test category:games/1/"
"?field=size&sorder=desc")
assert search2.build(update=False) == res2
def test_user_build(self):
user = KickassAPI.UserUrl("reduxionist", 1, None)
res = BASE_URL + "/user/reduxionist/uploads/?page=1"
assert user.build(update=False) == res
user2 = KickassAPI.UserUrl("reduxionist", 1, (KickassAPI.ORDER.SIZE,
KickassAPI.ORDER.DESC))
res2 = (BASE_URL + "/user/reduxionist/uploads/"
"?page=1&field=size&sorder=desc")
assert user2.build(update=False) == res2