[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools/tests - test_app.py:1.11 test_dependencies.py:1.5 test_include.py:1.15 test_locationmap.py:1.4

Fred L. Drake, Jr. fred at zope.com
Tue May 4 10:08:47 EDT 2004


Update of /cvs-repository/Packages/zpkgtools/zpkgtools/tests
In directory cvs.zope.org:/tmp/cvs-serv23481/zpkgtools/tests

Modified Files:
	test_app.py test_dependencies.py test_include.py 
	test_locationmap.py 
Log Message:
Checkpoint:
- remove the notion of resource types; now everything is just stuff
- change the layout of the distribution tree to match the
  documentation

This involves lots of changes in the internal APIs, with corresponding
changes in the tests.  Many tests have been removed since they no
longer make sense.

This change is not complete; *using* the distribution has not been
updated.


=== Packages/zpkgtools/zpkgtools/tests/test_app.py 1.10 => 1.11 ===
--- Packages/zpkgtools/zpkgtools/tests/test_app.py:1.10	Tue Apr 27 17:04:13 2004
+++ Packages/zpkgtools/zpkgtools/tests/test_app.py	Tue May  4 10:08:43 2004
@@ -184,49 +184,23 @@
         # Too many trailing numeric seqments
         eq(convert("mypkg-1_2_3alpha4_5"), None)
 
-
-class DistributionWithConflictingNamesTestCase(unittest.TestCase):
-    """Test that conflicting component names generates an error message."""
-
-    def setUp(self):
-        self.old_tempdir = tempfile.tempdir
-        self.stderr = sys.stderr
-        self.tmpdir = tempfile.mkdtemp(prefix="test_app_")
-        os.mkdir(os.path.join(self.tmpdir, "d1"))
-        os.mkdir(os.path.join(self.tmpdir, "d2"))
-        # define the resource map
-        self.mapfile = os.path.join(self.tmpdir, "resource.map")
-        f = open(self.mapfile, "w")
-        f.write("package:r    d1\n")
-        f.write("collection:r d2\n")
-        f.close()
-        # make collection:r depend on package:r
-        f = open(os.path.join(self.tmpdir, "d2", "DEPENDENCIES.cfg"), "w")
-        f.write("package:r\n")
-        f.close()
-        # make collection:r packagable
-        publicationfile = os.path.join(self.tmpdir, "d2",
-                                       publication.PUBLICATION_CONF)
-        f = open(publicationfile, "w")
-        f.write("Metadata-version: 1.0\n")
-        f.write("Name: foo\n")
-        f.close()
-        sys.stderr = StringIO()
-
-    def tearDown(self):
-        shutil.rmtree(self.tmpdir)
-        tempfile.tempdir = self.old_tempdir
-        sys.stderr = self.stderr
-
-    def test_conflicting_resource_names(self):
-        resource_map = "file://" + urllib.pathname2url(self.mapfile)
-        options = app.parse_args(["-f", "-m", resource_map, "collection:r"])
-        appobj = app.BuilderApplication(options)
-        appobj.load_resource()
-        self.assertRaises(SystemExit, appobj.build_distribution)
-        appobj.cleanup()
-        # I'm undecided whether the message itself should be checked.
-        self.assert_(sys.stderr.getvalue())
+    def test_control_build_type(self):
+        options = self.parse_args([])
+        self.assert_(options.build_type is None)
+        # collection
+        # short arg:
+        options = self.parse_args(["-c"])
+        self.assert_(options.build_type is "collection")
+        # long arg:
+        options = self.parse_args(["--collection"])
+        self.assert_(options.build_type is "collection")
+        # application
+        # short arg:
+        options = self.parse_args(["-a"])
+        self.assert_(options.build_type is "application")
+        # long arg:
+        options = self.parse_args(["--application"])
+        self.assert_(options.build_type is "application")
 
 
 class ApplicationSupportTestCase(unittest.TestCase):
@@ -237,37 +211,21 @@
         pkgmap = os.path.join(self.tmpdir, "packages.map")
         self.mapfile = "file://" + urllib.pathname2url(pkgmap)
         f = open(pkgmap, "w")
-        print >>f, ("collection:application  file://"
+        print >>f, ("application  file://"
                     + urllib.pathname2url(appdir))
         f.close()
         os.mkdir(appdir)
         f = open(os.path.join(appdir, publication.PUBLICATION_CONF), "w")
         print >>f, "Metadata-Version: 1.0"
         print >>f, "Name: sample application"
-        print >>f, "Installation-type: Application"
         f.close()
 
     def tearDown(self):
         shutil.rmtree(self.tmpdir)
 
-    def test_load_metadata(self):
-        # Check that when the metadata for an application distribution
-        # is loaded, that the resource_type is revised to reflect the
-        # application status.
-        argv = [CMD,
-                "-f", "-m", self.mapfile, "-v1.0",
-                "collection:application"]
-        options = app.parse_args(argv)
-        application = app.BuilderApplication(options)
-        self.assertEqual(application.resource_type, "collection")
-        #
-        application.load_resource()
-        self.assertEqual(application.resource_type, "application")
-
 
 def test_suite():
     suite = unittest.makeSuite(CommandLineTestCase)
-    suite.addTest(unittest.makeSuite(DistributionWithConflictingNamesTestCase))
     suite.addTest(unittest.makeSuite(ApplicationSupportTestCase))
     return suite
 


=== Packages/zpkgtools/zpkgtools/tests/test_dependencies.py 1.4 => 1.5 ===
--- Packages/zpkgtools/zpkgtools/tests/test_dependencies.py:1.4	Wed Apr  7 23:50:16 2004
+++ Packages/zpkgtools/zpkgtools/tests/test_dependencies.py	Tue May  4 10:08:43 2004
@@ -42,8 +42,8 @@
             """)
         deps = dependencies.load(sio)
         self.assertEqual(len(deps), 2)
-        self.assert_("package:zope.foo" in deps)
-        self.assert_("package:zope.app.bar" in deps)
+        self.assert_("zope.foo" in deps)
+        self.assert_("zope.app.bar" in deps)
 
     def test_just_others(self):
         sio = StringIO("""\
@@ -65,8 +65,8 @@
             """)
         deps = dependencies.load(sio)
         self.assertEqual(len(deps), 4)
-        self.assert_("package:zope.foo" in deps)
-        self.assert_("package:zope.app.bar" in deps)
+        self.assert_("zope.foo" in deps)
+        self.assert_("zope.app.bar" in deps)
         self.assert_("feature:not-a-module" in deps)
         self.assert_("feature:zope.bar" in deps)
 
@@ -82,10 +82,10 @@
         deps = dependencies.load(sio)
         self.assertEqual(len(deps), 5)
         self.assert_("feature:foo" in deps)
-        self.assert_("package:zope.app" in deps)
-        self.assert_("package:zope.schema" in deps)
+        self.assert_("zope.app" in deps)
+        self.assert_("zope.schema" in deps)
         self.assert_("feature:yes-really" in deps)
-        self.assert_("package:zope.yes_again" in deps)
+        self.assert_("zope.yes_again" in deps)
 
 
 def test_suite():


=== Packages/zpkgtools/zpkgtools/tests/test_include.py 1.14 => 1.15 ===
--- Packages/zpkgtools/zpkgtools/tests/test_include.py:1.14	Wed Apr 28 16:01:11 2004
+++ Packages/zpkgtools/zpkgtools/tests/test_include.py	Tue May  4 10:08:43 2004
@@ -33,7 +33,7 @@
         self.source = os.path.dirname(__file__)
         self.destination = tempfile.mkdtemp(prefix="test_include_")
         self.loader = loader.Loader()
-        self.processor = include.InclusionProcessor(self.source, self.loader)
+        self.processor = include.InclusionProcessor(self.loader)
         self.source = os.path.abspath(self.source)
         self.files_written = []
 
@@ -169,7 +169,8 @@
 
     def test_createDistributionTree_creates_destination(self):
         os.rmdir(self.destination)
-        self.processor.createDistributionTree(self.destination)
+        spec = include.Specification(self.source, "<fake>", "test")
+        self.processor.createDistributionTree(self.destination, spec)
         self.assert_(os.path.isdir(self.destination))
         self.assert_(os.path.isfile(join(self.destination, "ignorethis.txt")))
 
@@ -196,7 +197,8 @@
     def test_including_from_cvs_url(self):
         self.start_including_from_cvs_url()
         URL = "cvs://anonymous@cvs.zope.org:pserver/cvs-repository:Zope3"
-        self.processor.addSingleInclude("somedir", URL, self.destination)
+        self.processor.addSingleInclude("somedir", URL, self.destination,
+                                        self.source)
         url, = self.args[0]
         self.assertEqual(url, URL)
         path, dest = self.args[1]
@@ -205,7 +207,8 @@
     def test_including_from_cvs_url_without_base(self):
         self.start_including_from_cvs_url()
         URL = "cvs://anonymous@cvs.zope.org:pserver/cvs-repository:Zope3"
-        self.processor.addSingleInclude("somedir", URL, self.destination)
+        self.processor.addSingleInclude("somedir", URL, self.destination,
+                                        self.source)
         url, = self.args[0]
         self.assertEqual(url, URL)
         path, dest = self.args[1]
@@ -232,7 +235,8 @@
                           self.processor.addSingleInclude,
                           "somedir",
                           "repository:somedir:TAG",
-                          self.destination)
+                          self.destination,
+                          self.source)
 
     def test_including_from_url(self):
         URL = "http://www.example.org/"
@@ -246,7 +250,8 @@
         try:
             self.processor.addSingleInclude("somefile.txt",
                                             URL,
-                                            self.destination)
+                                            self.destination,
+                                            self.source)
         finally:
             urllib2.urlopen = old_urlopen
         self.assert_(self.called)
@@ -263,7 +268,8 @@
         FILENAME = "ignorethis.txt"
         self.processor.addSingleInclude("foo/splat.txt",
                                         FILENAME,
-                                        self.destination)
+                                        self.destination,
+                                        self.source)
         sourcefile = join(self.source, FILENAME)
         resultfile = join(self.destination, "foo", "splat.txt")
         self.assert_(os.path.isfile(resultfile))


=== Packages/zpkgtools/zpkgtools/tests/test_locationmap.py 1.3 => 1.4 ===
--- Packages/zpkgtools/zpkgtools/tests/test_locationmap.py:1.3	Thu Mar 18 17:32:41 2004
+++ Packages/zpkgtools/zpkgtools/tests/test_locationmap.py	Tue May  4 10:08:43 2004
@@ -50,10 +50,10 @@
     """
 
 EXPECTED_OUTPUT = {
-    "package:zope":     PREFIX + "Zope3/src/zope",
-    "package:zope.app": PREFIX + "Zope3/src/zope/app",
-    "package:ZConfig":  PREFIX + "Packages/ZConfig",
-    "package:NotReal":  PREFIX + "module/something/relative:TAG",
+    "zope":             PREFIX + "Zope3/src/zope",
+    "zope.app":         PREFIX + "Zope3/src/zope/app",
+    "ZConfig":          PREFIX + "Packages/ZConfig",
+    "NotReal":          PREFIX + "module/something/relative:TAG",
     "file:README.txt":  "http://www.example.com/README.txt",
     }
 
@@ -68,14 +68,14 @@
         # Make sure that an existing mapping is updated, not ignored,
         # and that existing entries are not overridden.
         sio = StringIO(SAMPLE_INPUT_WITHOUT_REPOSITORY_URLS)
-        d = {"package:other":   "over-there",
-             "package:ZConfig": "http://www.example.org/"}
+        d = {"other":   "over-there",
+             "ZConfig": "http://www.example.org/"}
         mapping = locationmap.load(sio, mapping=d)
-        self.assertEqual(d.pop("package:other"), "over-there")
-        self.assertEqual(d["package:ZConfig"], "http://www.example.org/")
+        self.assertEqual(d.pop("other"), "over-there")
+        self.assertEqual(d["ZConfig"], "http://www.example.org/")
         # Slam in the expected result, now that we've checked the
         # precedence of the existing entry:
-        d["package:ZConfig"] = EXPECTED_OUTPUT["package:ZConfig"]
+        d["ZConfig"] = EXPECTED_OUTPUT["ZConfig"]
         self.check_sample_results(d)
 
     def test_load_with_cvs_base(self):
@@ -166,150 +166,16 @@
         self.assertEqual(mapping, EXPECTED_OUTPUT)
 
     def test_fromPathOrUrl_passes_mapping(self):
-        d = {"package:other": "over-there"}
+        d = {"other": "over-there"}
         mapping = locationmap.fromPathOrUrl(self.packages_txt, mapping=d)
-        self.assertEqual(d.pop("package:other"), "over-there")
+        self.assertEqual(d.pop("other"), "over-there")
         self.assertEqual(d, EXPECTED_OUTPUT)
 
 
-class LocationMapTestCase(unittest.TestCase):
-    """Tests of the convenience mapping used as the CVS mapping storage.
-
-    This doesn't try to test everything about the mapping interface,
-    since the class inherits from UserDict; only the aspects that are
-    specific to the LocationMap.
-
-    """
-
-    def test_basic_operations(self):
-        m = locationmap.LocationMap()
-        self.assertEqual(len(m), 0)
-        m["package:foo"] = "value"
-        self.assert_("package:foo" in m)
-        self.assert_("foo" in m)
-        self.assert_(m.has_key("package:foo"))
-        self.assert_(m.has_key("foo"))
-        self.assertEqual(m["package:foo"], "value")
-        self.assertEqual(m["foo"], "value")
-        self.assertEqual(len(m), 1)
-        m["bar"] = "value"
-        self.assert_("package:bar" in m)
-        self.assert_("bar" in m)
-        self.assert_(m.has_key("package:bar"))
-        self.assert_(m.has_key("bar"))
-        self.assertEqual(m["package:bar"], "value")
-        self.assertEqual(m["bar"], "value")
-        self.assertEqual(len(m), 2)
-        keys = m.keys()
-        keys.sort()
-        self.assertEqual(keys, ["package:bar", "package:foo"])
-
-    def test_deletions(self):
-        m = locationmap.LocationMap()
-        m["foo"] = "value"
-        m["bar"] = "value"
-        del m["package:bar"]
-        self.failIf("bar" in m)
-        self.failIf("package:bar" in m)
-        del m["foo"]
-        self.failIf("foo" in m)
-        self.failIf("package:foo" in m)
-        self.assertEqual(len(m), 0)
-
-    def test_pop(self):
-        m = locationmap.LocationMap()
-        m["foo"] = "value-foo"
-        m["bar"] = "value-bar"
-        self.assertEqual(m.pop("foo"), "value-foo")
-        self.failIf("foo" in m)
-        self.failIf("package:foo" in m)
-        self.assertEqual(m.pop("package:bar"), "value-bar")
-        self.failIf("bar" in m)
-        self.failIf("package:bar" in m)
-        self.assertEqual(m.pop("bar", 42), 42)
-        self.assertEqual(m.pop("package:bar", 42), 42)
-        self.failIf("bar" in m)
-        self.failIf("package:bar" in m)
-        self.assertRaises(KeyError, m.pop, "foo")
-        self.assertRaises(KeyError, m.pop, "package:foo")
-
-    def test_update(self):
-        m = locationmap.LocationMap()
-        m.update({"foo": "value-foo", "package:bar": "value-bar"})
-        self.assertEqual(m["package:bar"], "value-bar")
-        self.assertEqual(m["package:foo"], "value-foo")
-        self.assertEqual(m["bar"], "value-bar")
-        self.assertEqual(m["foo"], "value-foo")
-        m.update(bat="value-bat")
-        self.assertEqual(m["package:bat"], "value-bat")
-        self.assertEqual(m["bat"], "value-bat")
-        self.assertEqual(len(m), 3)
-
-    def test_constructor_dict_kwargs(self):
-        # construct using both a dict and keywords
-        m = locationmap.LocationMap({"foo": 1, "package:bar": 2}, bat=3)
-        self.check_constructor_results(m)
-
-    def test_constructor_dict(self):
-        # construct using only a dict
-        m = locationmap.LocationMap({"foo": 1,
-                                     "package:bar": 2,
-                                     "bat": 3})
-        self.check_constructor_results(m)
-
-    def test_constructor_kwargs(self):
-        # construct using only keywords
-        m = locationmap.LocationMap(foo=1, bar=2, bat=3)
-        self.check_constructor_results(m)
-
-    def check_constructor_results(self, m):
-        self.assertEqual(len(m), 3)
-
-        self.assert_("package:foo" in m)
-        self.assert_("foo" in m)
-        self.assert_(m.has_key("package:foo"))
-        self.assert_(m.has_key("foo"))
-        self.assertEqual(m["package:foo"], 1)
-        self.assertEqual(m["foo"], 1)
-
-        self.assert_("package:bar" in m)
-        self.assert_("bar" in m)
-        self.assert_(m.has_key("package:bar"))
-        self.assert_(m.has_key("bar"))
-        self.assertEqual(m["package:bar"], 2)
-        self.assertEqual(m["bar"], 2)
-
-        self.assert_("package:bat" in m)
-        self.assert_("bat" in m)
-        self.assert_(m.has_key("package:bat"))
-        self.assert_(m.has_key("bat"))
-        self.assertEqual(m["package:bat"], 3)
-        self.assertEqual(m["bat"], 3)
-
-
-def test_normalizeResourceId():
-    """The normalizeResourceId() function ensures the default resource
-    type is handled consistently.
-
-    >>> locationmap.normalizeResourceId('package:foo')
-    'package:foo'
-    >>> locationmap.normalizeResourceId('foo')
-    'package:foo'
-    >>> locationmap.normalizeResourceId('collection:foo')
-    'collection:foo'
-
-    There's a weird case when the type prefix is empty:
-
-    >>> locationmap.normalizeResourceId(':foo')
-    ':foo'
-    """
-
 
 def test_suite():
     suite = unittest.makeSuite(LoadTestCase)
     suite.addTest(unittest.makeSuite(CvsWorkingDirectoryTestCase))
-    suite.addTest(unittest.makeSuite(LocationMapTestCase))
-    suite.addTest(doctest.DocTestSuite())
     return suite
 
 if __name__ == "__main__":




More information about the Zope-CVS mailing list