18452 get_highest_ranked_publisher can return string instead of publisher object
authorShawn Walker <shawn.walker@oracle.com>
Tue, 26 Jul 2011 17:36:18 -0700
changeset 2474 e815a9785747
parent 2473 69bbce069101
child 2475 77cfb483dd88
18452 get_highest_ranked_publisher can return string instead of publisher object
src/modules/client/image.py
src/tests/api/t_api.py
--- a/src/modules/client/image.py	Tue Jul 26 15:01:08 2011 -0700
+++ b/src/modules/client/image.py	Tue Jul 26 17:36:18 2011 -0700
@@ -1728,7 +1728,7 @@
                 for p in self.gen_publishers():
                         return p
                 for p in self.get_installed_pubs():
-                        return p
+                        return publisher.Publisher(p)
                 return None
 
         def check_cert_validity(self, pubs=EmptyI):
@@ -2741,22 +2741,6 @@
                         return fmris[0]
                 return None
 
-        def has_version_installed(self, fmri):
-                """Check that the version given in the FMRI or a successor is
-                installed in the current image."""
-
-                v = self.get_version_installed(fmri)
-
-                if v and not fmri.publisher:
-                        fmri.set_publisher(v.get_publisher_str())
-                elif not fmri.publisher:
-                        fmri.set_publisher(self.get_highest_ranked_publisher(),
-                            True)
-
-                if v and v.is_successor(fmri):
-                        return True
-                return False
-
         def get_pkg_repo(self, pfmri):
                 """Returns the repository object containing the origins that
                 should be used to retrieve the specified package or None if
--- a/src/tests/api/t_api.py	Tue Jul 26 15:01:08 2011 -0700
+++ b/src/tests/api/t_api.py	Tue Jul 26 17:36:18 2011 -0700
@@ -524,7 +524,7 @@
                 self.assertTrue(api_obj.has_publisher("bobcat"))
 
                 # Verify preferred publisher prefix is returned correctly.
-                self.assertEqual(api_obj.get_highest_ranked_publisher(),
+                self.assertEqual(api_obj.get_highest_ranked_publisher().prefix,
                     "bobcat")
 
                 # Verify that get_publisher returned the correct publisher
@@ -756,6 +756,14 @@
                 self.assertRaises(api_errors.InvalidP5IFile, api_obj.parse_p5i,
                     location=lcpath)
 
+                # Now install a package and remove all publishers and verify a
+                # publisher obj is returned by get_highest_ranked_publisher().
+                self._api_install(api_obj, ["foo"])
+                api_obj.remove_publisher("bobcat")
+                api_obj.remove_publisher("p5icat")
+                self.assert_(api_obj.get_highest_ranked_publisher().prefix,
+                    "bobcat")
+
         def test_deprecated(self):
                 """Test deprecated api interfaces."""