Index: /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/tests/test_paypal.py
===================================================================
--- /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/tests/test_paypal.py	(revision 12013)
+++ /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/tests/test_paypal.py	(revision 12013)
@@ -0,0 +1,73 @@
+import os
+import shutil
+import tempfile
+import unittest
+from zope.component import getGlobalSiteManager, queryUtility
+from waeup.ikoba.interfaces import IPayPalConfig
+from waeup.ikoba.payments.paypal import (
+    get_paypal_config_file_path, parse_paypal_config, get_access_token,
+    )
+from waeup.ikoba.testing import (
+    FunctionalLayer, FunctionalTestCase,
+    )
+
+
+class HelperTests(unittest.TestCase):
+
+    def setUp(self):
+        self.workdir = tempfile.mkdtemp()
+
+    def tearDown(self):
+        shutil.rmtree(self.workdir)
+        # unregister any remaining utils registered during tests
+        util = queryUtility(IPayPalConfig)
+        if util is not None:
+            getGlobalSiteManager().unregisterUtility(util, IPayPalConfig)
+
+    def test_get_paypal_config_file_path(self):
+        # we can get a config file path (if registered)
+        path = os.path.join(self.workdir, 'sample.cfg')
+        getGlobalSiteManager().registerUtility(
+            {'path': path, }, IPayPalConfig, '')
+        result = get_paypal_config_file_path()
+        assert result == path
+
+    def test_get_paypal_config_file_path_no_file(self):
+        # without IPayPalConfig util set, we get `None`
+        result = get_paypal_config_file_path()
+        assert result is None
+
+    def test_parse_paypal_config(self):
+        # we can parse paypal configs
+        path = os.path.join(self.workdir, 'sample.cfg')
+        open(path, 'w').write(
+            "[rest-client]\n"
+            "id = myid\n"
+            "secret = mysecret\n"
+            "mode = live\n")
+        result = parse_paypal_config(path)
+        assert result['client_id'] == u'myid'
+        assert result['client_secret'] == u'mysecret'
+        assert result['mode'] == 'live'
+
+    def test_parse_paypal_config_defaults(self):
+        # we have fallback values (defaults) in place
+        path = os.path.join(self.workdir, 'sample.cfg')
+        open(path, 'w').write(
+            "[rest-client]\n"
+            )
+        result = parse_paypal_config(path)
+        assert result['client_id'] is None
+        assert result['client_secret'] is None
+        assert result['mode'] == "sandbox"
+
+
+class FunctionalPaypalTests(FunctionalTestCase):
+    # XXX: The functional paypal tests are expensive
+
+    layer = FunctionalLayer
+
+    def test_get_access_token(self):
+        # we can get an access token
+        result = get_access_token()
+        assert isinstance(result, unicode)
