Commits

Anonymous committed 0b35322

tests fixed

  • Participants
  • Parent commits a7cf22a
  • Branches alfajor-integration

Comments (0)

Files changed (2)

File flaskext/testing.py

     :param value: value to check against
     """
 
+def assert_template_used(name):
+
+    pass
+
+
+def assert_templates_used(*names):
+
+    pass
+
+
 def assert_redirects(response, location):
     """
     Checks if response is an HTTP redirect to the 
     """
     assert response.status_code == status_code
 
-def assert200(response):
+def assert_200(response):
     """
     Checks if response status code is 200 
 
     :param response: Flask response
     """
 
-    assert assert_status(response, 200)
+    assert_status(response, 200)
 
-
-def assert403(self, response):
+def assert_403(response):
     """
     Checks if response status code is 403
 
     :param response: Flask response
     """
 
-    self.assertStatus(response, 403)
 
-assert_403 = assert403
+    assert_status(response, 404)
 
-def assert404(self, response):
+def assert_404(response):
     """
     Checks if response status code is 404
 
     :param response: Flask response
     """
 
-    self.assertStatus(response, 404)
+    assert_status(response, 404)
 
-assert_404 = assert404
 
-def assert405(self, response):
+def assert_405(response):
     """
     Checks if response status code is 405
 
     :param response: Flask response
     """
 
-    self.assertStatus(response, 405)
+    assert_status(response, 405)
 
-assert_405 = assert405
 
 
 try:
 browser = LocalProxy(lambda: _testing_ctx_stack.top.browser)
 client = LocalProxy(lambda: _testing_ctx_stack.top.client)
 fixtures = LocalProxy(lambda: _testing_ctx_stack.top.fixtures)
+templates = LocalProxy(lambda: _testing_ctx_stack.top.templates)
 
 class _GlobalFixtures(object):
     pass
     
         self.client = self.app.test_client()
         self.fixtures = _GlobalFixtures()
+        self.templates = []
 
     def push(self):
 
         self._teardown_funcs.append(func)
         return func
 
+    def create_app(self):
+        raise NotImplementedError, "app must be created by parent"
+
     def with_context(self, func):
 
         @functools.wraps(func)
             if self._parent:
                 app = self._parent.create_app()
             else:
-                raise RuntimeError, "Not parent node nor parent set"
+                app = self.create_app()
 
             _app_ctx = app.test_request_context()
             _app_ctx.push()
             for setup_func in self._setup_funcs:
                 setup_func()
 
+            # template_rendered.connect(_add_templates)
+
             try:
                 return func()
                 
             finally:
+                
+                # template_rendered.disconnect(_add_templates)
+
                 for teardown_func in self._teardown_funcs:
                     teardown_func()
 

File tests/__init__.py

     jsonify, render_template, current_app
 
 from flaskext.testing import TestCase, TwillTestCase, \
-    ContextVariableDoesNotExist, Testing, client, fixtures
+    ContextVariableDoesNotExist, Testing, client, fixtures, assert_404
 
 def create_app():
 
 @testing.with_context
 def test_assert_something():
     response = client.get("/foo/")
-    testing.assert_404(response)
+    assert_404(response)
 
 @testing.setup
 def set_x():