1. Andriy Kornatskyy
  2. wheezy.web

Commits

Andriy Kornatskyy  committed 5df1e95

Added benchmark tests for views in public demo

  • Participants
  • Parent commits 592f681
  • Branches default

Comments (0)

Files changed (6)

File demos/public/Makefile

View file
-.SILENT: clean po run test
-.PHONY: clean po run test
+.SILENT: clean po run test benchmark
+.PHONY: clean po run test benchmark
 
 VERSION=2.7
 
 ENV=../../env
 PYTHON=$(ENV)/bin/python$(VERSION)
 PYTEST=$(ENV)/bin/py.test-$(VERSION)
+NOSE=$(ENV)/bin/nosetests-$(VERSION)
 
 
 clean:
 
 test:
 	$(PYTEST) -q -x --pep8 --doctest-modules src/
+
+benchmark:
+	$(NOSE) -qs -m benchmark src/

File demos/public/src/error/web/tests/benchmark_views.py

View file
+
+""" ``benchmark_views`` module.
+"""
+
+from wheezy.core.benchmark import Benchmark
+
+from error.web.tests.test_views import ErrorTestCase
+
+
+class BenchmarkTestCase(ErrorTestCase):
+
+    def runTest(self):
+        """ Perform bachmark and print results.
+        """
+        p = Benchmark((
+            self.test_error_400,
+            self.test_error_403,
+            self.test_error_403,
+            ), 1000)
+        p.report('error', baselines={
+                'test_error_400': 1.0,
+                'test_error_403': 1.0,
+                'test_error_404': 1.0,
+        })

File demos/public/src/membership/web/tests/benchmark_views.py

View file
+
+""" ``benchmark_views`` module.
+"""
+
+from wheezy.core.benchmark import Benchmark
+
+from membership.web.tests.test_views import MembershipTestCase
+
+
+class BenchmarkTestCase(MembershipTestCase):
+
+    def runTest(self):
+        """ Perform bachmark and print results.
+        """
+        p = Benchmark((
+            self.test_signin,
+            self.test_signup,
+            self.test_signout,
+            ), 1000)
+        p.report('signin', baselines={
+                'test_signin': 1.0,
+                'test_signup': 0.667,
+                'test_signout': 4.0,
+        })

File demos/public/src/membership/web/tests/test_views.py

View file
 
 # region: test cases
 
+class MembershipTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.client = WSGIClient(main)
+
+    def tearDown(self):
+        del self.client
+        self.client = None
+
+    def test_signin(self):
+        """ Ensure signin page is rendered
+        """
+        assert 200 == self.client.go('/en/signin')
+        assert '- Sign In</title>' in self.client.content
+
+    def test_signup(self):
+        """
+        """
+        assert 200 == self.client.go('/en/signup')
+        assert '- Sign Up</title>' in self.client.content
+
+    def test_signout(self):
+        """
+        """
+        assert 302 == self.client.go('/en/signout')
+
+
 class SignInTestCase(unittest.TestCase, SignInMixin):
 
     def setUp(self):

File demos/public/src/public/web/tests/benchmark_views.py

View file
+
+""" ``benchmark_views`` module.
+"""
+
+from wheezy.core.benchmark import Benchmark
+
+from public.web.tests.test_views import PublicTestCase
+
+
+class BenchmarkTestCase(PublicTestCase):
+
+    def runTest(self):
+        """ Perform bachmark and print results.
+        """
+        p = Benchmark((
+            self.test_home,
+            self.test_about,
+            self.test_static_files,
+            self.test_static_file_not_found,
+            self.test_static_file_forbidden,
+            self.test_static_file_gzip,
+            self.test_head_static_file
+            ), 1000)
+        p.report('public', baselines={
+                'test_home': 1.0,
+                'test_about': 0.926,
+                'test_static_files': 1.655,
+                'test_static_file_not_found': 0.64,
+                'test_static_file_forbidden': 0.62,
+                'test_static_file_gzip': 8.91,
+                'test_head_static_file': 9.08
+        })

File src/wheezy/web/handlers/base.py

View file
 
 
 class BaseHandler(MethodHandler, ValidationMixin):
-    """ Provides methods that integarte such features like: routing,
+    """ Provides methods that integrate such features like: routing,
         i18n, model binding, template rendering, authentication,
         xsrf/resubmission protection.