4
|
1 import unittest
|
|
2
|
3
|
3 import sjsbox.server
|
4
|
4 from sjsbox.bunch import Bunch
|
|
5
|
|
6 class ServerTests(unittest.TestCase):
|
|
7 def test_boxes(self):
|
|
8 foo = Bunch(
|
|
9 mtime = 0,
|
|
10 name = 'foo.js',
|
|
11 contents = 'function handle() { return 404; }'
|
|
12 )
|
3
|
13
|
4
|
14 boxes = sjsbox.server.Boxes([foo])
|
|
15 try:
|
|
16 self.assertEqual(boxes['foo'].handle('GET', '/'),
|
|
17 404)
|
|
18 boxes.update()
|
|
19 self.assertEqual(boxes['foo'].handle('GET', '/'),
|
|
20 404)
|
|
21 foo.mtime = 1
|
|
22 foo.contents = 'function handle() { return "yo"; }';
|
|
23 boxes.update()
|
|
24 self.assertEqual(boxes['foo'].handle('GET', '/'),
|
|
25 u'yo')
|
|
26 finally:
|
|
27 boxes.shutdown()
|
3
|
28
|
|
29 def test_app():
|
|
30 sjsbox.server.App(None)
|