summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSai Krishna <saikrishna1511@gmail.com>2011-05-12 17:20:41 +0530
committerSai Krishna <saikrishna1511@gmail.com>2011-05-12 17:20:41 +0530
commite4f2a0a89f17d79c9e4577a0feac2fe507fd9f83 (patch)
tree35d9af44efc2156abe2c17cbef4f0b0f85a4848b /test
parent11e6bf86962c98540e0c6a19832e6544c55f8ffe (diff)
parentd5ce3e52fa784c7e1f2b1a6998e38546b3727e8b (diff)
Merge remote branch 'github/master'
Merged conflicts but added README.md, need to verify if this is needed Conflicts: README.md keystone/logic/service.py
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_exthandler.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/unit/test_exthandler.py b/test/unit/test_exthandler.py
new file mode 100644
index 00000000..003923ff
--- /dev/null
+++ b/test/unit/test_exthandler.py
@@ -0,0 +1,49 @@
+import os
+import sys
+# Need to access identity module
+sys.path.append(os.path.abspath(os.path.join(
+ os.getcwd(), '..', '..', 'keystone'))
+)
+from queryext.exthandler import UrlExtensionFilter
+import unittest
+
+
+class MockWsgiApp(object):
+
+ def __init__(self):
+ pass
+
+ def __call__(self, env, start_response):
+ pass
+
+
+def _start_response():
+ pass
+
+
+class UrlExtensionFilterTest(unittest.TestCase):
+
+ def setUp(self):
+ self.filter = UrlExtensionFilter(MockWsgiApp(), {})
+
+ def test_xml_extension(self):
+ env = {'PATH_INFO': '/v1.0/someresource.xml'}
+ self.filter(env, _start_response)
+ self.assertEqual('/v1.0/someresource', env['PATH_INFO'])
+ self.assertEqual('application/xml', env['HTTP_ACCEPT'])
+
+ def test_json_extension(self):
+ env = {'PATH_INFO': '/v1.0/someresource.json'}
+ self.filter(env, _start_response)
+ self.assertEqual('/v1.0/someresource', env['PATH_INFO'])
+ self.assertEqual('application/json', env['HTTP_ACCEPT'])
+
+ def test_extension_overrides_header(self):
+ env = {'PATH_INFO': '/v1.0/someresource.json', 'HTTP_ACCEPT': 'application/xml'}
+ self.filter(env, _start_response)
+ self.assertEqual('/v1.0/someresource', env['PATH_INFO'])
+ self.assertEqual('application/json', env['HTTP_ACCEPT'])
+
+
+if __name__ == '__main__':
+ unittest.main()