From feda8431b1eb78acd0716222aa0b2c671378c161 Mon Sep 17 00:00:00 2001 From: zxgao Date: Tue, 18 Dec 2018 14:12:40 +0800 Subject: [PATCH] Add unit test of api about trying to get a not exist flavor. Change-Id: I02a5c27fd68ad762d35aba40dda9176fae680ef8 Closes-Bug: 1808914 --- mogan/tests/unit/api/v1/test_flavor.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mogan/tests/unit/api/v1/test_flavor.py b/mogan/tests/unit/api/v1/test_flavor.py index f453e1c6..3ce52690 100644 --- a/mogan/tests/unit/api/v1/test_flavor.py +++ b/mogan/tests/unit/api/v1/test_flavor.py @@ -12,6 +12,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +from six.moves import http_client from mogan.tests.functional.api import v1 as v1_test from mogan.tests.unit.db import utils @@ -46,3 +47,11 @@ class TestFlavorAuthorization(v1_test.APITestV1): self.assertIn('description', resp) self.assertIn('links', resp) self.assertIn('resources', resp) + + def test_flavor_get_one_that_does_not_exist(self): + headers = self.gen_headers(self.context, roles="admin") + invalid_id = '00000000-0000-0000-0000-000000000000' + resp = self.get_json('/flavors/%s' % invalid_id, expect_errors=True, + headers=headers) + self.assertEqual(http_client.NOT_FOUND, resp.status_int) + self.assertTrue(resp.json['error_message'])