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:58:02 +0000 (UTC) [thread overview]
Message-ID: <1416268674.e3d73e36bee5421a01b079b6db484b88e5899cbb.twitch153@gentoo> (raw)
commit: e3d73e36bee5421a01b079b6db484b88e5899cbb
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 2 05:56:40 2014 +0000
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Nov 17 23:57:54 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=e3d73e36
Adds DotConfig tests to external test suite
tests/dtest.py: Removes WebappConfig.dotconfig from doctest listing
tests/external.py: Adds tests for DotConfig class
dotconfig.py: Removes doctests
---
WebappConfig/dotconfig.py | 61 ------------------------------------------
WebappConfig/tests/dtest.py | 2 --
WebappConfig/tests/external.py | 47 +++++++++++++++++++++++++++++---
3 files changed, 43 insertions(+), 67 deletions(-)
diff --git a/WebappConfig/dotconfig.py b/WebappConfig/dotconfig.py
index 948fa90..0d5f661 100644
--- a/WebappConfig/dotconfig.py
+++ b/WebappConfig/dotconfig.py
@@ -35,63 +35,6 @@ class DotConfig:
'''
This class handles the dotconfig file that will be written to all
virtual install locations.
-
- A virtual install location has been prepared in the testfiles
- directory:
-
- >>> import os.path
- >>> here = os.path.dirname(os.path.realpath(__file__))
- >>> a = DotConfig(here + '/tests/testfiles/htdocs/horde')
- >>> a.has_dotconfig()
- True
-
- This directory contains no virtual install:
-
- >>> b = DotConfig(here + '/tests/testfiles/htdocs/empty')
- >>> b.has_dotconfig()
- False
-
- The horde install directory is empty:
-
- >>> a.is_empty()
-
- This install location has another web application installed::
-
- >>> b = DotConfig(here + '/tests/testfiles/htdocs/complain')
- >>> b.is_empty()
- '!morecontents .webapp-cool-1.1.1'
-
- This prints what is installed in the horde directory (and
- tests the read() function):
-
- >>> a.show_installed()
- horde 3.0.5
-
- This will pretend to write a .webapp file (this test has too many ellipsis):
-
- >>> OUT.color_off()
- >>> a = DotConfig('/nowhere', pretend = True)
- >>> a.write('www-apps', 'horde', '5.5.5', 'localhost', '/horde3', 'me:me') #doctest: +ELLIPSIS
- * Would have written the following information into /nowhere/.webapp:
- * # .webapp
- ...
- *
- * WEB_CATEGORY="www-apps"
- * WEB_PN="horde"
- * WEB_PVR="5.5.5"
- * WEB_INSTALLEDBY="..."
- * WEB_INSTALLEDDATE="..."
- * WEB_INSTALLEDFOR="me:me"
- * WEB_HOSTNAME="localhost"
- * WEB_INSTALLDIR="/horde3"
-
- Delete the .webapp file if possible:
-
- >>> a = DotConfig(here + '/tests/testfiles/htdocs/horde', pretend = True)
- >>> a.kill() #doctest: +ELLIPSIS
- * Would have removed .../tests/testfiles/htdocs/horde/.webapp
- True
-
'''
def __init__(self,
@@ -290,7 +233,3 @@ class DotConfig:
else:
OUT.notice('--- ' + empty)
return False
-
-if __name__ == '__main__':
- import doctest, sys
- doctest.testmod(sys.modules[__name__])
diff --git a/WebappConfig/tests/dtest.py b/WebappConfig/tests/dtest.py
index 645aee7..8dab47a 100644
--- a/WebappConfig/tests/dtest.py
+++ b/WebappConfig/tests/dtest.py
@@ -8,7 +8,6 @@
import unittest, doctest, sys
-import WebappConfig.dotconfig
import WebappConfig.ebuild
import WebappConfig.filetype
import WebappConfig.protect
@@ -16,7 +15,6 @@ import WebappConfig.worker
def test_suite():
return unittest.TestSuite((
- doctest.DocTestSuite(WebappConfig.dotconfig),
doctest.DocTestSuite(WebappConfig.ebuild),
doctest.DocTestSuite(WebappConfig.filetype),
doctest.DocTestSuite(WebappConfig.protect),
diff --git a/WebappConfig/tests/external.py b/WebappConfig/tests/external.py
index 3263c1a..ffe76e8 100755
--- a/WebappConfig/tests/external.py
+++ b/WebappConfig/tests/external.py
@@ -22,10 +22,11 @@ import os
import unittest
import sys
-from WebappConfig.content import Contents
-from WebappConfig.db import WebappDB, WebappSource
-from WebappConfig.debug import OUT
-from warnings import filterwarnings, resetwarnings
+from WebappConfig.content import Contents
+from WebappConfig.db import WebappDB, WebappSource
+from WebappConfig.debug import OUT
+from WebappConfig.dotconfig import DotConfig
+from warnings import filterwarnings, resetwarnings
HERE = os.path.dirname(os.path.realpath(__file__))
@@ -253,6 +254,44 @@ class WebappSourceTest(unittest.TestCase):
self.assertEqual(source.packageavail(), 1)
+class DotConfigTest(unittest.TestCase):
+ def test_has_dotconfig(self):
+ dotconf = DotConfig('/'.join((HERE, 'testfiles', 'htdocs', 'horde')))
+ self.assertTrue(dotconf.has_dotconfig())
+
+ dotconf = DotConfig('/'.join((HERE, 'testfiles', 'htdocs', 'empty')))
+ self.assertFalse(dotconf.has_dotconfig())
+
+ def test_is_empty(self):
+ dotconf = DotConfig('/'.join((HERE, 'testfiles', 'htdocs', 'horde')))
+ self.assertEqual(dotconf.is_empty(), None)
+
+ dotconf = DotConfig('/'.join((HERE, 'testfiles', 'htdocs', 'complain')))
+ self.assertEqual(dotconf.is_empty(), '!morecontents .webapp-cool-1.1.1')
+
+ def test_show_installed(self):
+ dotconf = DotConfig('/'.join((HERE, 'testfiles', 'htdocs', 'horde')))
+ dotconf.show_installed()
+ output = sys.stdout.getvalue().split('\n')
+ self.assertEqual(output[0], 'horde 3.0.5')
+
+ def test_install(self):
+ dotconf = DotConfig('/nowhere', pretend=True)
+ dotconf.write('www-apps', 'horde', '5.5.5', 'localhost', '/horde3',
+ 'me:me')
+ output = sys.stdout.getvalue().split('\n')
+ self.assertEqual(output[14], '* WEB_INSTALLDIR="/horde3"')
+
+ def test_remove(self):
+ dotconf = DotConfig('/'.join((HERE, 'testfiles', 'htdocs', 'horde')),
+ pretend=True)
+ self.assertTrue(dotconf.kill())
+ output = sys.stdout.getvalue().split('\n')
+ self.assertEqual(output[0], '* Would have removed ' +
+ '/'.join((HERE, 'testfiles', 'htdocs', 'horde',
+ '.webapp')))
+
+
if __name__ == '__main__':
filterwarnings('ignore')
unittest.main(module=__name__, buffer=True)
next reply other threads:[~2014-11-17 23:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-17 23:58 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: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-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=1416268674.e3d73e36bee5421a01b079b6db484b88e5899cbb.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