Commits

Andriy Kornatskyy committed 3e2bc62

Added functional and benchmark tests for hello demo

Comments (0)

Files changed (2)

demos/hello/benchmark_hello.py

+
+""" ``benchmark_views`` module.
+"""
+
+from wheezy.core.benchmark import Benchmark
+
+from test_hello import HelloTestCase
+
+
+class BenchmarkTestCase(HelloTestCase):
+    """
+        ../../env/bin/nosetests-2.7 -qs -m benchmark benchmark_hello.py
+    """
+
+    def runTest(self):
+        """ Perform bachmark and print results.
+        """
+        p = Benchmark((
+            self.test_welcome,
+            self.test_home
+            ), 20000)
+        p.report('public', baselines={
+                'test_welcome': 1.0,
+                'test_home': 0.9
+        })

demos/hello/test_hello.py

+
+""" ``test_hello`` module.
+"""
+
+import unittest
+
+from wheezy.http.functional import WSGIClient
+
+from hello import main
+
+
+class HelloTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.client = WSGIClient(main)
+
+    def tearDown(self):
+        del self.client
+        self.client = None
+
+    def test_home(self):
+        """ Ensure welcome page is rendered.
+        """
+        assert 200 == self.client.get('/')
+        assert 'Hello World!' == self.client.content
+
+    def test_welcome(self):
+        """ Ensure welcome page is rendered.
+        """
+        assert 200 == self.client.get('/welcome')
+        assert 'Hello World!' == self.client.content