Author: batiste.bieler
Date: Wed Apr 15 11:25:15 2009
New Revision: 453

Modified:
    trunk/pages/tests.py
    trunk/pages/utils.py

Log:
Create a get_request_mock function and test if the session attribut is  
correctly added to the request objet by the session middleware

Modified: trunk/pages/tests.py
==============================================================================
--- trunk/pages/tests.py        (original)
+++ trunk/pages/tests.py        Wed Apr 15 11:25:15 2009
@@ -466,6 +466,11 @@
                           "[('MyResponse',  
<class 'pages.tests.MyResponse'>), "
                           "('args', ()), ('kwargs', {}), ('request',  
None)]")

+    def test_17_request_mockup(self):
+        from pages.utils import get_request_mock
+        request = get_request_mock()
+        self.assertEqual(hasattr(request, 'session'), True)
+
      def assertOnlyContextException(self, view):
          """
          If an @auto_render-decorated view returns an HttpResponse and is  
called
@@ -475,7 +480,7 @@
              view(None, only_context=True)
          except Exception, e:
              self.assertEqual(e.__class__, Exception)
-            self.assertEqual(e.message,
+            self.assertEqual(e[0],
                               "cannot return context dictionary because a  
view "
                               "returned an HTTP response when a "
                               "(template_name, context) tuple was expected")

Modified: trunk/pages/utils.py
==============================================================================
--- trunk/pages/utils.py        (original)
+++ trunk/pages/utils.py        Wed Apr 15 11:25:15 2009
@@ -12,15 +12,7 @@
  from pages import settings
  from exceptions import Exception as Except

-def get_placeholders(template_name):
-    """
-    Return a list of PlaceholderNode found in the given template
-    """
-    try:
-        temp = loader.get_template(template_name)
-    except TemplateDoesNotExist:
-        return []
-
+def get_request_mock():
      bh = BaseHandler()
      bh.load_middleware()
      request = WSGIRequest({
@@ -31,6 +23,19 @@
      # Apply request middleware
      for middleware_method in bh._request_middleware:
          response = middleware_method(request)
+    return request
+
+def get_placeholders(template_name):
+    """
+    Return a list of PlaceholderNode found in the given template
+    """
+    try:
+        temp = loader.get_template(template_name)
+    except TemplateDoesNotExist:
+        return []
+
+    request = get_request_mock()
+
      try:
          # to avoid circular import
          from pages.views import details

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to