summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbbangert <none@none>2006-11-13 12:30:42 -0800
committerbbangert <none@none>2006-11-13 12:30:42 -0800
commit200aa41e9e3e77561640eaf8c78363705fef5c39 (patch)
tree3a245711c7a0777c6ef0ff6c55a8a920a5ab5dda
parent787c16cb10826f3a7951a6195422cf129a5037ef (diff)
downloadroutes-200aa41e9e3e77561640eaf8c78363705fef5c39.tar.gz
[svn] * Added additional map.resource recognition tests.
--HG-- branch : trunk
-rw-r--r--CHANGELOG1
-rw-r--r--tests/test_functional/test_recognition.py26
2 files changed, 26 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 5db827e..0c768dd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@ Routes Changelog
========================
-- 1.6 (**svn**)
+* Added additional map.resource recognition tests.
* Added WSGI middleware that does route resolving using new `WSGI.org Routing
Vars Spec <http://wsgi.org/wsgi/Specifications/routing_args>`_.
* Added _absolute keyword option route connect to ignore SCRIPT_NAME settings.
diff --git a/tests/test_functional/test_recognition.py b/tests/test_functional/test_recognition.py
index c405f0a..e2d7877 100644
--- a/tests/test_functional/test_recognition.py
+++ b/tests/test_functional/test_recognition.py
@@ -729,7 +729,31 @@ class TestRecognition(unittest.TestCase):
con.environ = env
self.assertEqual({'action': 'index', 'controller': 'content', 'sub_domain': None, 'id': None},
con.mapper_dict)
-
+
+ def test_resource(self):
+ m = Mapper()
+ m.resource('person')
+ m.create_regs(['person'])
+
+ con = request_config()
+ con.mapper = m
+ def test_path(path, method):
+ env = dict(HTTP_HOST='example.com', PATH_INFO=path, REQUEST_METHOD=method)
+ con.mapper_dict = {}
+ con.environ = env
+
+ test_path('/person', 'GET')
+ assert {'controller':'person', 'action':'index'} == con.mapper_dict
+ test_path('/person', 'POST')
+ assert {'controller':'person', 'action':'create'} == con.mapper_dict
+ test_path('/person/2', 'GET')
+ assert {'controller':'person', 'action':'show', 'id':'2'} == con.mapper_dict
+ test_path('/person/2;edit', 'GET')
+ assert {'controller':'person', 'action':'edit', 'id':'2'} == con.mapper_dict
+ test_path('/person/2', 'DELETE')
+ assert {'controller':'person', 'action':'delete', 'id':'2'} == con.mapper_dict
+ test_path('/person/2', 'PUT')
+ assert {'controller':'person', 'action':'update', 'id':'2'} == con.mapper_dict
if __name__ == '__main__':