[Mpuls-commits] r1552 - in wasko/branches/2.0/mpulsweb/tests: . functional

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Feb 15 14:44:31 CET 2010


Author: torsten
Date: 2010-02-15 14:44:31 +0100 (Mon, 15 Feb 2010)
New Revision: 1552

Modified:
   wasko/branches/2.0/mpulsweb/tests/__init__.py
   wasko/branches/2.0/mpulsweb/tests/functional/test_auth.py
Log:
Added some tests on nose tests.


Modified: wasko/branches/2.0/mpulsweb/tests/__init__.py
===================================================================
--- wasko/branches/2.0/mpulsweb/tests/__init__.py	2010-02-15 13:43:40 UTC (rev 1551)
+++ wasko/branches/2.0/mpulsweb/tests/__init__.py	2010-02-15 13:44:31 UTC (rev 1552)
@@ -1 +1,40 @@
-#
+"""Pylons application test package
+
+This package assumes the Pylons environment is already loaded, such as
+when this script is imported from the `nosetests --with-pylons=test.ini`
+command.
+
+This module initializes the application via ``websetup`` (`paster
+setup-app`) and provides the base testing objects.
+"""
+from unittest import TestCase
+
+from paste.deploy import loadapp
+from paste.script.appinstall import SetupCommand
+from pylons import config, url
+from routes.util import URLGenerator
+from webtest import TestApp
+
+import pylons.test
+
+__all__ = ['environ', 'url', 'TestController']
+
+# Invoke websetup with the current config file
+SetupCommand('setup-app').run([config['__file__']])
+
+environ = {}
+
+class TestController(TestCase):
+
+    def __init__(self, *args, **kwargs):
+        if pylons.test.pylonsapp:
+            wsgiapp = pylons.test.pylonsapp
+        else:
+            wsgiapp = loadapp('config:%s' % config['__file__'])
+        self.app = TestApp(wsgiapp)
+        url._push_object(URLGenerator(config['routes.map'], environ))
+        TestCase.__init__(self, *args, **kwargs)
+
+    def _loginAsAdministrator(self):
+        data = {'username': 'anton', 'password': '1q2w3e4r'}
+        response = self.app.post(url(controller='auth', action='loginAction'), data)

Modified: wasko/branches/2.0/mpulsweb/tests/functional/test_auth.py
===================================================================
--- wasko/branches/2.0/mpulsweb/tests/functional/test_auth.py	2010-02-15 13:43:40 UTC (rev 1551)
+++ wasko/branches/2.0/mpulsweb/tests/functional/test_auth.py	2010-02-15 13:44:31 UTC (rev 1552)
@@ -4,4 +4,17 @@
 
     def test_index(self):
         response = self.app.get(url(controller='auth', action='index'))
-        # Test response...
+
+    def test_login(self):
+        response = self.app.get(url(controller='auth', action='login'))
+        assert "Anmeldekennung" in response
+
+    def test_loginAction(self):
+        data = {'username': 'hannibal', 'password': '1q2w3e4r'}
+        response = self.app.post(url(controller='auth', action='loginAction'), data)
+        assert 'USER_AUTHORIZED' in response.session
+
+    def test_loginFailAction(self):
+        data = {'username': 'hannibal', 'password': 'falschespasswort'}
+        response = self.app.post(url(controller='auth', action='loginAction'), data)
+        assert 'USER_AUTHORIZED' not in response.session



More information about the Mpuls-commits mailing list