-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecode_test.py
More file actions
40 lines (27 loc) · 1.09 KB
/
Copy pathdecode_test.py
File metadata and controls
40 lines (27 loc) · 1.09 KB
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
import unittest
import decode
class TestMain(unittest.TestCase):
def test_empty_input(self):
output = decode.main([])
self.assertEqual(0, len(output["items"]))
def test_invalid(self):
output = decode.main(["nope"])
self.assertEqual("-", output["items"][0]["title"])
self.assertFalse(output["items"][0]["valid"])
class TestDecode(unittest.TestCase):
def test_base64(self):
self.assertEqual("hello alfred", decode.decode_base64("aGVsbG8gYWxmcmVk"))
def test_base64_invalid(self):
with self.assertRaises(Exception):
decode.decode_base64("nope")
def test_json(self):
self.assertEqual('{"hello": "alfred"}', decode.decode_json(r'"{\"hello\": \"alfred\"}"'))
def test_json_invalid(self):
with self.assertRaises(Exception):
decode.decode_json("nope")
def test_url(self):
self.assertEqual("hello alfred", decode.decode_url("hello%20alfred"))
def test_html(self):
self.assertEqual("<br/>", decode.decode_html("<br/>"))
if __name__ == "__main__":
unittest.main()