Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
266 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"listvolumesresponse": { | ||
"volume": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"listvolumesresponse": { | ||
"count": 1, | ||
"volume": [ | ||
{ | ||
"diskofferingname": "Custom", | ||
"account": "admin", | ||
"domainid": "2edae3e4-95e4-11e3-b2e4-d19c9d3e5e1d", | ||
"name": "volumename", | ||
"created": "2014-02-22T13:25:12+0000", | ||
"storagetype": "shared", | ||
"type": "DATADISK", | ||
"tags": [], | ||
"domain": "ROOT", | ||
"isextractable": true, | ||
"zoneid": "1e47a2fc-61c7-401c-b90e-416b472ada64", | ||
"destroyed": false, | ||
"state": "Allocated", | ||
"diskofferingdisplaytext": "Custom Disk", | ||
"displayvolume": true, | ||
"size": 10737418240, | ||
"diskofferingid": "46f0a62e-ba3c-4a49-b619-877a8b2a07ed", | ||
"id": "aa903a80-efa9-4fac-b424-544cbda9fce9", | ||
"zonename": "Sandbox-simulator" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"listvolumesresponse": { | ||
"count": 21, | ||
"volume": [ | ||
{ | ||
"diskofferingname": "Custom", | ||
"account": "admin", | ||
"domainid": "2edae3e4-95e4-11e3-b2e4-d19c9d3e5e1d", | ||
"name": "6f78a7d4-8863-40da-96f8-0e10ad4ea94e", | ||
"created": "2014-02-22T13:25:12+0000", | ||
"storagetype": "shared", | ||
"type": "DATADISK", | ||
"tags": [], | ||
"domain": "ROOT", | ||
"isextractable": true, | ||
"zoneid": "1e47a2fc-61c7-401c-b90e-416b472ada64", | ||
"destroyed": false, | ||
"state": "Allocated", | ||
"diskofferingdisplaytext": "Custom Disk", | ||
"displayvolume": true, | ||
"size": 10737418240, | ||
"diskofferingid": "46f0a62e-ba3c-4a49-b619-877a8b2a07ed", | ||
"id": "aa903a80-efa9-4fac-b424-544cbda9fce9", | ||
"zonename": "Sandbox-simulator" | ||
}, | ||
{ | ||
"domain": "ROOT", | ||
"domainid": "2edae3e4-95e4-11e3-b2e4-d19c9d3e5e1d", | ||
"zoneid": "1e47a2fc-61c7-401c-b90e-416b472ada64", | ||
"vmname": "43791f77-26f8-48ca-b557-3a9392f735ae", | ||
"id": "de2d8297-eaaf-4e81-8ffe-97f37ddbbde5", | ||
"size": 5368709120, | ||
"diskofferingname": "Small", | ||
"diskofferingdisplaytext": "Small Disk, 5 GB", | ||
"storage": "PS0", | ||
"displayvolume": false, | ||
"destroyed": false, | ||
"state": "Ready", | ||
"type": "DATADISK", | ||
"zonename": "Sandbox-simulator", | ||
"tags": [], | ||
"isextractable": true, | ||
"account": "admin", | ||
"name": "DATA-5", | ||
"virtualmachineid": "43791f77-26f8-48ca-b557-3a9392f735ae", | ||
"storagetype": "shared", | ||
"hypervisor": "Simulator", | ||
"created": "2014-02-21T17:28:41+0000", | ||
"deviceid": 1, | ||
"diskofferingid": "8fade6f4-13ea-490f-aff2-65c9b37b7651", | ||
"vmstate": "Running" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
|
||
import mock | ||
import json | ||
|
||
from gstack.helpers import read_file | ||
from . import GStackAppTestCase | ||
|
||
class DisksTestCase(GStackAppTestCase): | ||
|
||
def test_list_disks(self): | ||
|
||
get = mock.Mock() | ||
get.return_value.text = read_file('tests/data/valid_describe_volumes.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/examplezone/disks', headers=headers) | ||
|
||
self.assert_ok(response) | ||
|
||
def test_aggregated_list_disks(self): | ||
|
||
get = mock.Mock() | ||
get.return_value.text = read_file('tests/data/valid_describe_volumes.json') | ||
get.return_value.status_code = 200 | ||
|
||
get_zones = mock.Mock() | ||
get_zones.return_value = json.loads(read_file('tests/data/valid_describe_zone.json')) | ||
|
||
with mock.patch('requests.get', get): | ||
with mock.patch( | ||
'gstack.controllers.zones._get_zones', | ||
get_zones | ||
): | ||
headers = {'authorization': 'Bearer ' + str(GStackAppTestCase.access_token)} | ||
response = self.get('/compute/v1/projects/projectid/aggregated/disks', headers=headers) | ||
|
||
self.assert_ok(response) | ||
|
||
def test_aggregated_list_disks_with_name_filter(self): | ||
|
||
get = mock.Mock() | ||
get.return_value.text = read_file('tests/data/valid_describe_volume.json') | ||
get.return_value.status_code = 200 | ||
|
||
get_zones = mock.Mock() | ||
get_zones.return_value = json.loads(read_file('tests/data/valid_describe_zone.json')) | ||
|
||
with mock.patch('requests.get', get): | ||
with mock.patch( | ||
'gstack.controllers.zones._get_zones', | ||
get_zones | ||
): | ||
headers = {'authorization': 'Bearer ' + str(GStackAppTestCase.access_token)} | ||
response = self.get( | ||
'/compute/v1/projects/projectid/aggregated/disks?filter=name+eq+volumename', | ||
headers=headers) | ||
|
||
self.assert_ok(response) | ||
|
||
def test_get_disk(self): | ||
|
||
get = mock.Mock() | ||
get.return_value.text = read_file('tests/data/valid_describe_volume.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/examplezone/disks/volumename', headers=headers) | ||
|
||
self.assert_ok(response) | ||
|
||
def test_get_disk_disk_not_found(self): | ||
|
||
get = mock.Mock() | ||
get.return_value.text = read_file('tests/data/empty_describe_volumes.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/examplezone/disks/volumename', headers=headers) | ||
|
||
self.assert_not_found(response) | ||
|
||
assert 'The resource \'/compute/v1/projects/exampleproject/zones/examplezone/disks/volumename\' was not found' \ | ||
in response.data | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
|
||
import mock | ||
import json | ||
|
||
from gstack.helpers import read_file | ||
from . import GStackAppTestCase | ||
|
||
class FirewallsTestCase(GStackAppTestCase): | ||
|
||
def test_list_firewalls(self): | ||
|
||
get = mock.Mock() | ||
get.return_value.text = read_file('tests/data/valid_describe_security_groups.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/global/firewalls', headers=headers) | ||
|
||
self.assert_ok(response) | ||
|
||
|
||
def test_get_firewall(self): | ||
|
||
get = mock.Mock() | ||
get.return_value.text = read_file('tests/data/valid_describe_security_group.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/global/firewalls/securitygroupname', headers=headers) | ||
|
||
self.assert_ok(response) | ||
|
||
def test_get_firewall_firewall_not_found(self): | ||
|
||
get = mock.Mock() | ||
get.return_value.text = read_file('tests/data/empty_describe_security_groups.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/global/firewalls/securitygroupname', headers=headers) | ||
|
||
self.assert_not_found(response) | ||
assert 'The resource \'/compute/v1/projects/exampleproject/global/firewalls/securitygroupname\' was not found' \ | ||
in response.data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters