From: "Devan Franchini" <twitch153@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/tests/, WebappConfig/
Date: Mon, 17 Nov 2014 23:42:50 +0000 (UTC) [thread overview]
Message-ID: <1416267760.56636b1fe3891e0b7ee6e8e6e3f4b8e9f68a9db6.twitch153@gentoo> (raw)
commit: 56636b1fe3891e0b7ee6e8e6e3f4b8e9f68a9db6
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 2 07:29:05 2014 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Nov 17 23:42:40 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=56636b1f
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
- <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 75c2eb6..6c0fa3a 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__))
@@ -293,6 +296,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)
next reply other threads:[~2014-11-17 23:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-17 23:42 Devan Franchini [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-06-19 19:19 [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/tests/, WebappConfig/ Devan Franchini
2014-11-17 23:58 Devan Franchini
2014-11-17 23:58 Devan Franchini
2014-11-17 23:58 Devan Franchini
2014-11-17 23:58 Devan Franchini
2014-11-17 23:42 Devan Franchini
2014-11-17 23:42 Devan Franchini
2014-11-17 23:42 Devan Franchini
2014-11-17 23:42 Devan Franchini
2014-11-17 23:42 Devan Franchini
2014-11-03 0:02 Devan Franchini
2014-11-03 0:02 Devan Franchini
2014-11-02 8:27 Devan Franchini
2014-11-02 7:37 Devan Franchini
2014-11-02 7:37 Devan Franchini
2014-11-02 5:58 Devan Franchini
2014-11-02 5:58 Devan Franchini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1416267760.56636b1fe3891e0b7ee6e8e6e3f4b8e9f68a9db6.twitch153@gentoo \
--to=twitch153@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox