5 class TestLoadMappings(unittest
.TestCase
):
8 self
.parsing
= cheatbt
.load_mappings("test/parsing")
9 self
.nodefault
= cheatbt
.load_mappings("test/nodefault")
11 def test_parsing(self
):
12 self
.assertEqual(self
.parsing
["tracker1.example.net"], 0)
13 self
.assertEqual(self
.parsing
["tracker2.example.net"], 10)
14 self
.assertEqual(self
.parsing
["tracker3.example.net"], 123)
15 self
.assertEqual(self
.parsing
["tracker4.example.net"], 456)
16 self
.assertEqual(self
.parsing
["tracker5.example.net"], 789)
18 def test_nodefault(self
):
19 self
.assertEqual(self
.nodefault
["default"], 1)
21 class TestCheat(unittest
.TestCase
):
24 self
.mappings
= {"default": 2}
26 def test_normal(self
):
28 These URLs should pass through without modification.
32 "http://www.example.net/",
33 "http://www.example.net/?test",
34 "http://www.example.net/test?test",
35 "http://www.example.net/test?test=val",
36 "http://www.example.net/test?uploaded=0",
37 "http://www.example.net:6969/",
38 "http://www.example.net:6969/?test",
39 "http://www.example.net:6969/test?test",
40 "http://www.example.net:6969/test?test=val",
41 "http://www.example.net:6969/test?uploaded=0"
45 self
.assertEqual(cheatbt
.cheat(url
, self
.mappings
), url
)
47 def test_modify_upload(self
):
49 Upload parameter should be modified.
53 ("http://www.example.net/test?uploaded=123456",
54 "http://www.example.net/test?uploaded=246912"),
55 ("http://www.example.net/test?test1=val&test2=val&downloaded=5&uploaded=10",
56 "http://www.example.net/test?test1=val&test2=val&downloaded=5&uploaded=20"),
57 ("http://www.example.net:6969/test?uploaded=123456",
58 "http://www.example.net:6969/test?uploaded=246912"),
59 ("http://www.example.net:6969/test?test1=val&test2=val&downloaded=5&uploaded=10",
60 "http://www.example.net:6969/test?test1=val&test2=val&downloaded=5&uploaded=20")
64 self
.assertEqual(cheatbt
.cheat(pair
[0], self
.mappings
), pair
[1])
66 if __name__
== '__main__':