Add aggregation list tests to instances
diff --git a/gstack/controllers/zones.py b/gstack/controllers/zones.py
index 9ff90bd..8e433f3 100755
--- a/gstack/controllers/zones.py
+++ b/gstack/controllers/zones.py
@@ -58,6 +58,8 @@
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']:
diff --git a/tests/instances_tests.py b/tests/instances_tests.py
index 13cbadc..ac887a5 100644
--- a/tests/instances_tests.py
+++ b/tests/instances_tests.py
@@ -2,6 +2,7 @@
# encoding: utf-8
import mock
+import json
from gstack.helpers import read_file
from . import GStackAppTestCase
@@ -20,6 +21,46 @@
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()