Index: main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_accesscodes.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_accesscodes.py	(revision 6377)
+++ main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/tests/test_accesscodes.py	(revision 6378)
@@ -23,11 +23,13 @@
 import tempfile
 import unittest
+from hurry.workflow.interfaces import InvalidTransitionError, IWorkflowState
 from zope.app.testing.functional import FunctionalTestCase
-from zope.component.hooks import setSite
+from zope.component.hooks import setSite, clearSite
 from waeup.sirp.app import University
 from waeup.sirp.testing import FunctionalLayer
 from waeup.sirp.accesscodes.accesscodes import (
     AccessCodeBatch, get_access_code, invalidate_accesscode,
-    disable_accesscode, reenable_accesscode)
+    disable_accesscode, reenable_accesscode, fire_transition)
+from waeup.sirp.accesscodes.workflow import INITIALIZED, USED, DISABLED
 
 class AccessCodeHelpersTests(FunctionalTestCase):
@@ -93,19 +95,6 @@
         assert result is True
 
-    def test_invalidate_used_accesscode(self):
-        invalidate_accesscode('APP-1-11111111')
-        inv_date = self.ac1._invalidation_date
-        result = invalidate_accesscode('APP-1-11111111')
-        assert result is False
-        assert self.ac1._invalidation_date == inv_date
-
-    def test_invalidate_disabled_accesscode(self):
-        # disabled acs cannot be invalidated.
-        disable_accesscode('APP-1-11111111')
-        result = invalidate_accesscode('APP-1-11111111')
-        assert result is False
-        assert self.ac1._disabled is True
-
     def test_disable_accesscode_unused(self):
+        # we can disable initialized acs
         assert self.ac1._disabled is False
         disable_accesscode('APP-1-11111111')
@@ -113,4 +102,5 @@
 
     def test_disable_accesscode_used(self):
+        # we can disable already used acs
         assert self.ac1._disabled is False
         invalidate_accesscode('APP-1-11111111')
@@ -119,4 +109,5 @@
 
     def test_reenable_accesscode(self):
+        # we can reenable disabled acs
         disable_accesscode('APP-1-11111111')
         result = reenable_accesscode('APP-1-11111111')
@@ -124,6 +115,50 @@
         assert self.ac1._disabled is False
 
-    def test_reenable_accesscode_enabled(self):
-        result = reenable_accesscode('APP-1-11111111')
-        assert result is False
-        assert self.ac1._disabled is False
+    def test_fire_transition(self):
+        # we can fire transitions generally
+        fire_transition('APP-1-11111111', 'use')
+        assert IWorkflowState(self.ac1).getState() is USED
+
+    def test_fire_transition_toward(self):
+        # the `toward` keyword is respected
+        fire_transition('APP-1-11111111', DISABLED, toward=True)
+        assert IWorkflowState(self.ac1).getState() is DISABLED
+
+    def test_fire_transition_no_site(self):
+        # when no site is available, we will get a TypeError
+        clearSite()
+        self.assertRaises(
+            KeyError,
+            fire_transition, 'APP-1-11111111', 'use')
+
+    def test_fire_transition_broken_ac_id(self):
+        # if we get an invalid access code id (of wrong format) we get
+        # ValueErrors
+        self.assertRaises(
+            ValueError,
+            fire_transition, '11111111', 'use')
+
+    def test_fire_transition_invalid_batch_id(self):
+        # if we request a non-existent batch_id, we'll get a KeyError
+        self.assertRaises(
+            KeyError,
+            fire_transition, 'FOO-1-11111111', 'use')
+
+    def test_fire_transition_invalid_ac(self):
+        # if we request a non-exitent access-code, we'll get a KeyError
+        self.assertRaises(
+            KeyError,
+            fire_transition, 'APP-1-NONSENSE', 'use')
+
+    def test_fire_transition_undef_trans_id(self):
+        # asking for undefined transition id means a KeyError
+        self.assertRaises(
+            KeyError,
+            fire_transition, 'APP-1-11111111', 'nonsense')
+
+    def test_fire_transition_invalid_transition(self):
+        # asking for a forbidden transition will result in
+        # InvalidTransitionError
+        self.assertRaises(
+            InvalidTransitionError,
+            fire_transition, 'APP-1-11111111', 'init') # already initialized
