]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove unused get_{id,version}_from_href()
authorMark McLoughlin <markmc@redhat.com>
Tue, 17 Jul 2012 03:10:18 +0000 (04:10 +0100)
committerMark McLoughlin <markmc@redhat.com>
Tue, 17 Jul 2012 03:10:18 +0000 (04:10 +0100)
The former is only used in the compute API in Nova to e.g. get
an image or flavor ID from a client supplied ref.

The latter is unused even in Nova since the removal of the 1.0
API.

Change-Id: I4e00ca816820cb51c0ab3d4d864766d981854939

cinder/api/openstack/common.py
cinder/tests/api/openstack/test_common.py

index c3e09133e714813c47e03a80b5e3f154c0329f5c..0ebe610e0600e63424e760a97deff06e7f2cbde2 100644 (file)
@@ -138,19 +138,6 @@ def limited_by_marker(items, request, max_limit=FLAGS.osapi_max_limit):
     return items[start_index:range_end]
 
 
-def get_id_from_href(href):
-    """Return the id or uuid portion of a url.
-
-    Given: 'http://www.foo.com/bar/123?q=4'
-    Returns: '123'
-
-    Given: 'http://www.foo.com/bar/abc123?q=4'
-    Returns: 'abc123'
-
-    """
-    return urlparse.urlsplit("%s" % href).path.split('/')[-1]
-
-
 def remove_version_from_href(href):
     """Removes the first api version from the href.
 
@@ -181,26 +168,6 @@ def remove_version_from_href(href):
     return urlparse.urlunsplit(parsed_url)
 
 
-def get_version_from_href(href):
-    """Returns the api version in the href.
-
-    Returns the api version in the href.
-    If no version is found, '2' is returned
-
-    Given: 'http://www.cinder.com/123'
-    Returns: '2'
-
-    Given: 'http://www.cinder.com/v1.1'
-    Returns: '1.1'
-
-    """
-    try:
-        expression = r'/v([0-9]+|[0-9]+\.[0-9]+)(/|$)'
-        return re.findall(expression, href)[0][0]
-    except IndexError:
-        return '2'
-
-
 def dict_to_query_str(params):
     # TODO(throughnothing): we should just use urllib.urlencode instead of this
     # But currently we don't work with urlencoded url's
index a004ff5689f33184ca0339b60437d8b2e46b812b..ff153baeac2a84f19521f8435e73872e216eb172 100644 (file)
@@ -245,57 +245,3 @@ class MiscFunctionsTest(test.TestCase):
         self.assertRaises(ValueError,
                           common.remove_version_from_href,
                           fixture)
-
-    def test_get_id_from_href_with_int_url(self):
-        fixture = 'http://www.testsite.com/dir/45'
-        actual = common.get_id_from_href(fixture)
-        expected = '45'
-        self.assertEqual(actual, expected)
-
-    def test_get_id_from_href_with_int(self):
-        fixture = '45'
-        actual = common.get_id_from_href(fixture)
-        expected = '45'
-        self.assertEqual(actual, expected)
-
-    def test_get_id_from_href_with_int_url_query(self):
-        fixture = 'http://www.testsite.com/dir/45?asdf=jkl'
-        actual = common.get_id_from_href(fixture)
-        expected = '45'
-        self.assertEqual(actual, expected)
-
-    def test_get_id_from_href_with_uuid_url(self):
-        fixture = 'http://www.testsite.com/dir/abc123'
-        actual = common.get_id_from_href(fixture)
-        expected = "abc123"
-        self.assertEqual(actual, expected)
-
-    def test_get_id_from_href_with_uuid_url_query(self):
-        fixture = 'http://www.testsite.com/dir/abc123?asdf=jkl'
-        actual = common.get_id_from_href(fixture)
-        expected = "abc123"
-        self.assertEqual(actual, expected)
-
-    def test_get_id_from_href_with_uuid(self):
-        fixture = 'abc123'
-        actual = common.get_id_from_href(fixture)
-        expected = 'abc123'
-        self.assertEqual(actual, expected)
-
-    def test_get_version_from_href(self):
-        fixture = 'http://www.testsite.com/v1.1/images'
-        expected = '1.1'
-        actual = common.get_version_from_href(fixture)
-        self.assertEqual(actual, expected)
-
-    def test_get_version_from_href_2(self):
-        fixture = 'http://www.testsite.com/v1.1'
-        expected = '1.1'
-        actual = common.get_version_from_href(fixture)
-        self.assertEqual(actual, expected)
-
-    def test_get_version_from_href_default(self):
-        fixture = 'http://www.testsite.com/images'
-        expected = '2'
-        actual = common.get_version_from_href(fixture)
-        self.assertEqual(actual, expected)