This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
46 lines (35 loc) · 1.39 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
import unittest
import imageproxy
class TestConfig(unittest.TestCase):
def test_read(self):
defaults = "[section]\n" "hello=world\n"
conf = imageproxy.read_config(defaults)
self.assertEqual(conf.sections(), ["section"])
self.assertEqual(conf.items("section"), [("hello", "world")])
def test_parse_defaults(self):
# This test assumes that IMAGEPROXY_SETTINGS isn't set.
sites, types = imageproxy.load_config()
self.assertTrue(isinstance(sites, dict))
self.assertEqual(len(sites), 0)
self.assertTrue(isinstance(types, dict))
self.assertEqual(sorted(types.keys()), ["image/jpeg"])
self.assertTrue(types["image/jpeg"])
def test_parse_site(self):
defaults = "[site:example.com]\ncache=true\nprefix=/media\nroot=/dev/null\n"
conf = imageproxy.read_config(defaults)
sites, types = imageproxy.parse_config(conf)
self.assertTrue(isinstance(types, dict))
self.assertEqual(len(types), 0)
self.assertEqual(list(sites.keys()), ["example.com"])
self.assertEqual(
sites["example.com"],
{
"cache": True,
"dimensions": {64, 256, 320, 640},
"prefix": "/media",
"root": "/dev/null",
"directories": True,
},
)
if __name__ == "__main__":
unittest.main()