Index: main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_application.py
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_application.py	(revision 12089)
+++ main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_application.py	(revision 12089)
@@ -0,0 +1,91 @@
+## $Id$
+##
+## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+"""
+Tests for applications.
+"""
+from zope.interface.verify import verifyClass, verifyObject
+from zope.component import createObject
+from hurry.workflow.interfaces import (
+    IWorkflowInfo, IWorkflowState, InvalidTransitionError)
+from waeup.ikoba.customers.interfaces import (
+    IApplicationsContainer, IApplication)
+from waeup.ikoba.interfaces import IObjectHistory
+from waeup.ikoba.customers.applications import (
+    ApplicationsContainer, SampleApplication)
+from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase)
+
+class ApplicationsContainerTestCase(FunctionalTestCase):
+
+    layer = FunctionalLayer
+
+    def test_interfaces(self):
+        # Make sure the correct interfaces are implemented.
+        self.assertTrue(
+            verifyClass(
+                IApplicationsContainer, ApplicationsContainer)
+            )
+        self.assertTrue(
+            verifyObject(
+                IApplicationsContainer, ApplicationsContainer())
+            )
+        self.assertTrue(
+            verifyClass(
+                IApplication, SampleApplication)
+            )
+        self.assertTrue(
+            verifyObject(
+                IApplication, SampleApplication())
+            )
+        return
+
+    def test_addApplication(self):
+        container = ApplicationsContainer()
+        application = createObject(u'waeup.SampleApplication')
+        id = application.application_id
+        container.addApplication(application)
+        self.assertEqual(container[id], application)
+        self.assertRaises(TypeError, container.addApplication, object())
+        self.assertEqual(application.class_name, 'SampleApplication')
+        self.assertEqual(id, 'a123')
+        return
+
+    def test_application_workflow(self):
+        application = createObject(u'waeup.SampleApplication')
+        IWorkflowInfo(application).fireTransition('create')
+        self.assertEqual(IWorkflowState(application).getState(), 'created')
+        IWorkflowInfo(application).fireTransition('submit')
+        self.assertEqual(IWorkflowState(application).getState(), 'submitted')
+        IWorkflowInfo(application).fireTransition('approve')
+        self.assertEqual(IWorkflowState(application).getState(), 'approved')
+        IWorkflowInfo(application).fireTransition('expire')
+        self.assertEqual(IWorkflowState(application).getState(), 'expired')
+        IWorkflowInfo(application).fireTransition('reset4')
+        self.assertEqual(IWorkflowState(application).getState(), 'created')
+        self.assertRaises(InvalidTransitionError,
+            IWorkflowInfo(application).fireTransition, 'approve')
+        IWorkflowInfo(application).fireTransition('submit')
+        IWorkflowInfo(application).fireTransition('reset3')
+        self.assertEqual(IWorkflowState(application).getState(), 'created')
+        return
+
+    def test_application_history(self):
+        doc = createObject(u'waeup.SampleApplication')
+        IWorkflowInfo(doc).fireTransition('create')
+        messages = ' '.join(doc.history.messages)
+        self.assertTrue('Application record created by system' in messages)
+        return
