From d775836347191d80497add9d2c84c0077eb8076b Mon Sep 17 00:00:00 2001 From: Giampaolo Lauria Date: Mon, 3 Dec 2012 13:59:53 -0500 Subject: Adds API Sample tests for Quotas extension. Partially implements blueprint nova-api-samples Fixes bug 1070172 Change-Id: I796897e69ec75da6da047574c0b8131f94bfa17e --- .../quotas-show-defaults-get-resp.json | 16 ++++++++++++ .../quotas-show-defaults-get-resp.xml | 14 +++++++++++ .../os-quota-sets/quotas-show-get-resp.json | 16 ++++++++++++ .../os-quota-sets/quotas-show-get-resp.xml | 14 +++++++++++ .../os-quota-sets/quotas-update-post-req.json | 5 ++++ .../os-quota-sets/quotas-update-post-req.xml | 4 +++ .../os-quota-sets/quotas-update-post-resp.json | 15 +++++++++++ .../os-quota-sets/quotas-update-post-resp.xml | 14 +++++++++++ .../quotas-show-defaults-get-resp.json.tpl | 16 ++++++++++++ .../quotas-show-defaults-get-resp.xml.tpl | 14 +++++++++++ .../os-quota-sets/quotas-show-get-resp.json.tpl | 16 ++++++++++++ .../os-quota-sets/quotas-show-get-resp.xml.tpl | 14 +++++++++++ .../os-quota-sets/quotas-update-post-req.json.tpl | 5 ++++ .../os-quota-sets/quotas-update-post-req.xml.tpl | 4 +++ .../os-quota-sets/quotas-update-post-resp.json.tpl | 15 +++++++++++ .../os-quota-sets/quotas-update-post-resp.xml.tpl | 14 +++++++++++ nova/tests/integrated/test_api_samples.py | 29 ++++++++++++++++++++++ 17 files changed, 225 insertions(+) create mode 100644 doc/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json create mode 100644 doc/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml create mode 100644 doc/api_samples/os-quota-sets/quotas-show-get-resp.json create mode 100644 doc/api_samples/os-quota-sets/quotas-show-get-resp.xml create mode 100644 doc/api_samples/os-quota-sets/quotas-update-post-req.json create mode 100644 doc/api_samples/os-quota-sets/quotas-update-post-req.xml create mode 100644 doc/api_samples/os-quota-sets/quotas-update-post-resp.json create mode 100644 doc/api_samples/os-quota-sets/quotas-update-post-resp.xml create mode 100644 nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.xml.tpl diff --git a/doc/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json b/doc/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json new file mode 100644 index 000000000..70d4b66eb --- /dev/null +++ b/doc/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json @@ -0,0 +1,16 @@ +{ + "quota_set": { + "cores": 20, + "floating_ips": 10, + "id": "fake_tenant", + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "injected_files": 5, + "instances": 10, + "key_pairs": 100, + "metadata_items": 128, + "ram": 51200, + "security_group_rules": 20, + "security_groups": 10 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml b/doc/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml new file mode 100644 index 000000000..7dfdddeb2 --- /dev/null +++ b/doc/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml @@ -0,0 +1,14 @@ + + + 20 + 10 + 10240 + 255 + 5 + 10 + 100 + 128 + 51200 + 20 + 10 + \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets/quotas-show-get-resp.json b/doc/api_samples/os-quota-sets/quotas-show-get-resp.json new file mode 100644 index 000000000..70d4b66eb --- /dev/null +++ b/doc/api_samples/os-quota-sets/quotas-show-get-resp.json @@ -0,0 +1,16 @@ +{ + "quota_set": { + "cores": 20, + "floating_ips": 10, + "id": "fake_tenant", + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "injected_files": 5, + "instances": 10, + "key_pairs": 100, + "metadata_items": 128, + "ram": 51200, + "security_group_rules": 20, + "security_groups": 10 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets/quotas-show-get-resp.xml b/doc/api_samples/os-quota-sets/quotas-show-get-resp.xml new file mode 100644 index 000000000..7dfdddeb2 --- /dev/null +++ b/doc/api_samples/os-quota-sets/quotas-show-get-resp.xml @@ -0,0 +1,14 @@ + + + 20 + 10 + 10240 + 255 + 5 + 10 + 100 + 128 + 51200 + 20 + 10 + \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets/quotas-update-post-req.json b/doc/api_samples/os-quota-sets/quotas-update-post-req.json new file mode 100644 index 000000000..1f12caa04 --- /dev/null +++ b/doc/api_samples/os-quota-sets/quotas-update-post-req.json @@ -0,0 +1,5 @@ +{ + "quota_set": { + "security_groups": 45 + } +} diff --git a/doc/api_samples/os-quota-sets/quotas-update-post-req.xml b/doc/api_samples/os-quota-sets/quotas-update-post-req.xml new file mode 100644 index 000000000..4bb7b3a47 --- /dev/null +++ b/doc/api_samples/os-quota-sets/quotas-update-post-req.xml @@ -0,0 +1,4 @@ + + + 45 + \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets/quotas-update-post-resp.json b/doc/api_samples/os-quota-sets/quotas-update-post-resp.json new file mode 100644 index 000000000..6581c6354 --- /dev/null +++ b/doc/api_samples/os-quota-sets/quotas-update-post-resp.json @@ -0,0 +1,15 @@ +{ + "quota_set": { + "cores": 20, + "floating_ips": 10, + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "injected_files": 5, + "instances": 10, + "key_pairs": 100, + "metadata_items": 128, + "ram": 51200, + "security_group_rules": 20, + "security_groups": 45 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets/quotas-update-post-resp.xml b/doc/api_samples/os-quota-sets/quotas-update-post-resp.xml new file mode 100644 index 000000000..aef4761f8 --- /dev/null +++ b/doc/api_samples/os-quota-sets/quotas-update-post-resp.xml @@ -0,0 +1,14 @@ + + + 20 + 10 + 10240 + 255 + 5 + 10 + 100 + 128 + 51200 + 20 + 45 + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json.tpl new file mode 100644 index 000000000..70d4b66eb --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.json.tpl @@ -0,0 +1,16 @@ +{ + "quota_set": { + "cores": 20, + "floating_ips": 10, + "id": "fake_tenant", + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "injected_files": 5, + "instances": 10, + "key_pairs": 100, + "metadata_items": 128, + "ram": 51200, + "security_group_rules": 20, + "security_groups": 10 + } +} \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml.tpl new file mode 100644 index 000000000..7dfdddeb2 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-defaults-get-resp.xml.tpl @@ -0,0 +1,14 @@ + + + 20 + 10 + 10240 + 255 + 5 + 10 + 100 + 128 + 51200 + 20 + 10 + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.json.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.json.tpl new file mode 100644 index 000000000..70d4b66eb --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.json.tpl @@ -0,0 +1,16 @@ +{ + "quota_set": { + "cores": 20, + "floating_ips": 10, + "id": "fake_tenant", + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "injected_files": 5, + "instances": 10, + "key_pairs": 100, + "metadata_items": 128, + "ram": 51200, + "security_group_rules": 20, + "security_groups": 10 + } +} \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.xml.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.xml.tpl new file mode 100644 index 000000000..7dfdddeb2 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-show-get-resp.xml.tpl @@ -0,0 +1,14 @@ + + + 20 + 10 + 10240 + 255 + 5 + 10 + 100 + 128 + 51200 + 20 + 10 + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-req.json.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-req.json.tpl new file mode 100644 index 000000000..1f12caa04 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-req.json.tpl @@ -0,0 +1,5 @@ +{ + "quota_set": { + "security_groups": 45 + } +} diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-req.xml.tpl new file mode 100644 index 000000000..596ce56ac --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-req.xml.tpl @@ -0,0 +1,4 @@ + + + 45 + diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.json.tpl new file mode 100644 index 000000000..6581c6354 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.json.tpl @@ -0,0 +1,15 @@ +{ + "quota_set": { + "cores": 20, + "floating_ips": 10, + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "injected_files": 5, + "instances": 10, + "key_pairs": 100, + "metadata_items": 128, + "ram": 51200, + "security_group_rules": 20, + "security_groups": 45 + } +} \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.xml.tpl new file mode 100644 index 000000000..aef4761f8 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-sets/quotas-update-post-resp.xml.tpl @@ -0,0 +1,14 @@ + + + 20 + 10 + 10240 + 255 + 5 + 10 + 100 + 128 + 51200 + 20 + 45 + \ No newline at end of file diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 286e66c49..4936ff2cb 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -1693,3 +1693,32 @@ class DeferredDeleteSampleJsonTests(ServersSampleBase): class DeferredDeleteSampleXmlTests(DeferredDeleteSampleJsonTests): ctype = 'xml' + + +class QuotasSampleJsonTests(ApiSampleTestBase): + extension_name = "nova.api.openstack.compute.contrib.quotas.Quotas" + + def test_show_quotas(self): + """Get api sample to show quotas""" + response = self._do_get('os-quota-sets/fake_tenant') + self.assertEqual(response.status, 200) + return self._verify_response('quotas-show-get-resp', {}, response) + + def test_show_quotas_defaults(self): + """Get api sample to show quotas defaults""" + response = self._do_get('os-quota-sets/fake_tenant/defaults') + self.assertEqual(response.status, 200) + return self._verify_response('quotas-show-defaults-get-resp', + {}, response) + + def test_update_quotas(self): + """Get api sample to update quotas""" + response = self._do_put('os-quota-sets/fake_tenant', + 'quotas-update-post-req', + {}) + self.assertEqual(response.status, 200) + return self._verify_response('quotas-update-post-resp', {}, response) + + +class QuotasSampleXmlTests(QuotasSampleJsonTests): + ctype = "xml" -- cgit