Skip to content

Commit 6c65cf2

Browse files
committed
Added a few unit tests
1 parent 7990bbb commit 6c65cf2

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

pyzootool/tests.py

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
from unittest import TestCase
2+
3+
from pyzootool import users, items, controller
4+
5+
class ZooTest(TestCase):
6+
7+
def setUp(self):
8+
self.user_info = {
9+
"username":"f4nt",
10+
"website":'null',
11+
"avatar":"http:\/\/blank.com/f4nt_l.jpg?1271429353",
12+
"profile":"http:\/\/zootool.com\/user\/f4nt\/"
13+
}
14+
self.item_info = {
15+
"uid":"wol",
16+
"title":"4Chan gets charitable",
17+
"url":"http:\/\/i.imgur.com\/kdYBh.jpg",
18+
"added":"1271422494",
19+
"type":"image",
20+
"views":"0",
21+
"likes":"1",
22+
"permalink":"http:\/\/zootool.com\/watch\/wol\/",
23+
"tinyurl":"http:\/\/zoo.tl\/wol",
24+
"thumbnail":"http:\/\/c0382052.cdn.cloudfiles.rackspacecloud.com\/wol_s.jpg?1271422495",
25+
"tags":["none"],
26+
"description":"None"
27+
}
28+
29+
self.item_array = [
30+
{
31+
"uid":"wol",
32+
"title":"4Chan gets charitable",
33+
"url":"http:\/\/i.imgur.com\/kdYBh.jpg",
34+
"added":"1271422494",
35+
"type":"image",
36+
"views":"0",
37+
"likes":"1",
38+
"permalink":"http:\/\/zootool.com\/watch\/wol\/",
39+
"tinyurl":"http:\/\/zoo.tl\/wol",
40+
"thumbnail":"http:\/\/c0382052.cdn.cloudfiles.rackspacecloud.com\/wol_s.jpg?1271422495",
41+
"tags":["none"],
42+
"description":"None"
43+
},
44+
{
45+
"uid":"r4v6",
46+
"title":"f4nt's pyzootool at master - GitHub",
47+
"url":"http:\/\/github.com\/f4nt\/pyzootool",
48+
"added":"1271381736",
49+
"type":"page",
50+
"views":"6",
51+
"likes":"2",
52+
"permalink":"http:\/\/zootool.com\/watch\/r4v6\/",
53+
"tinyurl":"http:\/\/zoo.tl\/r4v6",
54+
"thumbnail":"http:\/\/c0397571.cdn.cloudfiles.rackspacecloud.com\/r4v6_s.jpg?1271502861",
55+
"tags":["zootool","python"],
56+
"description":""
57+
}
58+
]
59+
60+
def test_user_parse(self):
61+
result = users.ZooUserResult(self.user_info)
62+
self.assertEqual(self.user_info['username'], result.username)
63+
64+
def test_item_parse(self):
65+
item = items.ZooItemResult(self.item_info)
66+
self.assertEqual(self.item_info['uid'], item.uid)
67+
68+
def test_array_item_parse(self):
69+
result_list = []
70+
for item in self.item_array:
71+
result = items.ZooItemResult(item)
72+
result_list.append(result)
73+
self.assertEqual(len(self.item_array), len(result_list))

0 commit comments

Comments
 (0)