Merged from trunk 5791:5795 (WarnerBro)
authorFabian Groffen <grobian@gentoo.org>
Sun, 28 Jan 2007 17:49:39 +0000 (17:49 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sun, 28 Jan 2007 17:49:39 +0000 (17:49 -0000)
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

20 files changed:
tests/__init__.py
tests/portage/dep/__init__.py [moved from tests/portage_dep/__init__.py with 63% similarity]
tests/portage/dep/test_dep_getcpv.py [moved from tests/portage_dep/test_dep_getcpv.py with 95% similarity]
tests/portage/dep/test_dep_getslot.py [moved from tests/portage_dep/test_dep_getslot.py with 94% similarity]
tests/portage/dep/test_get_operator.py [moved from tests/portage_dep/test_get_operator.py with 95% similarity]
tests/portage/dep/test_isjustname.py [moved from tests/portage_dep/test_isjustname.py with 95% similarity]
tests/portage/dep/test_isvalidatom.py [moved from tests/portage_dep/test_isvalidatom.py with 96% similarity]
tests/portage/dep/test_match_from_list.py [moved from tests/portage_dep/test_match_from_list.py with 96% similarity]
tests/portage/news/__init__.py [moved from tests/portage_news/__init__.py with 63% similarity]
tests/portage/news/test_NewsItem.py [new file with mode: 0644]
tests/portage/util/__init__.py [moved from tests/portage_util/__init__.py with 64% similarity]
tests/portage/util/test_grabdict.py [moved from tests/portage_util/test_grabdict.py with 89% similarity]
tests/portage/util/test_normalizedPath.py [moved from tests/portage_util/test_normalizedPath.py with 89% similarity]
tests/portage/util/test_stackDictList.py [moved from tests/portage_util/test_stackDictList.py with 93% similarity]
tests/portage/util/test_stackDicts.py [moved from tests/portage_util/test_stackDicts.py with 96% similarity]
tests/portage/util/test_stackLists.py [moved from tests/portage_util/test_stackLists.py with 94% similarity]
tests/portage/util/test_uniqueArray.py [moved from tests/portage_util/test_uniqueArray.py with 89% similarity]
tests/portage/util/test_varExpand.py [moved from tests/portage_util/test_varExpand.py with 98% similarity]
tests/portage/versions/__init__.py [moved from tests/portage_versions/__init__.py with 64% similarity]
tests/portage/versions/test_vercmp.py [moved from tests/portage_versions/test_vercmp.py with 93% similarity]

index 4ac94383f023ce0bc753d33d7cbdac6a4326a740..f9bca5ee6e36cfeaf02c208310eff3091cca34ef 100644 (file)
@@ -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()
 
similarity index 63%
rename from tests/portage_dep/__init__.py
rename to tests/portage/dep/__init__.py
index a258eec6017b44a61fdc958119b45f524e2eaf01..a3226c133d1705e80ab10804727f839ef4879654 100644 (file)
@@ -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$
similarity index 95%
rename from tests/portage_dep/test_dep_getcpv.py
rename to tests/portage/dep/test_dep_getcpv.py
index d4d78d9a947e91cfc30087d349ea6ba83f2abef4..857a408a3c7e65e4695a7030309966f66e01664e 100644 (file)
@@ -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
similarity index 94%
rename from tests/portage_dep/test_dep_getslot.py
rename to tests/portage/dep/test_dep_getslot.py
index 9801e064b4912c43729c988beefd932e624e2c24..7c3004d050831fc0f67c2daf299d1742082a1ec5 100644 (file)
@@ -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
similarity index 95%
rename from tests/portage_dep/test_get_operator.py
rename to tests/portage/dep/test_get_operator.py
index 72063f39ab48594059bc4cf5ba4b5066956248b1..28485e0f0bf618f3a95f39d1fbdc701cc4dd54fa 100644 (file)
@@ -4,7 +4,7 @@
 # $Id$
 
 from unittest import TestCase
-from portage_dep import get_operator
+from portage.dep import get_operator
 
 class GetOperator(TestCase):
 
similarity index 95%
rename from tests/portage_dep/test_isjustname.py
rename to tests/portage/dep/test_isjustname.py
index 3242244139838ea370ae2583c2b1d7432be33c37..e419e3f2643bb27206f2f63b75449c41e853fb56 100644 (file)
@@ -4,7 +4,7 @@
 # $Id$
 
 from unittest import TestCase
-from portage_dep import isjustname
+from portage.dep import isjustname
 
 class IsJustName(TestCase):
 
similarity index 96%
rename from tests/portage_dep/test_isvalidatom.py
rename to tests/portage/dep/test_isvalidatom.py
index ed66b34876803b5e1534b76a5a58671cd1f8571a..d373a52f050e52324e8be3b130a98662a5fcf56e 100644 (file)
@@ -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
similarity index 96%
rename from tests/portage_dep/test_match_from_list.py
rename to tests/portage/dep/test_match_from_list.py
index d9d53ccbd29d1a0330bfc11fcca219eb9610f6ce..4868184a6f9638f86db012efd62b1315f1621642 100644 (file)
@@ -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
similarity index 63%
rename from tests/portage_news/__init__.py
rename to tests/portage/news/__init__.py
index cc7420e1f77a57f6479151e55375df5dff66e307..aeaa49195f5351f4f2df2c8a54f2bf472aa15484 100644 (file)
@@ -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 (file)
index 0000000..22ef298
--- /dev/null
@@ -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 <ciaranm@gentoo.org>
+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 )
similarity index 64%
rename from tests/portage_util/__init__.py
rename to tests/portage/util/__init__.py
index 9325f85f14dc625789428ead6a3d0bdcef3321d0..9a66903d17bfeb0419f61912551c805683c8e6f7 100644 (file)
@@ -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$
similarity index 89%
rename from tests/portage_util/test_grabdict.py
rename to tests/portage/util/test_grabdict.py
index 9b995fa2494402f89543680a6d04e3364c99ee14..9f7b589215a5f08b6c4612c00f76c668760876bc 100644 (file)
@@ -4,7 +4,7 @@
 # $Id$
 
 from unittest import TestCase, TestLoader
-from portage_util import grabdict
+from portage.util import grabdict
 
 class GrabDictTestCase(TestCase):
        
similarity index 89%
rename from tests/portage_util/test_normalizedPath.py
rename to tests/portage/util/test_normalizedPath.py
index 9740306aa3114d5d0ae31cdd6f73b55f5109f97b..bd575d26680a5943ed17f0e8430eddea939d8bd6 100644 (file)
@@ -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)
similarity index 93%
rename from tests/portage_util/test_stackDictList.py
rename to tests/portage/util/test_stackDictList.py
index 45b67b83898cb35593ece1e56f0c6c315d3d0880..9e7a38ba16b943d3d173f5d92d0f5b339078d6fc 100644 (file)
@@ -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,{} ))
similarity index 96%
rename from tests/portage_util/test_stackDicts.py
rename to tests/portage/util/test_stackDicts.py
index 7293004b603da1e42f70ffd9b1c1c7796d9e449f..9d963744004fb612d8142e458d5a28f73b0b7c07 100644 (file)
@@ -4,7 +4,7 @@
 # $Id$
 
 from unittest import TestCase
-from portage_util import stack_dicts
+from portage.util import stack_dicts
 
 
 class StackDictsTestCase(TestCase):
similarity index 94%
rename from tests/portage_util/test_stackLists.py
rename to tests/portage/util/test_stackLists.py
index 9a88902da48f8e52e0fd1a798fb6edd3f658913d..3fc028323a07cf1538b67e64ca62abc2070578ab 100644 (file)
@@ -4,7 +4,7 @@
 # $Id$
 
 from unittest import TestCase
-from portage_util import stack_lists
+from portage.util import stack_lists
 
 class StackListsTestCase(TestCase):
        
similarity index 89%
rename from tests/portage_util/test_uniqueArray.py
rename to tests/portage/util/test_uniqueArray.py
index c9c9e217d3ee5691f839e91395460670170a9d44..62a3153217c93e5671d7f62227dd84821fc53c66 100644 (file)
@@ -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
similarity index 98%
rename from tests/portage_util/test_varExpand.py
rename to tests/portage/util/test_varExpand.py
index 0515bf7e56c116711da53a615085559b1e07c5c1..47dc7de2cad9024721f3a21849dae978914cdec5 100644 (file)
@@ -4,7 +4,7 @@
 # $Id$
 
 from unittest import TestCase, TestLoader
-from portage_util import varexpand
+from portage.util import varexpand
 
 class VarExpandTestCase(TestCase):
        
similarity index 64%
rename from tests/portage_versions/__init__.py
rename to tests/portage/versions/__init__.py
index 76f62f969f26200b6037ac93bc673d211ad4f188..5e5b216fba49a3873a67bf3e2b4b7ac97476024e 100644 (file)
@@ -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$
similarity index 93%
rename from tests/portage_versions/test_vercmp.py
rename to tests/portage/versions/test_vercmp.py
index 117472e492ab0a060bc83a4e91d05201ab88af53..ee3d3774151a5f81d09ed16ef488e8914c6385a0 100644 (file)
@@ -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):