Skip to content
Permalink
Browse files
Add aggregation list tests to instances
  • Loading branch information
brogand93 committed Jun 2, 2014
1 parent 8e90072 commit a383e91b221f9f7e713569b8868acb772a46d5a6
Showing 2 changed files with 43 additions and 0 deletions.
@@ -58,6 +58,8 @@ def get_zone_by_name(authorization, zone):
def get_zone_names(authorization):
zone_list = _get_zones(authorization)

print zone_list

zones = []
if zone_list['listzonesresponse']:
for zone in zone_list['listzonesresponse']['zone']:
@@ -2,6 +2,7 @@
# encoding: utf-8

import mock
import json

from gstack.helpers import read_file
from . import GStackAppTestCase
@@ -20,6 +21,46 @@ def test_list_instances(self):

self.assert_ok(response)

def test_aggregated_list_instances(self):

get = mock.Mock()
get.return_value.text = read_file('tests/data/valid_describe_instances.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/instances', headers=headers)

self.assert_ok(response)

def test_aggregated_list_instances_with_name_filter(self):

get = mock.Mock()
get.return_value.text = read_file('tests/data/valid_describe_instances.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/instances?filter=name+eq+instancename',
headers=headers)

self.assert_ok(response)

def test_get_instance(self):

get = mock.Mock()

0 comments on commit a383e91

Please sign in to comment.