Add integration tests for regions
Use betamax to record interactions between cratonclient and a craton server for the /v1/regions API. Implements: bp testing-plan Change-Id: I7f558a4516afdc3db27101639620534f4746b2af
This commit is contained in:
parent
2e34424cda
commit
4ae3199014
163
cratonclient/tests/cassettes/TestRegions-test_create.yaml
Normal file
163
cratonclient/tests/cassettes/TestRegions-test_create.yaml
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
http_interactions:
|
||||||
|
- recorded_at: '2017-03-21T15:52:13'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: "{\n \"name\": \"cloud-TestRegions-test_create\"\n}"
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '41'
|
||||||
|
Content-Type: application/json
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: POST
|
||||||
|
uri: <craton-url>/clouds
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: "{\n \"variables\": {},\n \"created_at\": \"2017-03-21T00:42:39.791662\"\
|
||||||
|
,\n \"note\": null,\n \"updated_at\": null,\n \"project_id\": \"<craton-demo-project>\"\
|
||||||
|
,\n \"name\": \"cloud-TestRegions-test_create\",\n \"id\": 147\n}"
|
||||||
|
headers:
|
||||||
|
Content-Length: '218'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:39 GMT
|
||||||
|
Location: <craton-url>/clouds/147
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-6f0519d5-bcb7-4925-b263-78d6b7b8b1b4
|
||||||
|
status:
|
||||||
|
code: 201
|
||||||
|
message: CREATED
|
||||||
|
url: <craton-url>/clouds
|
||||||
|
- recorded_at: '2017-03-21T15:52:13'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: "{\n \"cloud_id\": 147,\n \"name\": \"region-creation\"\n}"
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '44'
|
||||||
|
Content-Type: application/json
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: POST
|
||||||
|
uri: <craton-url>/regions
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: "{\n \"variables\": {},\n \"cloud_id\": 147,\n \"created_at\": \"\
|
||||||
|
2017-03-21T00:42:39.839331\",\n \"note\": null,\n \"project_id\": \"<craton-demo-project>\"\
|
||||||
|
,\n \"id\": 15,\n \"name\": \"region-creation\",\n \"updated_at\": null\n\
|
||||||
|
}"
|
||||||
|
headers:
|
||||||
|
Content-Length: '222'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:39 GMT
|
||||||
|
Location: <craton-url>/regions/15
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-a337c517-cdf8-48a8-97fd-0313443c525d
|
||||||
|
status:
|
||||||
|
code: 201
|
||||||
|
message: CREATED
|
||||||
|
url: <craton-url>/regions
|
||||||
|
- recorded_at: '2017-03-21T15:52:13'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: GET
|
||||||
|
uri: <craton-url>/regions/15
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: "{\n \"variables\": {},\n \"cloud_id\": 147,\n \"created_at\": \"\
|
||||||
|
2017-03-21T00:42:39.000000\",\n \"note\": null,\n \"project_id\": \"<craton-demo-project>\"\
|
||||||
|
,\n \"id\": 15,\n \"name\": \"region-creation\",\n \"updated_at\": null\n\
|
||||||
|
}"
|
||||||
|
headers:
|
||||||
|
Content-Length: '222'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:39 GMT
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-e5ac546a-10e3-4a4f-8dd6-89026ef5266f
|
||||||
|
status:
|
||||||
|
code: 200
|
||||||
|
message: OK
|
||||||
|
url: <craton-url>/regions/15
|
||||||
|
- recorded_at: '2017-03-21T15:52:13'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '0'
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: DELETE
|
||||||
|
uri: <craton-url>/regions/15
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Content-Length: '0'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:39 GMT
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-45859feb-f346-4561-a3e4-bcb54d2bb23d
|
||||||
|
status:
|
||||||
|
code: 204
|
||||||
|
message: NO CONTENT
|
||||||
|
url: <craton-url>/regions/15
|
||||||
|
- recorded_at: '2017-03-21T15:52:13'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '0'
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: DELETE
|
||||||
|
uri: <craton-url>/clouds/147
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Content-Length: '0'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:39 GMT
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-00deb216-f14e-44f8-b4cb-fa900c619de7
|
||||||
|
status:
|
||||||
|
code: 204
|
||||||
|
message: NO CONTENT
|
||||||
|
url: <craton-url>/clouds/147
|
||||||
|
recorded_with: betamax/0.8.0
|
161
cratonclient/tests/cassettes/TestRegions-test_delete.yaml
Normal file
161
cratonclient/tests/cassettes/TestRegions-test_delete.yaml
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
http_interactions:
|
||||||
|
- recorded_at: '2017-03-21T15:52:13'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: "{\n \"name\": \"cloud-TestRegions-test_delete\"\n}"
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '41'
|
||||||
|
Content-Type: application/json
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: POST
|
||||||
|
uri: <craton-url>/clouds
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: "{\n \"variables\": {},\n \"created_at\": \"2017-03-21T00:42:40.048289\"\
|
||||||
|
,\n \"note\": null,\n \"updated_at\": null,\n \"id\": 148,\n \"name\"\
|
||||||
|
: \"cloud-TestRegions-test_delete\",\n \"project_id\": \"<craton-demo-project>\"\
|
||||||
|
\n}"
|
||||||
|
headers:
|
||||||
|
Content-Length: '218'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:40 GMT
|
||||||
|
Location: <craton-url>/clouds/148
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-e0b1ea02-0854-485d-91eb-7a04face6c95
|
||||||
|
status:
|
||||||
|
code: 201
|
||||||
|
message: CREATED
|
||||||
|
url: <craton-url>/clouds
|
||||||
|
- recorded_at: '2017-03-21T15:52:13'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: "{\n \"cloud_id\": 148,\n \"name\": \"region-creation\"\n}"
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '44'
|
||||||
|
Content-Type: application/json
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: POST
|
||||||
|
uri: <craton-url>/regions
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: "{\n \"variables\": {},\n \"cloud_id\": 148,\n \"created_at\": \"\
|
||||||
|
2017-03-21T00:42:40.088796\",\n \"note\": null,\n \"updated_at\": null,\n\
|
||||||
|
\ \"id\": 16,\n \"name\": \"region-creation\",\n \"project_id\": \"<craton-demo-project>\"\
|
||||||
|
\n}"
|
||||||
|
headers:
|
||||||
|
Content-Length: '222'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:40 GMT
|
||||||
|
Location: <craton-url>/regions/16
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-c789660d-bf96-4bc2-a94d-4d8f8e5396d9
|
||||||
|
status:
|
||||||
|
code: 201
|
||||||
|
message: CREATED
|
||||||
|
url: <craton-url>/regions
|
||||||
|
- recorded_at: '2017-03-21T15:52:13'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '0'
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: DELETE
|
||||||
|
uri: <craton-url>/regions/16
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Content-Length: '0'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:40 GMT
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-6814ce07-367f-4548-bcaa-354d24ed412e
|
||||||
|
status:
|
||||||
|
code: 204
|
||||||
|
message: NO CONTENT
|
||||||
|
url: <craton-url>/regions/16
|
||||||
|
- recorded_at: '2017-03-21T15:52:13'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: GET
|
||||||
|
uri: <craton-url>/regions/16
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: '{"message": "Not Found", "status": 404}'
|
||||||
|
headers:
|
||||||
|
Content-Length: '46'
|
||||||
|
Content-Type: text/html; charset=utf-8
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:40 GMT
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-2cf37f2b-64cb-4b71-99f7-369f3fda6d33
|
||||||
|
status:
|
||||||
|
code: 404
|
||||||
|
message: NOT FOUND
|
||||||
|
url: <craton-url>/regions/16
|
||||||
|
- recorded_at: '2017-03-21T15:52:13'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '0'
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: DELETE
|
||||||
|
uri: <craton-url>/clouds/148
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Content-Length: '0'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:40 GMT
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-03c85c4a-b1a2-4c8e-a59c-ff3548a25212
|
||||||
|
status:
|
||||||
|
code: 204
|
||||||
|
message: NO CONTENT
|
||||||
|
url: <craton-url>/clouds/148
|
||||||
|
recorded_with: betamax/0.8.0
|
File diff suppressed because it is too large
Load Diff
4542
cratonclient/tests/cassettes/TestRegions-test_manual_pagination.yaml
Normal file
4542
cratonclient/tests/cassettes/TestRegions-test_manual_pagination.yaml
Normal file
File diff suppressed because it is too large
Load Diff
167
cratonclient/tests/cassettes/TestRegions-test_update.yaml
Normal file
167
cratonclient/tests/cassettes/TestRegions-test_update.yaml
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
http_interactions:
|
||||||
|
- recorded_at: '2017-03-21T15:52:15'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: "{\n \"name\": \"cloud-TestRegions-test_update\"\n}"
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '41'
|
||||||
|
Content-Type: application/json
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: POST
|
||||||
|
uri: <craton-url>/clouds
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: "{\n \"variables\": {},\n \"created_at\": \"2017-03-21T00:42:41.637962\"\
|
||||||
|
,\n \"note\": null,\n \"updated_at\": null,\n \"id\": 151,\n \"name\"\
|
||||||
|
: \"cloud-TestRegions-test_update\",\n \"project_id\": \"<craton-demo-project>\"\
|
||||||
|
\n}"
|
||||||
|
headers:
|
||||||
|
Content-Length: '218'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:41 GMT
|
||||||
|
Location: <craton-url>/clouds/151
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-2da1f63d-caf8-4ae2-acc1-5cc3c55ae6d9
|
||||||
|
status:
|
||||||
|
code: 201
|
||||||
|
message: CREATED
|
||||||
|
url: <craton-url>/clouds
|
||||||
|
- recorded_at: '2017-03-21T15:52:15'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: "{\n \"cloud_id\": 151,\n \"name\": \"region-to-update\"\n}"
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '45'
|
||||||
|
Content-Type: application/json
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: POST
|
||||||
|
uri: <craton-url>/regions
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: "{\n \"variables\": {},\n \"cloud_id\": 151,\n \"created_at\": \"\
|
||||||
|
2017-03-21T00:42:41.721637\",\n \"note\": null,\n \"updated_at\": null,\n\
|
||||||
|
\ \"id\": 61,\n \"name\": \"region-to-update\",\n \"project_id\": \"<craton-demo-project>\"\
|
||||||
|
\n}"
|
||||||
|
headers:
|
||||||
|
Content-Length: '223'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:41 GMT
|
||||||
|
Location: <craton-url>/regions/61
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-fb85c056-6722-4174-bb27-24e390f6583e
|
||||||
|
status:
|
||||||
|
code: 201
|
||||||
|
message: CREATED
|
||||||
|
url: <craton-url>/regions
|
||||||
|
- recorded_at: '2017-03-21T15:52:15'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: "{\n \"name\": \"region_updated\",\n \"note\": \"Here I add my note.\"\
|
||||||
|
\n}"
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '57'
|
||||||
|
Content-Type: application/json
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: PUT
|
||||||
|
uri: <craton-url>/regions/61
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: "{\n \"cloud_id\": 151,\n \"created_at\": \"2017-03-21T00:42:41.000000\"\
|
||||||
|
,\n \"note\": \"Here I add my note.\",\n \"updated_at\": \"2017-03-21T00:42:41.811053\"\
|
||||||
|
,\n \"project_id\": \"<craton-demo-project>\",\n \"name\": \"region_updated\"\
|
||||||
|
,\n \"id\": 61\n}"
|
||||||
|
headers:
|
||||||
|
Content-Length: '243'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:41 GMT
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-80453771-42f3-49ee-9bc2-ea9343fe3a9d
|
||||||
|
status:
|
||||||
|
code: 200
|
||||||
|
message: OK
|
||||||
|
url: <craton-url>/regions/61
|
||||||
|
- recorded_at: '2017-03-21T15:52:15'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '0'
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: DELETE
|
||||||
|
uri: <craton-url>/regions/61
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Content-Length: '0'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:41 GMT
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-5f9e3a5c-ceed-4fff-8883-b235d5a646c6
|
||||||
|
status:
|
||||||
|
code: 204
|
||||||
|
message: NO CONTENT
|
||||||
|
url: <craton-url>/regions/61
|
||||||
|
- recorded_at: '2017-03-21T15:52:15'
|
||||||
|
request:
|
||||||
|
body:
|
||||||
|
encoding: utf-8
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Accept: '*/*'
|
||||||
|
Accept-Encoding: gzip, deflate
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Length: '0'
|
||||||
|
User-Agent: python-cratonclient/0.0.1
|
||||||
|
X-Auth-Project: <craton-demo-project>
|
||||||
|
X-Auth-Token: <craton-demo-token>
|
||||||
|
X-Auth-User: <craton-demo-username>
|
||||||
|
method: DELETE
|
||||||
|
uri: <craton-url>/clouds/151
|
||||||
|
response:
|
||||||
|
body:
|
||||||
|
encoding: null
|
||||||
|
string: ''
|
||||||
|
headers:
|
||||||
|
Content-Length: '0'
|
||||||
|
Content-Type: application/json
|
||||||
|
Date: Tue, 21 Mar 2017 00:42:41 GMT
|
||||||
|
Server: WSGIServer/0.2 CPython/3.5.2
|
||||||
|
x-openstack-request-id: req-0b8747e5-1455-4748-95f7-3115c831a735
|
||||||
|
status:
|
||||||
|
code: 204
|
||||||
|
message: NO CONTENT
|
||||||
|
url: <craton-url>/clouds/151
|
||||||
|
recorded_with: betamax/0.8.0
|
106
cratonclient/tests/integration/v1/test_regions.py
Normal file
106
cratonclient/tests/integration/v1/test_regions.py
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
"""Module containing the cratonclient.v1.regions integration tests."""
|
||||||
|
|
||||||
|
from cratonclient.tests.integration import base
|
||||||
|
|
||||||
|
|
||||||
|
class TestRegions(base.BetamaxTestCase):
|
||||||
|
"""Tests for v1 RegionsManager."""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""Prepare our test case for regions."""
|
||||||
|
super(TestRegions, self).setUp()
|
||||||
|
self.create_demo_client()
|
||||||
|
self.cloud = self.cleanupCloud(self.client.clouds.create(
|
||||||
|
name='cloud-{}'.format(self.cassette_name),
|
||||||
|
))
|
||||||
|
|
||||||
|
def test_create(self):
|
||||||
|
"""Verify creation of regions via the API."""
|
||||||
|
region = self.cleanupRegion(self.client.regions.create(
|
||||||
|
name='region-creation',
|
||||||
|
cloud_id=self.cloud.id,
|
||||||
|
))
|
||||||
|
|
||||||
|
self.assertEqual('region-creation', region.name)
|
||||||
|
self.assertEqual(self.cloud.id, region.cloud_id)
|
||||||
|
|
||||||
|
same_region = self.client.regions.get(region.id)
|
||||||
|
self.assertEqual(region.id, same_region.id)
|
||||||
|
self.assertEqual(region.name, same_region.name)
|
||||||
|
self.assertEqual(region.cloud_id, same_region.cloud_id)
|
||||||
|
|
||||||
|
def test_delete(self):
|
||||||
|
"""Verify deletion of regions via the API."""
|
||||||
|
region = self.client.regions.create(
|
||||||
|
name='region-creation',
|
||||||
|
cloud_id=self.cloud.id,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(self.client.regions.delete(region.id))
|
||||||
|
self.assertNotFound(self.client.regions.get, region.id)
|
||||||
|
|
||||||
|
def test_list_autopaginates(self):
|
||||||
|
"""Verify autopagination when listing regions."""
|
||||||
|
for i in range(64):
|
||||||
|
self.cleanupRegion(self.client.regions.create(
|
||||||
|
name='regions-autopaginate-{}'.format(i),
|
||||||
|
cloud_id=self.cloud.id,
|
||||||
|
))
|
||||||
|
|
||||||
|
regions = list(self.client.regions.list())
|
||||||
|
self.assertEqual(64, len(regions))
|
||||||
|
|
||||||
|
def test_manual_pagination(self):
|
||||||
|
"""Verify manual pagination of regions."""
|
||||||
|
for i in range(64):
|
||||||
|
self.cleanupRegion(self.client.regions.create(
|
||||||
|
name='regions-manual-list-{}'.format(i),
|
||||||
|
cloud_id=self.cloud.id,
|
||||||
|
))
|
||||||
|
|
||||||
|
first_page = list(self.client.regions.list(autopaginate=False))
|
||||||
|
self.assertEqual(30, len(first_page))
|
||||||
|
next_page = list(self.client.regions.list(
|
||||||
|
autopaginate=False,
|
||||||
|
marker=first_page[-1].id,
|
||||||
|
))
|
||||||
|
self.assertEqual(30, len(next_page))
|
||||||
|
last_page = list(self.client.regions.list(
|
||||||
|
autopaginate=False,
|
||||||
|
marker=next_page[-1].id,
|
||||||
|
))
|
||||||
|
self.assertEqual(4, len(last_page))
|
||||||
|
|
||||||
|
def test_update(self):
|
||||||
|
"""Verify the ability to update a given region."""
|
||||||
|
region = self.cleanupRegion(self.client.regions.create(
|
||||||
|
name='region-to-update',
|
||||||
|
cloud_id=self.cloud.id,
|
||||||
|
))
|
||||||
|
|
||||||
|
self.assertTrue('region-to-update', region.name)
|
||||||
|
self.assertIsNone(region.note)
|
||||||
|
|
||||||
|
updated_region = self.client.regions.update(
|
||||||
|
region.id,
|
||||||
|
name='region_updated',
|
||||||
|
note='Here I add my note.',
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(region.id, updated_region.id)
|
||||||
|
self.assertNotEqual(region.name, updated_region.name)
|
||||||
|
self.assertEqual('region_updated', updated_region.name)
|
||||||
|
self.assertEqual('Here I add my note.', updated_region.note)
|
Loading…
x
Reference in New Issue
Block a user