[X2Go-Commits] x2gobroker.git - tmp (branch) updated: 28c20041e7709026e6f4518e4ad05d87895524bf

X2Go dev team git-admin at x2go.org
Tue Apr 23 21:08:34 CEST 2013


The branch, tmp has been updated
       via  28c20041e7709026e6f4518e4ad05d87895524bf (commit)
      from  49855e399037e5508d1f1071862924446ae8d46f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 x2gobroker/__init__.py => test.py                  |   15 ++--
 x2gobroker/{ => tests}/__init__.py                 |   17 +++--
 x2gobroker/tests/runalltests.py                    |   52 ++++++++++++++
 x2gobroker/tests/test_backend_base.py              |   74 ++++++++++++++++++++
 .../zeroconf.py => tests/test_backend_zeroconf.py} |   60 +++++++++-------
 5 files changed, 180 insertions(+), 38 deletions(-)
 copy x2gobroker/__init__.py => test.py (74%)
 mode change 100644 => 100755
 copy x2gobroker/{ => tests}/__init__.py (58%)
 create mode 100644 x2gobroker/tests/runalltests.py
 create mode 100644 x2gobroker/tests/test_backend_base.py
 copy x2gobroker/{backends/zeroconf.py => tests/test_backend_zeroconf.py} (59%)

The diff of changes is:
diff --git a/x2gobroker/__init__.py b/test.py
old mode 100644
new mode 100755
similarity index 74%
copy from x2gobroker/__init__.py
copy to test.py
index ad8c1e4..5dce707
--- a/x2gobroker/__init__.py
+++ b/test.py
@@ -1,8 +1,8 @@
+#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-# Copyright (C) 2012 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
-# Copyright (C) 2012 by Oleksandr Shneyder <oleksandr.shneyder at obviously-nice.de>
-#
+# Copyright (C) 2010 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+# 
 # X2Go Session Broker is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published by
 # the Free Software Foundation; either version 3 of the License, or
@@ -18,6 +18,11 @@
 # Free Software Foundation, Inc.,
 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-__VERSION__ = '0.0.0.1'
-
+"""
+Unit tests for Python X2GoBroker.
+"""
+import os
 
+if __name__ == "__main__":
+    os.chdir(os.path.join('x2gobroker', 'tests',))
+    os.system('python ./runalltests.py')
diff --git a/x2gobroker/__init__.py b/x2gobroker/tests/__init__.py
similarity index 58%
copy from x2gobroker/__init__.py
copy to x2gobroker/tests/__init__.py
index ad8c1e4..7b5de7d 100644
--- a/x2gobroker/__init__.py
+++ b/x2gobroker/tests/__init__.py
@@ -1,14 +1,13 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (C) 2012 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
-# Copyright (C) 2012 by Oleksandr Shneyder <oleksandr.shneyder at obviously-nice.de>
-#
-# X2Go Session Broker is free software; you can redistribute it and/or modify
+# Copyright (C) 2010 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+# 
+# Python X2Go is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published by
 # the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
-# X2Go Session Broker is distributed in the hope that it will be useful,
+# Python X2Go 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 Affero General Public License for more details.
@@ -18,6 +17,12 @@
 # Free Software Foundation, Inc.,
 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-__VERSION__ = '0.0.0.1'
+import os
+import sys
+base = os.path.join(os.path.split(os.path.split(os.getcwd())[0])[0])
 
+# prepend the X2Go path (useful for building new packages)
+sys.path = [ os.path.normpath(base), ] + sys.path
 
+import runalltests
+import test_printing
diff --git a/x2gobroker/tests/runalltests.py b/x2gobroker/tests/runalltests.py
new file mode 100644
index 0000000..d2ead75
--- /dev/null
+++ b/x2gobroker/tests/runalltests.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2010 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+# 
+# X2Go Session Broker is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# X2Go Session Broker 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+"""\
+This file is a default test runner as found in ZOPE/Plone products. It works 
+fine for any kind of Python unit testing---as we do here for Python X2GoBroker.
+"""
+
+import os
+import sys
+
+base = os.path.join(os.path.split(os.path.split(os.getcwd())[0])[0])
+
+try:
+    import x2gobroker
+except ImportError:
+    sys.path.insert(0, os.path.join(os.getcwd(), '../..'))
+
+# prepend the X2GoBroker path (useful for building new packages)
+sys.path = [os.path.normpath(base)] + sys.path
+
+import unittest
+TestRunner = unittest.TextTestRunner
+suite = unittest.TestSuite()
+
+tests = os.listdir(os.curdir)
+tests = [n[:-3] for n in tests if n.startswith('test') and n.endswith('.py')]
+
+for test in tests:
+    m = __import__(test)
+    if hasattr(m, 'test_suite'):
+        suite.addTest(m.test_suite())
+
+if __name__ == '__main__':
+    TestRunner().run(suite)
diff --git a/x2gobroker/tests/test_backend_base.py b/x2gobroker/tests/test_backend_base.py
new file mode 100644
index 0000000..2cdd066
--- /dev/null
+++ b/x2gobroker/tests/test_backend_base.py
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2010 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+# 
+# Python X2Go is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Python X2Go 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+import unittest
+import tempfile
+
+# Python X2GoBroker modules
+import x2gobroker.backends.base
+import x2gobroker.defaults
+
+class TestX2GoBrokerBackendBase(unittest.TestCase):
+
+    ### TEST CONFIGURATION: <backend> >> enable = true|false
+
+    def test_is_enabled(self):
+        _config_defaults = x2gobroker.defaults.X2GOBROKER_CONFIG_DEFAULTS
+        _config_defaults.update({'base': {'enable': True, }, })
+        _config = """
+[base]
+enable = false
+"""
+        tf = tempfile.NamedTemporaryFile()
+        print >> tf, _config
+        tf.seek(0)
+        base_backend = x2gobroker.backends.base.X2GoBroker(config_file=tf.name, config_defaults=_config_defaults)
+        self.assertEqual(base_backend.is_enabled(), False)
+        _config = """
+[base]
+enable = true
+"""
+        tf = tempfile.NamedTemporaryFile()
+        print >> tf, _config
+        tf.seek(0)
+        base_backend = x2gobroker.backends.base.X2GoBroker(config_file=tf.name)
+        self.assertEqual(base_backend.is_enabled(), True)
+        tf.close()
+
+    ### TEST CONFIGURATION: global >> check-credentials = false
+
+    def test_check_access_nocreds(self):
+        _config_defaults = x2gobroker.defaults.X2GOBROKER_CONFIG_DEFAULTS
+        _config_defaults.update({'base': {'enable': True, }, })
+        _config = """
+[global]
+check-credentials = false
+"""
+        tf = tempfile.NamedTemporaryFile()
+        print >> tf, _config
+        tf.seek(0)
+        base_backend = x2gobroker.backends.base.X2GoBroker(config_file=tf.name, config_defaults=_config_defaults)
+        self.assertEqual(base_backend.check_access(), True)
+        tf.close()
+
+def test_suite():
+    from unittest import TestSuite, makeSuite
+    suite = TestSuite()
+    suite.addTest(makeSuite(TestX2GoBrokerBackendBase))
+    return suite
diff --git a/x2gobroker/backends/zeroconf.py b/x2gobroker/tests/test_backend_zeroconf.py
similarity index 59%
copy from x2gobroker/backends/zeroconf.py
copy to x2gobroker/tests/test_backend_zeroconf.py
index b6c8cc1..f7d9b9d 100644
--- a/x2gobroker/backends/zeroconf.py
+++ b/x2gobroker/tests/test_backend_zeroconf.py
@@ -1,14 +1,13 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (C) 2012 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
-# Copyright (C) 2012 by Oleksandr Shneyder <oleksandr.shneyder at obviously-nice.de>
-#
-# X2Go Session Broker is free software; you can redistribute it and/or modify
+# Copyright (C) 2010 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+# 
+# Python X2Go is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published by
 # the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
-# X2Go Session Broker is distributed in the hope that it will be useful,
+# Python X2Go 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 Affero General Public License for more details.
@@ -18,29 +17,19 @@
 # Free Software Foundation, Inc.,
 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-"""\
-X2goBrokerZEROCONF class - a demo X2GoBroker implementations that needs not configuration at all
-
-"""
-__NAME__ = 'x2gobroker-pylib'
-
-# modules
-import subprocess
-import uuid
+import unittest
+import tempfile
 
 # Python X2GoBroker modules
-import base
-
-from x2gobroker.defaults import X2GOBROKER_AGENT_CMD as _X2GOBROKER_AGENT_CMD
+import x2gobroker.backends.zeroconf
 
-class X2GoBroker(base.X2GoBroker):
+class TestX2GoBrokerBackendZeroconf(unittest.TestCase):
 
-    backend_name = 'zeroconf'
-
-    def list_profiles(self, username):
+    ### TEST: list_profiles() method
 
+    def test_profilelist(self):
         list_of_profiles = {
-            uuid.uuid4(): {
+            'unittest': {
                 'user': u'',
                 'defsndport': True,
                 'useiconv': False,
@@ -70,18 +59,35 @@ class X2GoBroker(base.X2GoBroker):
                 'name': u'LOCALHOST',
                 'iconvto': u'UTF-8',
                 'soundtunnel': True,
-                'command': self.get_backend_value(self.backend_name, u'desktop-shell'),
+                'command': 'KDE',
                 'dpi': 96,
                 'sshport': 22,
                 'setdpi': 0,
                 'pack': u'16m-jpeg',
             },
         }
-        return list_of_profiles
+        zeroconf_backend = x2gobroker.backends.zeroconf.X2GoBroker()
+        _profiles = zeroconf_backend.list_profiles('user_foo')
+        self.assertEqual(len(_profiles.keys()), 1)
+        _key = _profiles.keys()[0]
+        # replace profile ID ,,unittest'' with the returned random profile ID (uuid hash)
+        _test_profiles = {
+            _key: list_of_profiles['unittest']
+        }
+        self.assertEqual(_profiles, _test_profiles)
 
-    def select_profile(self, profile_name):
+    ### TEST: select_profile() method
 
-        selectprofile_output = {
+    def test_profileselection(self):
+        _output = {
             'server': 'localhost:22',
         }
-        return selectprofile_output
+        zeroconf_backend = x2gobroker.backends.zeroconf.X2GoBroker()
+        self.assertEqual(zeroconf_backend.select_profile('profile_bar'), _output)
+
+
+def test_suite():
+    from unittest import TestSuite, makeSuite
+    suite = TestSuite()
+    suite.addTest(makeSuite(TestX2GoBrokerBackendZeroconf))
+    return suite


hooks/post-receive
-- 
x2gobroker.git (HTTP(S) Session broker for X2Go)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).




More information about the x2go-commits mailing list