[Zope-CVS] CVS: Products/Basket/tests - testBasket.py:1.24

Chris McDonough chrism at plope.com
Thu Nov 10 13:21:59 EST 2005


Update of /cvs-repository/Products/Basket/tests
In directory cvs.zope.org:/tmp/cvs-serv15635/tests

Modified Files:
	testBasket.py 
Log Message:
Break oiut Basket class and support functions into a basket.py module.

If an egg is marked explicitly as "not-zip-safe", unzip it to a tempdir and add the tempdir to sys.path.


=== Products/Basket/tests/testBasket.py 1.23 => 1.24 ===
--- Products/Basket/tests/testBasket.py:1.23	Wed Nov  9 22:13:53 2005
+++ Products/Basket/tests/testBasket.py	Thu Nov 10 13:21:29 2005
@@ -4,7 +4,7 @@
 import copy
 import Products
 from Products.Basket.utils import EggProductContext
-from Products.Basket import get_containing_package
+from Products.Basket.basket import get_containing_package
 import pkg_resources
 from OFS.ObjectManager import ObjectManager
 from OFS.SimpleItem import SimpleItem
@@ -122,7 +122,7 @@
         App.config.getConfiguration().debug_mode = self.old_debug_mode
 
     def _getTargetClass(self):
-        from Products.Basket import Basket
+        from Products.Basket.basket import Basket
         return Basket
 
     def _makeOne(self, *arg, **kw):
@@ -274,6 +274,27 @@
                          ['multiproduct1 initialized',
                           'multiproduct2 initialized'])
 
+    def test_not_zip_safe_exploded(self):
+        basket = self._makeOne()
+        basket.pdist_fname = os.path.join(self.fixtures, 'pdist-notzipsafe.txt')
+        
+        sys.path.append(self.fixtures)
+        self.working_set.add_entry(self.fixtures)
+
+        result = basket.initialize(DummyProductContext('Basket'))
+        self.assertEqual(len(basket.tempdirs), 1)
+        tempdir = basket.tempdirs[0]
+        self.failUnless(os.path.isdir(tempdir))
+        eggdir = os.path.join(tempdir, 'notzipsafe-0.1-py2.3.egg')
+        pkgdir = os.path.join(eggdir, 'notzipsafe')
+        self.failUnless(os.path.isdir(eggdir))
+        self.failUnless(os.path.isdir(pkgdir))
+        self.failUnless(os.path.isfile(os.path.join(pkgdir, '__init__.py')))
+        self.failUnless(os.path.isfile(os.path.join(pkgdir, 'test_image.jpg')))
+        self.failUnless(os.path.realpath(eggdir) in sys.path)
+        basket.cleanup()
+        self.failIf(os.path.isdir(tempdir))
+
     def test_product_distributions_by_dwim(self):
         basket = self._makeOne()
         basket.pre_initialized = True
@@ -290,14 +311,16 @@
 
     def test_product_distribution_not_a_zope_product(self):
         basket = self._makeOne()
-        basket.pre_initialized = True
-
         sys.path.append(self.fixtures)
         self.working_set.add_entry(self.fixtures)
 
+        basket.pre_initialized = False
+        pdist = os.path.join(self.fixtures, 'pdist-notproduct.txt')
+        basket.pdist_fname = pdist
+
         self._catch_log_errors(zLOG.ERROR)
         try:
-            basket.require('notazopeproduct')
+            basket.preinitialize()
         finally:
             self._ignore_log_errors()
 
@@ -313,7 +336,8 @@
 
         pdist = os.path.join(self.fixtures, 'pdist-ok.txt')
         self.assertEqual(basket.pre_initialized, False)
-        basket.preinitialize(pdist)
+        basket.pdist_fname = pdist
+        basket.preinitialize()
         self.assertEqual(basket.pre_initialized, True)
 
         import Products.product1
@@ -333,9 +357,9 @@
 
         pdist = os.path.join(self.fixtures, 'pdist-fail.txt')
         self.assertEqual(basket.pre_initialized, False)
+        basket.pdist_fname = pdist
         self.assertRaises(pkg_resources.DistributionNotFound,
-                          basket.preinitialize,
-                          pdist)
+                          basket.preinitialize)
         self.assertEqual(basket.pre_initialized, False)
 
         self.failIf(sys.modules.has_key('Products.product1'))
@@ -366,7 +390,8 @@
         # falls back to dwim mode
 
         self.assertEqual(basket.pre_initialized, False)
-        basket.preinitialize(pdist)
+        basket.pdist_fname = pdist
+        basket.preinitialize()
         self.assertEqual(basket.pre_initialized, True)
 
         import Products.product1



More information about the Zope-CVS mailing list