From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 6DBAE1389F5 for ; Mon, 17 Nov 2014 23:58:07 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 547BAE0961; Mon, 17 Nov 2014 23:58:06 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A6EE1E0961 for ; Mon, 17 Nov 2014 23:58:05 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 97BB6340545 for ; Mon, 17 Nov 2014 23:58:04 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D44B3A587 for ; Mon, 17 Nov 2014 23:58:02 +0000 (UTC) From: "Devan Franchini" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" Message-ID: <1416268674.edd3a0f5d60c2fb2f0c248fcafab32855555d75d.twitch153@gentoo> Subject: [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/, WebappConfig/tests/ X-VCS-Repository: proj/webapp-config X-VCS-Files: WebappConfig/ebuild.py WebappConfig/tests/dtest.py WebappConfig/tests/external.py X-VCS-Directories: WebappConfig/tests/ WebappConfig/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: edd3a0f5d60c2fb2f0c248fcafab32855555d75d X-VCS-Branch: experimental Date: Mon, 17 Nov 2014 23:58:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: a2da41dd-8996-4925-8976-2396b33896f7 X-Archives-Hash: c35237e42dfa643759c125822aaef9fe commit: edd3a0f5d60c2fb2f0c248fcafab32855555d75d Author: Devan Franchini gentoo org> AuthorDate: Sun Nov 2 07:29:05 2014 +0000 Commit: Devan Franchini gentoo org> CommitDate: Mon Nov 17 23:57:54 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=edd3a0f5 Adds Ebuild tests to external test suite tests/dtest.py: Removes WebappConfig.ebuild from doctest listing tests/external.py: Adds tests for Ebuild class ebuild.py: Removes doctests, the tests used for testing run_hooks() were not added to the external test suite due to the fact that there is no return to check against, just output. --- WebappConfig/ebuild.py | 141 ----------------------------------------- WebappConfig/tests/dtest.py | 2 - WebappConfig/tests/external.py | 37 +++++++++++ 3 files changed, 37 insertions(+), 143 deletions(-) diff --git a/WebappConfig/ebuild.py b/WebappConfig/ebuild.py index 24ef0d6..fecbe44 100644 --- a/WebappConfig/ebuild.py +++ b/WebappConfig/ebuild.py @@ -35,69 +35,6 @@ class Ebuild: This class handles all ebuild related task. Currently this includes displaying the post install instruction as well as running hooks provided by the ebuild. - - This creates the basic configuration defaults: - - >>> import WebappConfig.config - >>> config = WebappConfig.config.Config() - - This needs to be completed with some parameters - that would be usually provided when parsing the - commandline: - - >>> config.config.set('USER', 'my_htdocsbase', 'htdocs') - >>> config.config.set('USER', 'pn', 'horde') - >>> config.config.set('USER', 'pvr', '3.0.5') - >>> config.config.set('USER', 'vhost_server_uid', 'apache') - >>> config.config.set('USER', 'vhost_server_gid', 'apache') - - And the application directory needs to be set - to the testfile reporitory - - >>> import os.path - >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> config.config.set('USER', 'my_approot', here + - ... '/tests/testfiles/share-webapps') - - Time to create the ebuild handler: - - >>> my_approot = config.config.get('USER', 'my_approot') - >>> my_appdir = my_approot + "/horde/3.0.5" - >>> config.config.set('USER', 'my_appdir', my_appdir) - >>> config.config.set('USER', 'my_hookscriptsdir', my_appdir + '/hooks') - >>> config.config.set('USER', 'my_cgibinbase', 'cgi-bin') - >>> config.config.set('USER', 'my_errorsbase', 'error') - >>> config.config.set('USER', 'my_iconsbase', 'icons') - >>> config.config.set('USER', 'my_serverconfigdir', '/'.join([my_appdir,'conf'])) - >>> config.config.set('USER', 'my_hostrootdir', '/'.join([my_appdir,'hostroot'])) - >>> config.config.set('USER', 'my_htdocsdir', '/'.join([my_appdir,'htdocs'])) - >>> config.config.set('USER', 'my_sqlscriptsdir', '/'.join([my_appdir,'sqlscripts'])) - >>> a = Ebuild(config) - - Run a hook script: - - >>> from WebappConfig.server import Basic - >>> basic = Basic({'source': '', 'destination': '', 'hostroot': '', 'vhostroot':''}, - ... config.create_permissions(), - ... {'source':'','content':'','protect':'','dotconfig':'','ebuild':'','db':''}, - ... {'verbose':False,'pretend':True}, 'portage') - >>> a.run_hooks('test', basic) - - The same on a directory that misses a hook dir: - - >>> config.config.set('USER', 'pn', 'empty') - >>> config.config.set('USER', 'pvr', '1.0') - >>> a = Ebuild(config) - >>> a.run_hooks('test', basic) - - This app has a hook dir but no script: - - >>> config.config.set('USER', 'pn', 'uninstalled') - >>> config.config.set('USER', 'pvr', '6.6.6') - >>> a = Ebuild(config) - >>> a.run_hooks('test', basic) - - ''' def __init__(self, config): @@ -197,80 +134,6 @@ class Ebuild: This function exports the necessary variables to the shell environment so that they are accessible within the shell scripts and/or files provided by the ebuild. - - The procedure from above is repeated to set up the default - environment: - - ">>> import WebappConfig.config" - ">>> config = WebappConfig.config.Config()" - ">>> config.config.set('USER', 'my_htdocsbase', 'htdocs')" - ">>> config.config.set('USER', 'pn', 'horde')" - ">>> config.config.set('USER', 'pvr', '3.0.5')" - ">>> import os.path" - ">>> here = os.path.dirname(os.path.realpath(__file__))" - ">>> config.config.set('USER', 'my_approot', here +" - "... '/tests/testfiles/share-webapps')" - ">>> my_approot = config.config.get('USER', 'my_approot')" - ">>> my_appdir = my_approot + "/horde/3.0.5"" - ">>> config.config.set('USER', 'my_appdir', my_appdir)" - ">>> config.config.set('USER', 'my_hookscriptsdir', my_appdir + '/hooks')" - ">>> config.config.set('USER', 'my_cgibinbase', 'cgi-bin')" - ">>> config.config.set('USER', 'my_errorsbase', 'error')" - ">>> config.config.set('USER', 'my_iconsbase', 'icons')" - ">>> config.config.set('USER', 'my_serverconfigdir', '/'.join([my_appdir,'conf']))" - ">>> config.config.set('USER', 'my_hostrootdir', '/'.join([my_appdir,'hostroot']))" - ">>> config.config.set('USER', 'my_htdocsdir', '/'.join([my_appdir,'htdocs']))" - ">>> config.config.set('USER', 'my_sqlscriptsdir', '/'.join([my_appdir,'sqlscripts']))" - - Time to create the ebuild handler: - - ">>> a = Ebuild(config)" - - The dummy post-install file should display all the variables - that are exported here: - - ">>> a.show_postinst() #doctest: +ELLIPSIS - - ================================================================= - POST-INSTALL INSTRUCTIONS - ================================================================= - - MY_HOSTROOTDIR: .../tests/testfiles/share-webapps/horde/3.0.5/hostroot - MY_HTDOCSDIR: .../tests/testfiles/share-webapps/horde/3.0.5/htdocs - MY_CGIBINDIR: .../tests/testfiles/share-webapps/horde/3.0.5/hostroot/cgi-bin - MY_INSTALLDIR: / - MY_ICONSDIR: .../tests/testfiles/share-webapps/horde/3.0.5/hostroot/icons - MY_SERVERCONFIGDIR: .../tests/testfiles/share-webapps/horde/3.0.5/conf - MY_ERRORSDIR: .../tests/testfiles/share-webapps/horde/3.0.5/hostroot/error - MY_SQLSCRIPTSDIR: .../tests/testfiles/share-webapps/horde/3.0.5/sqlscripts - VHOST_ROOT: /var/www/... - VHOST_HTDOCSDIR: /var/www/.../htdocs - VHOST_CGIBINDIR: /var/www/.../cgi-bin - VHOST_CONFDIR: /var/www/.../ - VHOST_ERRORSDIR: /var/www/.../error - VHOST_ICONSDIR: /var/www/.../icons - VHOST_HOSTNAME: ... - VHOST_SERVER: apache - VHOST_APPDIR: / - VHOST_CONFIG_UID: ... - VHOST_CONFIG_GID: ... - VHOST_SERVER_UID: ... - VHOST_SERVER_GID: ... - VHOST_DEFAULT_UID: 0 - VHOST_DEFAULT_GID: 0 - VHOST_PERMS_SERVEROWNED_DIR: 0775 - VHOST_PERMS_SERVEROWNED_FILE: 0664 - VHOST_PERMS_CONFIGOWNED_DIR: 0755 - VHOST_PERMS_CONFIGOWNED_FILE: 0644 - VHOST_PERMS_DEFAULTOWNED_DIR: 0755 - VHOST_PERMS_VIRTUALOWNED_FILE: o-w - VHOST_PERMS_INSTALLDIR: 0755 - ROOT: / - PN: horde - PVR: 3.0.5 - - ================================================================= - " ''' v_root = self.get_config('vhost_root') @@ -337,7 +200,3 @@ class Ebuild: result[i] = str(value) return result - -if __name__ == '__main__': - import doctest, sys - doctest.testmod(sys.modules[__name__]) diff --git a/WebappConfig/tests/dtest.py b/WebappConfig/tests/dtest.py index 8dab47a..a46be2c 100644 --- a/WebappConfig/tests/dtest.py +++ b/WebappConfig/tests/dtest.py @@ -8,14 +8,12 @@ import unittest, doctest, sys -import WebappConfig.ebuild import WebappConfig.filetype import WebappConfig.protect import WebappConfig.worker def test_suite(): return unittest.TestSuite(( - doctest.DocTestSuite(WebappConfig.ebuild), doctest.DocTestSuite(WebappConfig.filetype), doctest.DocTestSuite(WebappConfig.protect), doctest.DocTestSuite(WebappConfig.worker), diff --git a/WebappConfig/tests/external.py b/WebappConfig/tests/external.py index ffe76e8..88b98c8 100755 --- a/WebappConfig/tests/external.py +++ b/WebappConfig/tests/external.py @@ -22,10 +22,13 @@ import os import unittest import sys +from WebappConfig.config import Config from WebappConfig.content import Contents from WebappConfig.db import WebappDB, WebappSource from WebappConfig.debug import OUT from WebappConfig.dotconfig import DotConfig +from WebappConfig.ebuild import Ebuild +from WebappConfig.server import Basic from warnings import filterwarnings, resetwarnings HERE = os.path.dirname(os.path.realpath(__file__)) @@ -292,6 +295,40 @@ class DotConfigTest(unittest.TestCase): '.webapp'))) + +class EbuildTest(unittest.TestCase): + def test_showpostinst(self): + config = Config() + approot = '/'.join((HERE, 'testfiles', 'share-webapps')) + appdir = '/'.join((approot, 'horde', '3.0.5')) + conf = {'my_htdocsbase': 'htdocs', 'pn': 'horde', 'pvr': '3.0.5', + 'vhost_server_uid': 'apache', 'vhost_server_git': 'apache', + 'my_approot': approot, + 'my_appdir': appdir, + 'my_hookscriptsdir': '/'.join((appdir, 'hooks')), + 'my_cgibinbase': 'cgi-bin', 'my_errorsbase': 'error', + 'my_iconsbase': 'icons', + 'my_serverconfigdir': '/'.join((appdir, 'conf')), + 'my_hostrootdir': '/'.join((appdir, 'hostroot')), + 'my_htdocsdir': '/'.join((appdir, 'htdocs')), + 'my_sqlscriptsdir': '/'.join((appdir, 'sqlscripts')), + } + + for key in conf.keys(): + config.config.set('USER', key, conf[key]) + + ebuild = Ebuild(config) + ebuild.show_postinst() + output = sys.stdout.getvalue().split('\n') + + self.assertEqual(output[5], 'MY_HOSTROOTDIR: ' + '/'.join((HERE, + 'testfiles', + 'share-webapps', + 'horde', + '3.0.5', + 'hostroot'))) + + if __name__ == '__main__': filterwarnings('ignore') unittest.main(module=__name__, buffer=True)