summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests
diff options
context:
space:
mode:
authorMalthe Borch <mborch@gmail.com>2009-08-24 17:21:10 +0000
committerMalthe Borch <mborch@gmail.com>2009-08-24 17:21:10 +0000
commit241390d911639cb658bbbbbf1bf3d8c21e0c0270 (patch)
tree7ebcc33709c8c715debf9b94e5157a1464df260c /repoze/bfg/tests
parent45b545c377945812a83d926d11f1635d279069a6 (diff)
downloadpyramid-241390d911639cb658bbbbbf1bf3d8c21e0c0270.tar.gz
pyramid-241390d911639cb658bbbbbf1bf3d8c21e0c0270.tar.bz2
pyramid-241390d911639cb658bbbbbf1bf3d8c21e0c0270.zip
Added ZCML directive to serve up static files from a directory.
Diffstat (limited to 'repoze/bfg/tests')
-rw-r--r--repoze/bfg/tests/test_zcml.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/repoze/bfg/tests/test_zcml.py b/repoze/bfg/tests/test_zcml.py
index 556f22983..d17babaf3 100644
--- a/repoze/bfg/tests/test_zcml.py
+++ b/repoze/bfg/tests/test_zcml.py
@@ -1037,6 +1037,76 @@ class TestRouteDirective(unittest.TestCase):
self.assertEqual(route_discriminator[3], 'GET')
self.assertEqual(route_args, ('path', 'name', None))
+class TestStaticDirective(unittest.TestCase):
+ def setUp(self):
+ cleanUp()
+ import os
+ here = os.path.dirname(__file__)
+ self.static_path = os.path.join(here, 'fixtures', 'static')
+
+ def tearDown(self):
+ cleanUp()
+
+ def _callFUT(self, *arg, **kw):
+ from repoze.bfg.zcml import static
+ return static(*arg, **kw)
+
+ def test_absolute(self):
+ from repoze.bfg.zcml import handler
+ from repoze.bfg.zcml import connect_route
+ from repoze.bfg.interfaces import IView
+ context = DummyContext()
+ self._callFUT(context, 'name', self.static_path)
+ actions = context.actions
+ self.assertEqual(len(actions), 2)
+
+ route_action = actions[0]
+ route_callable = route_action['callable']
+ route_discriminator = route_action['discriminator']
+ route_args = route_action['args']
+ self.assertEqual(route_callable, handler)
+ self.assertEqual(route_discriminator[:3], (
+ 'view', None, ''))
+ self.assertEqual(route_discriminator[4], IView)
+
+ route_action = actions[1]
+ route_callable = route_action['callable']
+ route_discriminator = route_action['discriminator']
+ route_args = route_action['args']
+ self.assertEqual(route_callable, connect_route)
+ self.assertEqual(route_discriminator, (
+ 'route', 'name', None, None))
+ self.assertEqual(route_args, (
+ 'name*subpath', 'name', None))
+
+ def test_package_relative(self):
+ from repoze.bfg.zcml import handler
+ from repoze.bfg.zcml import connect_route
+ from repoze.bfg.interfaces import IView
+ context = DummyContext()
+ self._callFUT(context, 'name', 'repoze.bfg.tests:fixtures/static')
+ actions = context.actions
+ self.assertEqual(len(actions), 2)
+
+ route_action = actions[0]
+ route_callable = route_action['callable']
+ route_discriminator = route_action['discriminator']
+ route_args = route_action['args']
+ self.assertEqual(route_callable, handler)
+ self.assertEqual(route_discriminator[:3], (
+ 'view', None, ''))
+ self.assertEqual(route_discriminator[4], IView)
+
+ route_action = actions[1]
+ route_callable = route_action['callable']
+ route_discriminator = route_action['discriminator']
+ route_args = route_action['args']
+ self.assertEqual(route_callable, connect_route)
+ self.assertEqual(route_discriminator, (
+ 'route', 'name', None, None))
+ self.assertEqual(route_args, (
+ 'name*subpath', 'name', None))
+
class TestResourceDirective(unittest.TestCase):
def setUp(self):
cleanUp()