From: Fabian Groffen Date: Sun, 28 Jan 2007 17:49:39 +0000 (-0000) Subject: Merged from trunk 5791:5795 (WarnerBro) X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=f73e88d9eadb04528fe1597fbca2e100963bd5b6;p=portage.git Merged from trunk 5791:5795 (WarnerBro) fix namespacing in tests add test to entice svn mv Move tests into new directory structure fix minor sed overzeallousness svn path=/main/branches/prefix/; revision=5812 --- diff --git a/tests/__init__.py b/tests/__init__.py index 4ac94383f..f9bca5ee6 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -7,7 +7,7 @@ import os, unittest def main(): - testDirs = ["portage", "portage_util","portage_versions", "portage_dep"] + testDirs = ["portage", "portage/util","portage/versions", "portage/dep"] suite = unittest.TestSuite() diff --git a/tests/portage_dep/__init__.py b/tests/portage/dep/__init__.py similarity index 63% rename from tests/portage_dep/__init__.py rename to tests/portage/dep/__init__.py index a258eec60..a3226c133 100644 --- a/tests/portage_dep/__init__.py +++ b/tests/portage/dep/__init__.py @@ -1,4 +1,4 @@ -# tests/portage_dep/__init__.py -- Portage Unit Test functionality +# tests/portage.dep/__init__.py -- Portage Unit Test functionality # Copyright 2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ diff --git a/tests/portage_dep/test_dep_getcpv.py b/tests/portage/dep/test_dep_getcpv.py similarity index 95% rename from tests/portage_dep/test_dep_getcpv.py rename to tests/portage/dep/test_dep_getcpv.py index d4d78d9a9..857a408a3 100644 --- a/tests/portage_dep/test_dep_getcpv.py +++ b/tests/portage/dep/test_dep_getcpv.py @@ -4,7 +4,7 @@ # $Id$ from unittest import TestCase -from portage_dep import dep_getcpv +from portage.dep import dep_getcpv class DepGetCPV(TestCase): """ A simple testcase for isvalidatom diff --git a/tests/portage_dep/test_dep_getslot.py b/tests/portage/dep/test_dep_getslot.py similarity index 94% rename from tests/portage_dep/test_dep_getslot.py rename to tests/portage/dep/test_dep_getslot.py index 9801e064b..7c3004d05 100644 --- a/tests/portage_dep/test_dep_getslot.py +++ b/tests/portage/dep/test_dep_getslot.py @@ -4,7 +4,7 @@ # $Id$ from unittest import TestCase -from portage_dep import dep_getslot +from portage.dep import dep_getslot class DepGetSlot(TestCase): """ A simple testcase for isvalidatom diff --git a/tests/portage_dep/test_get_operator.py b/tests/portage/dep/test_get_operator.py similarity index 95% rename from tests/portage_dep/test_get_operator.py rename to tests/portage/dep/test_get_operator.py index 72063f39a..28485e0f0 100644 --- a/tests/portage_dep/test_get_operator.py +++ b/tests/portage/dep/test_get_operator.py @@ -4,7 +4,7 @@ # $Id$ from unittest import TestCase -from portage_dep import get_operator +from portage.dep import get_operator class GetOperator(TestCase): diff --git a/tests/portage_dep/test_isjustname.py b/tests/portage/dep/test_isjustname.py similarity index 95% rename from tests/portage_dep/test_isjustname.py rename to tests/portage/dep/test_isjustname.py index 324224413..e419e3f26 100644 --- a/tests/portage_dep/test_isjustname.py +++ b/tests/portage/dep/test_isjustname.py @@ -4,7 +4,7 @@ # $Id$ from unittest import TestCase -from portage_dep import isjustname +from portage.dep import isjustname class IsJustName(TestCase): diff --git a/tests/portage_dep/test_isvalidatom.py b/tests/portage/dep/test_isvalidatom.py similarity index 96% rename from tests/portage_dep/test_isvalidatom.py rename to tests/portage/dep/test_isvalidatom.py index ed66b3487..d373a52f0 100644 --- a/tests/portage_dep/test_isvalidatom.py +++ b/tests/portage/dep/test_isvalidatom.py @@ -4,7 +4,7 @@ # $Id$ from unittest import TestCase -from portage_dep import isvalidatom +from portage.dep import isvalidatom class IsValidAtom(TestCase): """ A simple testcase for isvalidatom diff --git a/tests/portage_dep/test_match_from_list.py b/tests/portage/dep/test_match_from_list.py similarity index 96% rename from tests/portage_dep/test_match_from_list.py rename to tests/portage/dep/test_match_from_list.py index d9d53ccbd..4868184a6 100644 --- a/tests/portage_dep/test_match_from_list.py +++ b/tests/portage/dep/test_match_from_list.py @@ -4,7 +4,7 @@ # $Id$ from unittest import TestCase -from portage_dep import match_from_list +from portage.dep import match_from_list class AtomCmpEqualGlob(TestCase): """ A simple testcase for =* glob matching diff --git a/tests/portage_news/__init__.py b/tests/portage/news/__init__.py similarity index 63% rename from tests/portage_news/__init__.py rename to tests/portage/news/__init__.py index cc7420e1f..aeaa49195 100644 --- a/tests/portage_news/__init__.py +++ b/tests/portage/news/__init__.py @@ -1,4 +1,4 @@ -# tests/portage_news/__init__.py -- Portage Unit Test functionality +# tests/portage.news/__init__.py -- Portage Unit Test functionality # Copyright 2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ diff --git a/tests/portage/news/test_NewsItem.py b/tests/portage/news/test_NewsItem.py new file mode 100644 index 000000000..22ef298d4 --- /dev/null +++ b/tests/portage/news/test_NewsItem.py @@ -0,0 +1,83 @@ +# test_NewsItem.py -- Portage Unit Testing Functionality +# Copyright 2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id: test_varExpand.py 5596 2007-01-12 08:08:53Z antarus $ + +from unittest import TestCase, TestLoader +from portage.news import NewsItem +from portage.const import PROFILE_PATH + +class NewsItemTestCase(TestCase): + + self.fakeItem = """ +Title: YourSQL Upgrades from 4.0 to 4.1 +Author: Ciaran McCreesh +Content-Type: text/plain +Posted: 01-Nov-2005 +Revision: 1 +#Display-If-Installed: +#Display-If-Profile: +#Display-If-Arch: + +YourSQL databases created using YourSQL version 4.0 are incompatible +with YourSQL version 4.1 or later. There is no reliable way to +automate the database format conversion, so action from the system +administrator is required before an upgrade can take place. + +Please see the Gentoo YourSQL Upgrade Guide for instructions: + + http://www.gentoo.org/doc/en/yoursql-upgrading.xml + +Also see the official YourSQL documentation: + + http://dev.yoursql.com/doc/refman/4.1/en/upgrading-from-4-0.html + +After upgrading, you should also recompile any packages which link +against YourSQL: + + revdep-rebuild --library=libyoursqlclient.so.12 + +The revdep-rebuild tool is provided by app-portage/gentoolkit. +""" + + from portage import settings + import time + + def testDisplayIfProfile(): + from portage.const import PROFILE_PATH + tmpItem = self.fakeItem.replace("#Display-If-Profile:", "Display-If-Profile: %s" % + os.readlink( PROFILE_PATH ) ) + + item = _processItem(tmpItem) + self.assertTrue( item.isRelevant( os.readlink( PROFILE_PATH ) ), + msg="Expected %s to be relevant, but it was not!" % tmpItem ) + + def testDisplayIfInstalled(): + tmpItem = self.fakeItem.replace("#Display-If-Installed:", "Display-If-Profile: %s" % + "sys-apps/portage" ) + + item = _processItem(tmpItem) + self.assertTrue( item.isRelevant( portage.settings ), + msg="Expected %s to be relevant, but it was not!" % tmpItem ) + + + def testDisplayIfKeyword(): + from portage import settings + tmpItem = self.fakeItem.replace("#Display-If-Keyword:", "Display-If-Keyword: %s" % + settings["ACCEPT_KEYWORDS"].split()[0] ) + + item = _processItem(tmpItem) + self.assertTrue( item.isRelevant( os.readlink( PROFILE_PATH ) ), + msg="Expected %s to be relevant, but it was not!" % tmpItem ) + + + def _processItem( self, item ): + + path = os.path.join( settings["PORTAGE_TMPDIR"], str(time.time()) + f = open( os.path.join( path ) + f.write(item) + f.close + try: + return NewsItem( path, 0 ) + except TypeError: + self.fail("Error while processing news item %s" % path ) diff --git a/tests/portage_util/__init__.py b/tests/portage/util/__init__.py similarity index 64% rename from tests/portage_util/__init__.py rename to tests/portage/util/__init__.py index 9325f85f1..9a66903d1 100644 --- a/tests/portage_util/__init__.py +++ b/tests/portage/util/__init__.py @@ -1,4 +1,4 @@ -# tests/portage_util/__init__.py -- Portage Unit Test functionality +# tests/portage.util/__init__.py -- Portage Unit Test functionality # Copyright 2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ diff --git a/tests/portage_util/test_grabdict.py b/tests/portage/util/test_grabdict.py similarity index 89% rename from tests/portage_util/test_grabdict.py rename to tests/portage/util/test_grabdict.py index 9b995fa24..9f7b58921 100644 --- a/tests/portage_util/test_grabdict.py +++ b/tests/portage/util/test_grabdict.py @@ -4,7 +4,7 @@ # $Id$ from unittest import TestCase, TestLoader -from portage_util import grabdict +from portage.util import grabdict class GrabDictTestCase(TestCase): diff --git a/tests/portage_util/test_normalizedPath.py b/tests/portage/util/test_normalizedPath.py similarity index 89% rename from tests/portage_util/test_normalizedPath.py rename to tests/portage/util/test_normalizedPath.py index 9740306aa..bd575d266 100644 --- a/tests/portage_util/test_normalizedPath.py +++ b/tests/portage/util/test_normalizedPath.py @@ -9,7 +9,7 @@ class NormalizePathTestCase(TestCase): def testNormalizePath(self): - from portage_util import normalize_path + from portage.util import normalize_path path = "///foo/bar/baz" good = "/foo/bar/baz" self.assertEqual(normalize_path(path), good) diff --git a/tests/portage_util/test_stackDictList.py b/tests/portage/util/test_stackDictList.py similarity index 93% rename from tests/portage_util/test_stackDictList.py rename to tests/portage/util/test_stackDictList.py index 45b67b838..9e7a38ba1 100644 --- a/tests/portage_util/test_stackDictList.py +++ b/tests/portage/util/test_stackDictList.py @@ -8,7 +8,7 @@ from unittest import TestCase class StackDictListTestCase(TestCase): def testStackDictList(self): - from portage_util import stack_dictlist + from portage.util import stack_dictlist tests = [ ({'a':'b'},{'x':'y'},False,{'a':['b'],'x':['y']}) ] tests.append(( {'KEYWORDS':['alpha','x86']},{'KEYWORDS':['-*']},True,{} )) diff --git a/tests/portage_util/test_stackDicts.py b/tests/portage/util/test_stackDicts.py similarity index 96% rename from tests/portage_util/test_stackDicts.py rename to tests/portage/util/test_stackDicts.py index 7293004b6..9d9637440 100644 --- a/tests/portage_util/test_stackDicts.py +++ b/tests/portage/util/test_stackDicts.py @@ -4,7 +4,7 @@ # $Id$ from unittest import TestCase -from portage_util import stack_dicts +from portage.util import stack_dicts class StackDictsTestCase(TestCase): diff --git a/tests/portage_util/test_stackLists.py b/tests/portage/util/test_stackLists.py similarity index 94% rename from tests/portage_util/test_stackLists.py rename to tests/portage/util/test_stackLists.py index 9a88902da..3fc028323 100644 --- a/tests/portage_util/test_stackLists.py +++ b/tests/portage/util/test_stackLists.py @@ -4,7 +4,7 @@ # $Id$ from unittest import TestCase -from portage_util import stack_lists +from portage.util import stack_lists class StackListsTestCase(TestCase): diff --git a/tests/portage_util/test_uniqueArray.py b/tests/portage/util/test_uniqueArray.py similarity index 89% rename from tests/portage_util/test_uniqueArray.py rename to tests/portage/util/test_uniqueArray.py index c9c9e217d..62a315321 100644 --- a/tests/portage_util/test_uniqueArray.py +++ b/tests/portage/util/test_uniqueArray.py @@ -4,13 +4,13 @@ # $Id$ from unittest import TestCase -from portage_util import unique_array +from portage.util import unique_array class UniqueArrayTestCase(TestCase): def testUniqueArrayPass(self): """ - test portage_util.uniqueArray() + test portage.util.uniqueArray() """ import os diff --git a/tests/portage_util/test_varExpand.py b/tests/portage/util/test_varExpand.py similarity index 98% rename from tests/portage_util/test_varExpand.py rename to tests/portage/util/test_varExpand.py index 0515bf7e5..47dc7de2c 100644 --- a/tests/portage_util/test_varExpand.py +++ b/tests/portage/util/test_varExpand.py @@ -4,7 +4,7 @@ # $Id$ from unittest import TestCase, TestLoader -from portage_util import varexpand +from portage.util import varexpand class VarExpandTestCase(TestCase): diff --git a/tests/portage_versions/__init__.py b/tests/portage/versions/__init__.py similarity index 64% rename from tests/portage_versions/__init__.py rename to tests/portage/versions/__init__.py index 76f62f969..5e5b216fb 100644 --- a/tests/portage_versions/__init__.py +++ b/tests/portage/versions/__init__.py @@ -1,4 +1,4 @@ -# tests/portage_versions/__init__.py -- Portage Unit Test functionality +# tests/portage.versions/__init__.py -- Portage Unit Test functionality # Copyright 2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ diff --git a/tests/portage_versions/test_vercmp.py b/tests/portage/versions/test_vercmp.py similarity index 93% rename from tests/portage_versions/test_vercmp.py rename to tests/portage/versions/test_vercmp.py index 117472e49..ee3d37741 100644 --- a/tests/portage_versions/test_vercmp.py +++ b/tests/portage/versions/test_vercmp.py @@ -4,10 +4,10 @@ # $Id$ from unittest import TestCase -from portage_versions import vercmp +from portage.versions import vercmp class VerCmpTestCase(TestCase): - """ A simple testCase for portage_versions.vercmp() + """ A simple testCase for portage.versions.vercmp() """ def testVerCmpGreater(self):