-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
67 lines (53 loc) · 2.36 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
import unittest
import cheatbt
class TestLoadMappings(unittest.TestCase):
def setUp(self):
self.parsing = cheatbt.load_mappings("test/parsing")
self.nodefault = cheatbt.load_mappings("test/nodefault")
def test_parsing(self):
self.assertEqual(self.parsing["tracker1.example.net"], 0)
self.assertEqual(self.parsing["tracker2.example.net"], 10)
self.assertEqual(self.parsing["tracker3.example.net"], 123)
self.assertEqual(self.parsing["tracker4.example.net"], 456)
self.assertEqual(self.parsing["tracker5.example.net"], 789)
def test_nodefault(self):
self.assertEqual(self.nodefault["default"], 1)
class TestCheat(unittest.TestCase):
def setUp(self):
self.mappings = {"default": 2}
def test_normal(self):
"""
These URLs should pass through without modification.
"""
urls = (
"http://www.example.net/",
"http://www.example.net/?test",
"http://www.example.net/test?test",
"http://www.example.net/test?test=val",
"http://www.example.net/test?uploaded=0",
"http://www.example.net:6969/",
"http://www.example.net:6969/?test",
"http://www.example.net:6969/test?test",
"http://www.example.net:6969/test?test=val",
"http://www.example.net:6969/test?uploaded=0"
)
for url in urls:
self.assertEqual(cheatbt.cheat(url, self.mappings), url)
def test_modify_upload(self):
"""
Upload parameter should be modified.
"""
urls = (
("http://www.example.net/test?uploaded=123456",
"http://www.example.net/test?uploaded=246912"),
("http://www.example.net/test?test1=val&test2=val&downloaded=5&uploaded=10",
"http://www.example.net/test?test1=val&test2=val&downloaded=5&uploaded=20"),
("http://www.example.net:6969/test?uploaded=123456",
"http://www.example.net:6969/test?uploaded=246912"),
("http://www.example.net:6969/test?test1=val&test2=val&downloaded=5&uploaded=10",
"http://www.example.net:6969/test?test1=val&test2=val&downloaded=5&uploaded=20")
)
for pair in urls:
self.assertEqual(cheatbt.cheat(pair[0], self.mappings), pair[1])
if __name__ == '__main__':
unittest.main()