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 90B361389F5 for ; Mon, 17 Nov 2014 23:42:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D9290E0944; Mon, 17 Nov 2014 23:42:54 +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 3CDBBE0952 for ; Mon, 17 Nov 2014 23:42:54 +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 322B33404DA for ; Mon, 17 Nov 2014 23:42:53 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 40065A587 for ; Mon, 17 Nov 2014 23:42:50 +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: <1416267761.4cd947392b9885ffa702e45782be776835948e76.twitch153@gentoo> Subject: [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/tests/, WebappConfig/ X-VCS-Repository: proj/webapp-config X-VCS-Files: WebappConfig/tests/dtest.py WebappConfig/tests/external.py WebappConfig/worker.py X-VCS-Directories: WebappConfig/ WebappConfig/tests/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: 4cd947392b9885ffa702e45782be776835948e76 X-VCS-Branch: experimental Date: Mon, 17 Nov 2014 23:42:50 +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: f3903a87-80ec-436a-9a43-0d0a4e18516d X-Archives-Hash: 41b8c13009bcdb08a2165028e0c82c4a commit: 4cd947392b9885ffa702e45782be776835948e76 Author: Devan Franchini gentoo org> AuthorDate: Mon Nov 3 00:57:18 2014 +0000 Commit: Devan Franchini gentoo org> CommitDate: Mon Nov 17 23:42:41 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=4cd94739 Adds WebappAdd and WebappRemove tests to external test suite tests/dtest.py: Deletes dtest.py tests/external.py: Adds tests for WebappAdd and WebappRemove worker.py: Removes doctests --- WebappConfig/tests/dtest.py | 19 ------- WebappConfig/tests/external.py | 81 +++++++++++++++++++++++++++ WebappConfig/worker.py | 122 ----------------------------------------- 3 files changed, 81 insertions(+), 141 deletions(-) diff --git a/WebappConfig/tests/dtest.py b/WebappConfig/tests/dtest.py deleted file mode 100644 index 6931dd8..0000000 --- a/WebappConfig/tests/dtest.py +++ /dev/null @@ -1,19 +0,0 @@ -################################################################################ -# KOLAB LIBRARY - TESTING "CONDITION.PY" -################################################################################ -# test_condition.py -- Testing condition.py -# Copyright 2005 Gunnar Wrobel -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -import unittest, doctest, sys - -import WebappConfig.worker - -def test_suite(): - return unittest.TestSuite(( - doctest.DocTestSuite(WebappConfig.worker), - )) - -if __name__ == '__main__': - unittest.main(defaultTest='test_suite') diff --git a/WebappConfig/tests/external.py b/WebappConfig/tests/external.py index 3216dd5..3ad53e5 100755 --- a/WebappConfig/tests/external.py +++ b/WebappConfig/tests/external.py @@ -31,6 +31,7 @@ from WebappConfig.ebuild import Ebuild from WebappConfig.filetype import FileType from WebappConfig.protect import Protection from WebappConfig.server import Basic +from WebappConfig.worker import WebappAdd, WebappRemove from warnings import filterwarnings, resetwarnings HERE = os.path.dirname(os.path.realpath(__file__)) @@ -421,6 +422,86 @@ class ProtectTest(unittest.TestCase): self.assertEqual(output[8], '* etc-update') +class WebappAddTest(unittest.TestCase): + def test_mk(self): + OUT.color_off() + contents = Contents('/'.join((HERE, 'testfiles', 'installtest')), + pretend = True) + webrm = WebappRemove(contents, True, True) + protect = Protection('', 'horde', '3.0.5', 'portage') + source = WebappSource(root = '/'.join((HERE, 'testfiles', + 'share-webapps')), + category = '', package = 'installtest', + version = '1.0') + source.read() + source.ignore = ['.svn'] + + webadd = WebappAdd('htdocs', + '/'.join((HERE, 'testfiles', 'installtest')), + {'dir': {'default-owned': ('root', + 'root', + '0644')}, + 'file': {'virtual': ('root', + 'root', + '0644'), + 'server-owned': ('apache', + 'apache', + '0660'), + 'config-owned': ('nobody', + 'nobody', + '0600')} + }, + {'content': contents, + 'removal': webrm, + 'protect': protect, + 'source' : source}, + {'relative': 1, + 'upgrade' : False, + 'pretend' : True, + 'verbose' : False, + 'linktype': 'soft'}) + webadd.mkfile('test1') + webadd.mkfile('test4') + webadd.mkfile('test2') + webadd.mkfile('test3') + webadd.mkdir('dir1') + webadd.mkdir('dir2') + + output = sys.stdout.getvalue().split('\n') + + self.assertEqual(output[0], '* pretending to add: sym 1 virtual ' + + '"test1"') + self.assertEqual(output[1], '* pretending to add: file 1 ' + + 'server-owned "test4"') + self.assertEqual(output[3], '* pretending to add: sym 1 virtual ' + + '"test2"') + self.assertEqual(output[4], '^o^ hiding test3') + self.assertEqual(output[6], '* pretending to add: dir 1 ' + + 'default-owned "dir1"') + self.assertEqual(output[8], '* pretending to add: dir 1 ' + + 'default-owned "dir2"') + + # Now testing all of them combined: + webadd.mkdirs('') + output = sys.stdout.getvalue().split('\n') + self.assertEqual(output[20], '^o^ hiding /test3') + + +class WebappRemoveTest(unittest.TestCase): + def test_remove_files(self): + OUT.color_off() + contents = Contents('/'.join((HERE, 'testfiles', 'contents', 'app2')), + package = 'test', version = '1.0', pretend = True) + contents.read() + webrm = WebappRemove(contents, True, True) + webrm.remove_files() + + output = sys.stdout.getvalue().split('\n') + self.assertEqual(output[3], '* pretending to remove: ' + + '/'.join((HERE, 'testfiles', 'contents', 'app2', + 'test3'))) + + if __name__ == '__main__': filterwarnings('ignore') unittest.main(module=__name__, buffer=True) diff --git a/WebappConfig/worker.py b/WebappConfig/worker.py index 5b10060..8b10253 100644 --- a/WebappConfig/worker.py +++ b/WebappConfig/worker.py @@ -44,27 +44,6 @@ class WebappRemove: ''' This is the handler for removal of web applications from their virtual install locations. - - For removal of files a content handler is sufficient: - - >>> OUT.color_off() - >>> import os.path - >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> from WebappConfig.content import Contents - >>> a = Contents(here + '/tests/testfiles/contents/app2', - ... package = 'test', version = '1.0', pretend = True) - >>> a.read() - >>> b = WebappRemove(a, True, True) - - # Pretend to remove files: - - # b.remove_files() #doctest: +ELLIPSIS - - # Deleted the test since this will almost certainly fail because - # of the modification time. - - Deleted test for removal of directories. They are always reported as 'not - empty' in case I am working in the subversion repository. ''' def __init__(self, @@ -168,102 +147,6 @@ class WebappAdd: ''' This is the class that handles the actual transfer of files from the web application source directory to the virtual install location. - - The setup of the class is rather complex since a lot of different - handlers are needed for the task. - - >>> OUT.color_off() - >>> import os.path - >>> here = os.path.dirname(os.path.realpath(__file__)) - - The content handler points to the virtual install directory: - - >>> from WebappConfig.content import Contents - >>> a = Contents(here + '/tests/testfiles/installtest', pretend = True) - - Removal of files will be necessary while upgrading : - - >>> b = WebappRemove(a, True, True) - - The handler for protected files is simple: - - >>> import WebappConfig.protect - >>> c = WebappConfig.protect.Protection('','horde','3.0.5','portage') - - And finally a fully initialized source is needed: - - >>> from WebappConfig.db import WebappSource - >>> d = WebappSource(root=here + '/tests/testfiles/share-webapps', - ... category='', package='installtest', version='1.0') - >>> d.read() - >>> d.ignore = ['.svn'] - - >>> e = WebappAdd('htdocs', - ... here + '/tests/testfiles/installtest', - ... {'dir' : { - ... 'default-owned': ('root', 'root', '0644'), - ... }, - ... 'file' : { - ... 'virtual' : ('root', 'root', '0644'), - ... 'server-owned' : ('apache', 'apache', '0660'), - ... 'config-owned' : ('nobody', 'nobody', '0600'), - ... }}, - ... {'content': a, - ... 'removal': b, - ... 'protect': c, - ... 'source' : d}, - ... {'relative': 1, - ... 'upgrade': False, - ... 'pretend': True, - ... 'verbose': False, - ... 'linktype': 'soft'}) - - Installing a standard file: - - >>> e.mkfile('test1') - * pretending to add: sym 1 virtual "test1" - >>> e.mkfile('test4') - * pretending to add: file 1 server-owned "test4" - - This location is already occupied. But since the file is not - known, it will be deleted: - - >>> e.mkfile('test2') #doctest: +ELLIPSIS - * would have removed ".../tests/testfiles/installtest/test2" since it is in the way for the current install. It should not be present in that location! - * pretending to add: sym 1 virtual "test2" - - This location is also occupied but it it is a config protected - file so it may not be removed: - - >>> e.mkfile('test3') #doctest: - ^o^ hiding test3 - * pretending to add: file 1 config-owned "test3" - - >>> e.mkdir('dir1') - * pretending to add: dir 1 default-owned "dir1" - - >>> e.mkdir('dir2') #doctest: +ELLIPSIS - * .../tests/testfiles/installtest/dir2 already exists, but is not a directory - removing - * pretending to add: dir 1 default-owned "dir2" - - And finally everything combined: - - >>> e.mkdirs('') #doctest: +ELLIPSIS - * Installing from .../tests/testfiles/share-webapps/installtest/1.0/htdocs/ - * pretending to add: dir 1 default-owned "dir1" - * Installing from .../tests/testfiles/share-webapps/installtest/1.0/htdocs/dir1 - * pretending to add: sym 1 virtual "dir1/webapp_test" - * .../tests/testfiles/installtest//dir2 already exists, but is not a directory - removing - * pretending to add: dir 1 default-owned "dir2" - * Installing from .../tests/testfiles/share-webapps/installtest/1.0/htdocs/dir2 - * pretending to add: sym 1 virtual "dir2/webapp_test" - * pretending to add: sym 1 virtual "test1" - * would have removed ".../tests/testfiles/installtest//test2" since it is in the way for the current install. It should not be present in that location! - * pretending to add: sym 1 virtual "test2" - ^o^ hiding /test3 - * pretending to add: file 1 config-owned "test3" - * pretending to add: file 1 server-owned "test4" - ''' def __init__(self, @@ -593,8 +476,3 @@ class WebappAdd: filename, dst_name, self.__relative) - - -if __name__ == '__main__': - import doctest, sys - doctest.testmod(sys.modules[__name__])