def show(self, request, image): """Return a dictionary with image details.""" image_dict = { "id": image.get("id"), "name": image.get("name"), "minRam": int(image.get("min_ram") or 0), "minDisk": int(image.get("min_disk") or 0), "metadata": image.get("properties", {}), "created": self._format_date(image.get("created_at")), "updated": self._format_date(image.get("updated_at")), "status": self._get_status(image), "progress": self._get_progress(image), "links": self._get_links(request, image["id"]), } server_ref = image.get("properties", {}).get("instance_ref") if server_ref is not None: image_dict["server"] = { "id": common.get_id_from_href(server_ref), "links": [{ "rel": "self", "href": server_ref, }, { "rel": "bookmark", "href": common.remove_version_from_href(server_ref), }], } return dict(image=image_dict)
def test_remove_version_from_href_4(self): fixture = 'http://www.testsite.com/v1.1/images/v10.5' expected = 'http://www.testsite.com/images/v10.5' actual = common.remove_version_from_href(fixture) self.assertEqual(actual, expected)
def test_remove_version_from_href_4(self): fixture = "http://www.testsite.com/v1.1/images/v10.5" expected = "http://www.testsite.com/images/v10.5" actual = common.remove_version_from_href(fixture) self.assertEqual(actual, expected)