Index: /main/waeup.cas/trunk/README.rst
===================================================================
--- /main/waeup.cas/trunk/README.rst	(revision 10511)
+++ /main/waeup.cas/trunk/README.rst	(revision 10512)
@@ -37,9 +37,9 @@
 You can generate coverage reports by::
 
-  (py27)$ py.test --cov
+  (py27)$ py.test --cov .
 
 This will dump reports on commandline. For HTML reports you can try::
 
-  (py27)$ py.test --cov --cov-report=html
+  (py27)$ py.test --cov . --cov-report=html
 
 Please make sure, that coverage stays at 100%.
Index: /main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py	(revision 10511)
+++ /main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py	(revision 10512)
@@ -88,5 +88,5 @@
         url='http://localhost:6666/',
         marker='^SCHOOL1-',
-        moodle_url = 'http://localhost/moodle',
+        moodle_url = 'http://localhost:7777/',
         )
     )
@@ -166,4 +166,6 @@
         self.register_function(
             self._check_credentials, 'check_student_credentials')
+        self.register_function(
+            self._get_moodle_data, 'get_moodle_data')
 
     def _check_credentials(self, username, password):
@@ -183,25 +185,75 @@
         return None
 
-
-class KofaAuthenticatorIntegrationTests(unittest.TestCase):
+    def _get_moodle_data(self, username):
+        # fake waeup.kofa get_moodle_data method.
+        if username == 'bird':
+            return dict(email='aa@aa.aa',
+                        firstname='Charles',
+                        lastname='Parker',
+                        )
+        if username == 'pig':
+            return dict(email='bb@bb.bb',
+                        firstname='Ray',
+                        lastname='Charles',
+                        )
+        return None
+
+class FakeMoodleServer(SimpleXMLRPCServer):
+    # A fake Moodle server that provides only XMLRPC methods
+
+    allow_reuse_address = True
+
+    def __init__(self, *args, **kw):
+        kw.update(allow_none=True)
+        SimpleXMLRPCServer.__init__(self, *args, **kw)
+        self.register_function(
+            self._core_user_create_users, 'core_user_create_users')
+        self.register_function(
+            self._core_user_get_users, 'core_user_get_users')
+        self.register_function(
+            self._core_user_update_users, 'core_user_update_users')
+
+    def _core_user_create_users(self, list_of_dicts):
+        # fake Moodle core_user_create_users method.
+        return None
+
+    def _core_user_get_users(self, list_of_dicts):
+        # fake Moodle core_user_get_users method.
+        return {'users':[{'id':'any id'}]}
+
+    def _core_user_update_users(self, list_of_dicts):
+        # fake Moodle core_user_update_users method.
+        return None
+
+class KofaAuthenticatorsIntegrationTests(unittest.TestCase):
     # A test case where a fake Kofa server is started before tests (and
     # shut down afterwards).
 
-    server = None
-    th = None
+    kofa_server = None
+    kofa_th = None
+    moodle_server = None
+    moodle_th = None
 
     @classmethod
     def setUpClass(cls):
         # set up a fake kofa server
-        cls.server = FakeKofaServer(('localhost', 6666))
-        cls.th = threading.Thread(target=cls.server.serve_forever)
-        cls.th.daemon = True
-        cls.th.start()
+        cls.kofa_server = FakeKofaServer(('localhost', 6666))
+        cls.kofa_th = threading.Thread(target=cls.kofa_server.serve_forever)
+        cls.kofa_th.daemon = True
+        cls.kofa_th.start()
+        # set up a fake moodle server
+        cls.moodle_server = FakeMoodleServer(('localhost', 7777))
+        cls.moodle_th = threading.Thread(target=cls.moodle_server.serve_forever)
+        cls.moodle_th.daemon = True
+        cls.moodle_th.start()
 
     @classmethod
     def tearDownClass(cls):
         # tear down fake kofa server
-        cls.server.shutdown()
-        cls.server.server_close()
+        cls.kofa_server.shutdown()
+        cls.kofa_server.server_close()
+        # tear down fake moodle server
+        cls.moodle_server.shutdown()
+        cls.moodle_server.server_close()
 
     def test_fake_kofa_works(self):
@@ -220,7 +272,24 @@
             'id': 'pig',
             'type': 'applicant'}
+        result = proxy.get_moodle_data('pig')
+        assert result == {
+            'lastname': 'Charles',
+            'email': 'bb@bb.bb',
+            'firstname': 'Ray',
+            }
         return
 
-    def test_check_credentials(self):
+    def test_moodle_works(self):
+        # make sure the local fake moodle works
+        proxy = xmlrpclib.ServerProxy("http://localhost:7777", allow_none=True)
+        result = proxy.core_user_create_users([])
+        assert result == None
+        result = proxy.core_user_get_users([])
+        assert result == {'users':[{'id':'any id'}]}
+        result = proxy.core_user_update_users([])
+        assert result == None
+        return
+
+    def test_check_credentials_1(self):
         # we get real responses when querying Kofa instances
         auth = KofaAuthenticator(auth_backends=str(BACKENDS2))
@@ -232,2 +301,11 @@
         assert result3 == (False, 'Invalid username or password.')
 
+    def test_check_credentials_2(self):
+        # we get real responses when querying Kofa instances
+        auth = KofaMoodleAuthenticator(auth_backends=str(BACKENDS3))
+        result1 = auth.check_credentials('SCHOOL1-bird', 'bebop')
+        assert result1 == (True, '')
+        result2 = auth.check_credentials('SCHOOL1-foo', 'bar')
+        assert result2 == (False, 'Invalid username or password.')
+        result3 = auth.check_credentials('SCHOOL2-bar', 'baz')
+        assert result3 == (False, 'Invalid username or password.')
