Merge "Add tests for our cells integration"

This commit is contained in:
Jenkins 2017-03-24 15:10:41 +00:00 committed by Gerrit Code Review
commit bf5249c66f
8 changed files with 10413 additions and 11 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,200 @@
http_interactions:
- recorded_at: '2017-03-21T15:20:14'
request:
body:
encoding: utf-8
string: "{\n \"name\": \"cells-cloud-TestCells-test_create\"\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>/clouds
response:
body:
encoding: null
string: "{\n \"project_id\": \"<craton-demo-project>\",\n \"name\": \"cells-cloud-TestCells-test_create\"\
,\n \"note\": null,\n \"updated_at\": null,\n \"variables\": {},\n \"\
created_at\": \"2017-03-21T00:10:38.118921\",\n \"id\": 14\n}"
headers:
Content-Length: '221'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Location: <craton-url>/clouds/14
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-f9b76b9e-566d-4280-a969-06e60741e34c
status:
code: 201
message: CREATED
url: <craton-url>/clouds
- recorded_at: '2017-03-21T15:20:14'
request:
body:
encoding: utf-8
string: "{\n \"name\": \"cells-region-TestCells-test_create\",\n \"cloud_id\"\
: 14\n}"
headers:
Accept: '*/*'
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: '62'
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 \"project_id\": \"<craton-demo-project>\",\n \"name\": \"cells-region-TestCells-test_create\"\
,\n \"note\": null,\n \"updated_at\": null,\n \"variables\": {},\n \"\
created_at\": \"2017-03-21T00:10:38.212043\",\n \"id\": 10,\n \"cloud_id\"\
: 14\n}"
headers:
Content-Length: '240'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Location: <craton-url>/regions/10
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-689fd261-4625-4b28-b973-54c3ff7b9025
status:
code: 201
message: CREATED
url: <craton-url>/regions
- recorded_at: '2017-03-21T15:20:14'
request:
body:
encoding: utf-8
string: "{\n \"variables\": {\n \"a\": \"b\"\n },\n \"name\": \"cell-0\"\
,\n \"cloud_id\": 14,\n \"region_id\": 10,\n \"note\": \"This is a test\
\ cell. There are many like it, but this is mine\"\n}"
headers:
Accept: '*/*'
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: '149'
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>/cells
response:
body:
encoding: null
string: "{\n \"project_id\": \"<craton-demo-project>\",\n \"name\": \"cell-0\"\
,\n \"note\": \"This is a test cell. There are many like it, but this is\
\ mine\",\n \"updated_at\": null,\n \"variables\": {\n \"a\": \"b\"\n\
\ },\n \"created_at\": \"2017-03-21T00:10:38.345855\",\n \"id\": 30,\n\
\ \"region_id\": 10,\n \"cloud_id\": 14\n}"
headers:
Content-Length: '306'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Location: <craton-url>/cells/30
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-d5262b2f-63bd-4eb5-80a2-d0d5a9d7c79e
status:
code: 201
message: CREATED
url: <craton-url>/cells
- recorded_at: '2017-03-21T15:20:14'
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>/cells/30
response:
body:
encoding: null
string: ''
headers:
Content-Length: '0'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-6431152a-df0a-461b-8983-7a92eb58939b
status:
code: 204
message: NO CONTENT
url: <craton-url>/cells/30
- recorded_at: '2017-03-21T15:20:14'
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/10
response:
body:
encoding: null
string: ''
headers:
Content-Length: '0'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-92e9871b-7c2b-49ad-a778-4ec9f8f7047d
status:
code: 204
message: NO CONTENT
url: <craton-url>/regions/10
- recorded_at: '2017-03-21T15:20:14'
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/14
response:
body:
encoding: null
string: ''
headers:
Content-Length: '0'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-8c1c3e29-5d12-40a0-b7df-6ecf991e431b
status:
code: 204
message: NO CONTENT
url: <craton-url>/clouds/14
recorded_with: betamax/0.8.0

View File

@ -0,0 +1,227 @@
http_interactions:
- recorded_at: '2017-03-21T15:20:14'
request:
body:
encoding: utf-8
string: "{\n \"name\": \"cells-cloud-TestCells-test_delete\"\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>/clouds
response:
body:
encoding: null
string: "{\n \"project_id\": \"<craton-demo-project>\",\n \"name\": \"cells-cloud-TestCells-test_delete\"\
,\n \"note\": null,\n \"updated_at\": null,\n \"variables\": {},\n \"\
created_at\": \"2017-03-21T00:10:38.237204\",\n \"id\": 15\n}"
headers:
Content-Length: '221'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Location: <craton-url>/clouds/15
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-095849cf-b6ae-4c5f-a616-491a4381d9a7
status:
code: 201
message: CREATED
url: <craton-url>/clouds
- recorded_at: '2017-03-21T15:20:14'
request:
body:
encoding: utf-8
string: "{\n \"name\": \"cells-region-TestCells-test_delete\",\n \"cloud_id\"\
: 15\n}"
headers:
Accept: '*/*'
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: '62'
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 \"project_id\": \"<craton-demo-project>\",\n \"name\": \"cells-region-TestCells-test_delete\"\
,\n \"note\": null,\n \"updated_at\": null,\n \"variables\": {},\n \"\
created_at\": \"2017-03-21T00:10:38.370396\",\n \"id\": 11,\n \"cloud_id\"\
: 15\n}"
headers:
Content-Length: '240'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Location: <craton-url>/regions/11
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-2d162165-4187-4d44-bea3-9c1760438c60
status:
code: 201
message: CREATED
url: <craton-url>/regions
- recorded_at: '2017-03-21T15:20:14'
request:
body:
encoding: utf-8
string: "{\n \"name\": \"cell-to-delete\",\n \"cloud_id\": 15,\n \"region_id\"\
: 11\n}"
headers:
Accept: '*/*'
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: '59'
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>/cells
response:
body:
encoding: null
string: "{\n \"project_id\": \"<craton-demo-project>\",\n \"name\": \"cell-to-delete\"\
,\n \"note\": null,\n \"updated_at\": null,\n \"variables\": {},\n \"\
created_at\": \"2017-03-21T00:10:38.487204\",\n \"id\": 33,\n \"region_id\"\
: 11,\n \"cloud_id\": 15\n}"
headers:
Content-Length: '239'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Location: <craton-url>/cells/33
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-81fee3a8-7f8c-4424-b8d3-d790b294efd6
status:
code: 201
message: CREATED
url: <craton-url>/cells
- recorded_at: '2017-03-21T15:20:14'
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>/cells/33
response:
body:
encoding: null
string: ''
headers:
Content-Length: '0'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-755ac568-87ef-4a36-ae4c-9639e8306df7
status:
code: 204
message: NO CONTENT
url: <craton-url>/cells/33
- recorded_at: '2017-03-21T15:20:14'
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>/cells/33
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:10:38 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-67c08f6b-a2f5-4ce9-a12e-c34119d9f521
status:
code: 404
message: NOT FOUND
url: <craton-url>/cells/33
- recorded_at: '2017-03-21T15:20:14'
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/11
response:
body:
encoding: null
string: ''
headers:
Content-Length: '0'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-c97e15dc-9562-4e9e-8a73-9e63fc7e2951
status:
code: 204
message: NO CONTENT
url: <craton-url>/regions/11
- recorded_at: '2017-03-21T15:20: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/15
response:
body:
encoding: null
string: ''
headers:
Content-Length: '0'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-0dfe349e-fe39-40c5-bfab-ccca0456f142
status:
code: 204
message: NO CONTENT
url: <craton-url>/clouds/15
recorded_with: betamax/0.8.0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,234 @@
http_interactions:
- recorded_at: '2017-03-21T15:20:14'
request:
body:
encoding: utf-8
string: "{\n \"name\": \"cells-cloud-TestCells-test_update_existing_cell\"\n\
}"
headers:
Accept: '*/*'
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: '59'
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 \"project_id\": \"<craton-demo-project>\",\n \"name\": \"cells-cloud-TestCells-test_update_existing_cell\"\
,\n \"note\": null,\n \"updated_at\": null,\n \"variables\": {},\n \"\
created_at\": \"2017-03-21T00:10:38.318952\",\n \"id\": 16\n}"
headers:
Content-Length: '235'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Location: <craton-url>/clouds/16
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-5b08fd6a-d2c2-4ec1-bddc-c92c2d544e2f
status:
code: 201
message: CREATED
url: <craton-url>/clouds
- recorded_at: '2017-03-21T15:20:14'
request:
body:
encoding: utf-8
string: "{\n \"name\": \"cells-region-TestCells-test_update_existing_cell\"\
,\n \"cloud_id\": 16\n}"
headers:
Accept: '*/*'
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: '76'
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 \"project_id\": \"<craton-demo-project>\",\n \"name\": \"cells-region-TestCells-test_update_existing_cell\"\
,\n \"note\": null,\n \"updated_at\": null,\n \"variables\": {},\n \"\
created_at\": \"2017-03-21T00:10:38.443485\",\n \"id\": 12,\n \"cloud_id\"\
: 16\n}"
headers:
Content-Length: '254'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Location: <craton-url>/regions/12
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-0b5cffb5-81f1-4580-847a-8d282a3479ae
status:
code: 201
message: CREATED
url: <craton-url>/regions
- recorded_at: '2017-03-21T15:20:14'
request:
body:
encoding: utf-8
string: "{\n \"variables\": {\n \"out-with\": \"the-old\"\n },\n \"name\"\
: \"cell-to-update\",\n \"cloud_id\": 16,\n \"region_id\": 12,\n \"note\"\
: \"Original note\"\n}"
headers:
Accept: '*/*'
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: '122'
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>/cells
response:
body:
encoding: null
string: "{\n \"project_id\": \"<craton-demo-project>\",\n \"name\": \"cell-to-update\"\
,\n \"note\": \"Original note\",\n \"updated_at\": null,\n \"variables\"\
: {\n \"out-with\": \"the-old\"\n },\n \"created_at\": \"2017-03-21T00:10:38.584541\"\
,\n \"id\": 36,\n \"region_id\": 12,\n \"cloud_id\": 16\n}"
headers:
Content-Length: '279'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Location: <craton-url>/cells/36
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-091847d6-f965-4ee1-a898-0bbb61c1dd87
status:
code: 201
message: CREATED
url: <craton-url>/cells
- recorded_at: '2017-03-21T15:20:14'
request:
body:
encoding: utf-8
string: "{\n \"note\": \"Updated note.\"\n}"
headers:
Accept: '*/*'
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: '25'
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>/cells/36
response:
body:
encoding: null
string: "{\n \"project_id\": \"<craton-demo-project>\",\n \"name\": \"cell-to-update\"\
,\n \"note\": \"Updated note.\",\n \"updated_at\": \"2017-03-21T00:10:38.693373\"\
,\n \"created_at\": \"2017-03-21T00:10:38.000000\",\n \"id\": 36,\n \"\
region_id\": 12,\n \"cloud_id\": 16\n}"
headers:
Content-Length: '255'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-893bb83f-8327-4047-8dd3-d304f16812b1
status:
code: 200
message: OK
url: <craton-url>/cells/36
- recorded_at: '2017-03-21T15:20:14'
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>/cells/36
response:
body:
encoding: null
string: ''
headers:
Content-Length: '0'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-31e44ca6-df4c-4a07-88b1-2b5e6afd06e0
status:
code: 204
message: NO CONTENT
url: <craton-url>/cells/36
- recorded_at: '2017-03-21T15:20: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/12
response:
body:
encoding: null
string: ''
headers:
Content-Length: '0'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:38 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-d89882d3-a917-4d72-8028-29e8f9638397
status:
code: 204
message: NO CONTENT
url: <craton-url>/regions/12
- recorded_at: '2017-03-21T15:20: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/16
response:
body:
encoding: null
string: ''
headers:
Content-Length: '0'
Content-Type: application/json
Date: Tue, 21 Mar 2017 00:10:39 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-request-id: req-d1881451-1653-4c6d-b533-d5dc59382939
status:
code: 204
message: NO CONTENT
url: <craton-url>/clouds/16
recorded_with: betamax/0.8.0

View File

@ -74,6 +74,26 @@ class BetamaxTestCase(base.TestCase):
'project': CRATON_ROOT_PROJECT,
}
def cleanupHost(self, host):
"""Add a cleanup task for the host."""
self.addCleanup(self.client.hosts.delete, host.id)
return host
def cleanupCloud(self, cloud):
"""Add a cleanup task for the cloud."""
self.addCleanup(self.client.clouds.delete, cloud.id)
return cloud
def cleanupRegion(self, region):
"""Add a cleanup task for the region."""
self.addCleanup(self.client.regions.delete, region.id)
return region
def cleanupCell(self, cell):
"""Add a cleanup task for the cell."""
self.addCleanup(self.client.cells.delete, cell.id)
return cell
def create_client(self, username, token, project):
"""Create a Craton client using Craton Auth."""
self.session = auth.craton_auth(

View File

@ -0,0 +1,122 @@
# -*- 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.cells integration tests."""
from cratonclient import exceptions
from cratonclient.tests.integration import base
class TestCells(base.BetamaxTestCase):
"""CellsManager integration tests."""
def setUp(self):
"""Prepare our cells test case."""
super(TestCells, self).setUp()
self.create_demo_client()
self.cloud = self.cleanupCloud(self.client.clouds.create(
name='cells-cloud-{}'.format(self.cassette_name)
))
self.region = self.cleanupRegion(self.client.regions.create(
name='cells-region-{}'.format(self.cassette_name),
cloud_id=self.cloud.id,
))
def test_create(self):
"""Test creation of a cell via the API."""
note = 'This is a test cell. There are many like it, but this is mine'
cell = self.cleanupCell(self.client.cells.create(
name='cell-0',
region_id=self.region.id,
cloud_id=self.cloud.id,
note=note,
variables={'a': 'b'},
))
self.assertEqual('cell-0', cell.name)
self.assertEqual(self.region.id, cell.region_id)
self.assertEqual(self.cloud.id, cell.cloud_id)
self.assertEqual(note, cell.note)
def test_delete(self):
"""Test deleting a cell after creating it."""
cell = self.client.cells.create(
name='cell-to-delete',
region_id=self.region.id,
cloud_id=self.cloud.id,
)
self.assertEqual('cell-to-delete', cell.name)
self.assertTrue(self.client.cells.delete(cell.id))
self.assertRaises(exceptions.NotFound, self.client.cells.get, cell.id)
def test_autopagination_when_listing(self):
"""Verify the client autopaginates lists of cells."""
note_str = 'This was created automatically for pagination. ({}/63)'
for i in range(0, 63):
self.cleanupCell(self.client.cells.create(
name='pagination-cell-{}'.format(i),
region_id=self.region.id,
cloud_id=self.cloud.id,
note=note_str.format(i),
))
cells = list(self.client.cells.list())
self.assertEqual(63, len(cells))
def test_manual_pagination(self):
"""Verify manual pagination of cells."""
note_str = 'This was created automatically for pagination. ({}/63)'
for i in range(0, 63):
self.cleanupCell(self.client.cells.create(
name='pagination-cell-{}'.format(i),
region_id=self.region.id,
cloud_id=self.cloud.id,
note=note_str.format(i),
))
cells = list(self.client.cells.list(autopaginate=False))
self.assertEqual(30, len(cells))
next_page = list(self.client.cells.list(
marker=cells[-1].id,
autopaginate=False,
))
self.assertEqual(30, len(next_page))
last_page = list(self.client.cells.list(
marker=next_page[-1].id,
autopaginate=False,
))
self.assertEqual(3, len(last_page))
def test_update_existing_cell(self):
"""Verify we can update a cell."""
cell = self.cleanupCell(self.client.cells.create(
name='cell-to-update',
region_id=self.region.id,
cloud_id=self.cloud.id,
note='Original note',
variables={'out-with': 'the-old'},
))
self.assertEqual('cell-to-update', cell.name)
self.assertEqual('Original note', cell.note)
updated_cell = self.client.cells.update(
item_id=cell.id,
note='Updated note.',
)
self.assertEqual(cell.id, updated_cell.id)
self.assertEqual(cell.name, updated_cell.name)
self.assertEqual('Updated note.', updated_cell.note)

View File

@ -24,20 +24,13 @@ class TestHosts(base.BetamaxTestCase):
"""Prepare our hosts test case."""
super(TestHosts, self).setUp()
self.create_demo_client()
self.cloud = self.client.clouds.create(
self.cloud = self.cleanupCloud(self.client.clouds.create(
name='cloud-{}'.format(self.cassette_name),
)
self.addCleanup(self.client.clouds.delete, self.cloud.id)
self.region = self.client.regions.create(
))
self.region = self.cleanupRegion(self.client.regions.create(
name='region-{}'.format(self.cassette_name),
cloud_id=self.cloud.id,
)
self.addCleanup(self.client.regions.delete, self.region.id)
def cleanupHost(self, host):
"""Add a cleanup task for this host."""
self.addCleanup(self.client.hosts.delete, host.id)
return host
))
def test_create(self):
"""Test creation of hosts via the Python API."""