def _flavor_id_from_req_data(self, data): try: flavor_ref = data['server']['flavorRef'] except (TypeError, KeyError): msg = _("Missing flavorRef attribute") raise exc.HTTPBadRequest(explanation=msg) try: return common.get_id_from_href(flavor_ref) except ValueError: msg = _("Invalid flavorRef provided.") raise exc.HTTPBadRequest(explanation=msg)
def _flavor_id_from_req_data(self, data): try: flavor_ref = data['server']['flavorRef'] except (TypeError, KeyError): msg = _("Missing flavorRef attribute") raise exc.HTTPBadRequest(explanation=msg) try: return common.get_id_from_href(flavor_ref) except ValueError: msg = _("Invalid flavorRef provided.") raise exc.HTTPBadRequest(explanation=msg)
def _get_image(self, request, instance): image_ref = instance["image_ref"] if image_ref: image_id = str(common.get_id_from_href(image_ref)) bookmark = self._image_builder._get_bookmark_link( request, image_id, "images") return { "id": image_id, "links": [{ "rel": "bookmark", "href": bookmark, }], } else: return ""
def _get_image(self, request, instance): image_ref = instance["image_ref"] if image_ref: image_id = str(common.get_id_from_href(image_ref)) bookmark = self._image_builder._get_bookmark_link(request, image_id, "images") return { "id": image_id, "links": [{ "rel": "bookmark", "href": bookmark, }], } else: return ""
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_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_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_int(self): fixture = '45' actual = common.get_id_from_href(fixture) expected = '45' 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_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_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_int(self): fixture = '45' actual = common.get_id_from_href(fixture) expected = '45' self.assertEqual(actual, expected)
def _flavor_id_from_req_data(self, data): flavor_ref = data['server']['flavorRef'] return common.get_id_from_href(flavor_ref)
def _flavor_id_from_req_data(self, data): flavor_ref = data['server']['flavorRef'] return common.get_id_from_href(flavor_ref)