Add unit test of api about trying to get a not exist flavor.

Change-Id: I02a5c27fd68ad762d35aba40dda9176fae680ef8
Closes-Bug: 1808914
This commit is contained in:
zxgao 2018-12-18 14:12:40 +08:00
parent c801a3f8ea
commit feda8431b1
1 changed files with 9 additions and 0 deletions

View File

@ -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'])