Skip to content
Permalink
Browse files
Extennd on Zone tests
  • Loading branch information
brogand93 committed Jun 1, 2014
1 parent e47d1d6 commit 4c8c45c8f7011c6698842a19db831ce6e4e7a11f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
@@ -4,7 +4,7 @@
"zone": [
{
"localstorageenabled": true,
"name": "CH-GV2",
"name": "zonename",
"zonetoken": "ccb0a60c-79c8-3230-ab8b-8bdbe8c45bb7",
"securitygroupsenabled": true,
"allocationstate": "Enabled",
@@ -13,12 +13,39 @@ class ZonesTestCase(GStackAppTestCase):
def test_list_zones(self):

get = mock.Mock()
get.return_value.text = read_file('tests/data/zones_search.json')
get.return_value.text = read_file('tests/data/valid_describe_zone.json')
get.return_value.status_code = 200

with mock.patch('requests.get', get):
headers = {'authorization': 'Bearer ' + str(GStackAppTestCase.access_token)}
print headers
response = self.get('/compute/v1/projects/exampleproject/zones', headers=headers)

self.assert_ok(response)

def test_get_zone(self):

get = mock.Mock()
get.return_value.text = read_file('tests/data/valid_describe_zone.json')
get.return_value.status_code = 200

with mock.patch('requests.get', get):
headers = {'authorization': 'Bearer ' + str(GStackAppTestCase.access_token)}
response = self.get('/compute/v1/projects/exampleproject/zones/zonename', headers=headers)

self.assert_ok(response)

def test_get_zone_not_found(self):

get = mock.Mock()
get.return_value.text = read_file('tests/data/empty_describe_zone.json')
get.return_value.status_code = 200

with mock.patch('requests.get', get):
headers = {'authorization': 'Bearer ' + str(GStackAppTestCase.access_token)}
response = self.get('/compute/v1/projects/exampleproject/zones/zonename', headers=headers)

print response.data

self.assert_not_found(response)
assert 'The resource \'/compute/v1/projects/exampleproject/zones/zonename\' was not found' \
in response.data

0 comments on commit 4c8c45c

Please sign in to comment.