summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--WebappConfig/ebuild.py141
-rw-r--r--WebappConfig/tests/dtest.py2
-rwxr-xr-xWebappConfig/tests/external.py37
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
- <BLANKLINE>
- =================================================================
- POST-INSTALL INSTRUCTIONS
- =================================================================
- <BLANKLINE>
- 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
- <BLANKLINE>
- =================================================================
- <BLANKLINE>"
'''
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)