[zpkg] SVN: zpkgtools/trunk/zpkgtools/ - add a test that the release-name option is honored (-n/--name)

Fred L. Drake, Jr. fdrake at gmail.com
Mon Sep 19 12:06:07 EDT 2005


Log message for revision 38521:
  - add a test that the release-name option is honored (-n/--name)
  - allow the release name to be set in the config file
  

Changed:
  U   zpkgtools/trunk/zpkgtools/app.py
  U   zpkgtools/trunk/zpkgtools/config.py
  U   zpkgtools/trunk/zpkgtools/config.xml
  U   zpkgtools/trunk/zpkgtools/tests/test_app.py
  U   zpkgtools/trunk/zpkgtools/tests/test_config.py

-=-
Modified: zpkgtools/trunk/zpkgtools/app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/app.py	2005-09-19 15:31:33 UTC (rev 38520)
+++ zpkgtools/trunk/zpkgtools/app.py	2005-09-19 16:06:06 UTC (rev 38521)
@@ -97,6 +97,8 @@
             if not cf.default_collection:
                 self.error("no resource to package specified")
             options.resource = cf.default_collection
+        if not options.release_name:
+            options.release_name = cf.release_name
 
     def error(self, message, rc=1):
         self.logger.critical(message)
@@ -110,8 +112,6 @@
         self.manifests = []
         self.ip = None
         self.resource = options.resource
-        if not options.release_name:
-            options.release_name = self.resource
         # Create a new directory for all temporary files to go in:
         self.tmpdir = tempfile.mkdtemp(prefix=options.program + "-")
         self.old_tmpdir = tempfile.tempdir
@@ -126,7 +126,7 @@
             self.error("unknown resource: %s" % self.resource)
         self.resource_url = self.locations[self.resource]
         #
-        release_name = self.options.release_name
+        release_name = options.release_name or self.resource
         self.target_name = "%s-%s" % (release_name, self.options.version)
         self.target_file = self.target_name + ".tgz"
         if self.options.tree_only:

Modified: zpkgtools/trunk/zpkgtools/config.py
===================================================================
--- zpkgtools/trunk/zpkgtools/config.py	2005-09-19 15:31:33 UTC (rev 38520)
+++ zpkgtools/trunk/zpkgtools/config.py	2005-09-19 16:06:06 UTC (rev 38521)
@@ -46,7 +46,13 @@
         raise ValueError("exclusions do not support wildcards")
     return value
 
+def release_name(value):
+    try:
+        return resource_name(value)
+    except ValueError:
+        raise ValueError("resource-name does not support wildcards")
 
+
 def resource_map(value):
     return value.map
 
@@ -78,6 +84,7 @@
         self.exclude_packages = []
         self.include_support_code = True
         self.default_collection = None
+        self.release_name = None
 
     def finalize(self):
         """Load the location maps into `locations`."""
@@ -134,6 +141,7 @@
         self.collect_dependencies = cf.collect_dependencies
         self.default_collection = cf.default_collection
         self.include_support_code = cf.include_support_code
+        self.release_name = cf.release_name
         self.resource_maps = cf.resource_maps
         self.exclude_packages = cf.exclude_packages
         for value in cf.location_maps:

Modified: zpkgtools/trunk/zpkgtools/config.xml
===================================================================
--- zpkgtools/trunk/zpkgtools/config.xml	2005-09-19 15:31:33 UTC (rev 38520)
+++ zpkgtools/trunk/zpkgtools/config.xml	2005-09-19 16:06:06 UTC (rev 38521)
@@ -74,4 +74,9 @@
        default="yes"
        />
 
+  <key name="release-name"
+       datatype=".config.release_name"
+       required="no"
+       />
+
 </schema>

Modified: zpkgtools/trunk/zpkgtools/tests/test_app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_app.py	2005-09-19 15:31:33 UTC (rev 38520)
+++ zpkgtools/trunk/zpkgtools/tests/test_app.py	2005-09-19 16:06:06 UTC (rev 38521)
@@ -456,8 +456,18 @@
         app = self.createApplication(
             ["-f", "-t", "-m", package_map, "package"])
         app.run()
-        self.check_package_tree("package")
+        self.check_package_tree("package", "package")
 
+    def test_building_distribution_tree_alternate_name(self):
+        # This builds a package and checks that the tree_only flag
+        # causes the application to build a tree in the current
+        # directory instead of a tarball.
+        package_map = self.createPackageMap()
+        app = self.createApplication(
+            ["-f", "-t", "-m", package_map, "-n", "other", "package"])
+        app.run()
+        self.check_package_tree("other", "package")
+
     def test_building_default_collection(self):
         # Test that a configuration's setting of a default collection
         # is used to actually determine what's built.
@@ -467,7 +477,7 @@
         app = self.createApplication(
             ["-C", config, "-t", "-m", package_map])
         app.run()
-        self.check_package_tree("package")
+        self.check_package_tree("package", "package")
 
     def test_building_default_collection_override(self):
         # Test that a configuration's setting of a default collection
@@ -478,16 +488,16 @@
         app = self.createApplication(
             ["-C", config, "-t", "-m", package_map, "collection-1"])
         app.run()
-        self.check_package_tree("collection-1")
+        self.check_package_tree("collection-1", "collection-1")
 
-    def check_package_tree(self, name, version="0.0.0"):
+    def check_package_tree(self, name, resource, version="0.0.0"):
         # Make sure the local tree is present and looks like one of
         # our distributions; this relies on the tree being built
         # unpacked (the -t option).
         pd = "%s-%s" % (name, version)
         self.assert_(os.path.isdir(pd))
         try:
-            self.assert_(os.path.isdir(os.path.join(pd, name)))
+            self.assert_(os.path.isdir(os.path.join(pd, resource)))
             self.assert_(os.path.isdir(os.path.join(pd, "Support")))
             self.assert_(isfile(pd, "setup.py"))
             self.assert_(isfile(pd, "setup.cfg"))

Modified: zpkgtools/trunk/zpkgtools/tests/test_config.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_config.py	2005-09-19 15:31:33 UTC (rev 38520)
+++ zpkgtools/trunk/zpkgtools/tests/test_config.py	2005-09-19 16:06:06 UTC (rev 38521)
@@ -87,10 +87,19 @@
         self.assertRaises(cfgparser.ConfigurationError,
                           self.load_text, "default-collection foo.*\n")
 
+        # release-name too many times
+        self.assertRaises(cfgparser.ConfigurationError,
+                          self.load_text, ("release-name foo\n"
+                                           "release-name foo\n"))
+
     def test_default_collection(self):
         cf = self.load_text("default-collection foo\n")
         self.assertEqual(cf.default_collection, "foo")
 
+    def test_release_name(self):
+        cf = self.load_text("release-name foo\n")
+        self.assertEqual(cf.release_name, "foo")
+
     def test_loadPath_no_such_file(self):
         path = os.path.join(here, "no-such-file")
         cf = config.Configuration()



More information about the zpkg mailing list