Merge "Added goal filter in Watcher API"
This commit is contained in:
@@ -207,6 +207,25 @@ class TestListAuditTemplate(api_base.FunctionalTest):
|
||||
next_marker = response['audit_templates'][-1]['uuid']
|
||||
self.assertIn(next_marker, response['next'])
|
||||
|
||||
def test_filter_by_goal(self):
|
||||
cfg.CONF.set_override('goals', {"DUMMY": "DUMMY", "BASIC": "BASIC"},
|
||||
group='watcher_goals', enforce_type=True)
|
||||
|
||||
for id_ in range(2):
|
||||
obj_utils.create_test_audit_template(
|
||||
self.context, id=id_, uuid=utils.generate_uuid(),
|
||||
name='My Audit Template {0}'.format(id_),
|
||||
goal="DUMMY")
|
||||
|
||||
for id_ in range(2, 5):
|
||||
obj_utils.create_test_audit_template(
|
||||
self.context, id=id_, uuid=utils.generate_uuid(),
|
||||
name='My Audit Template {0}'.format(id_),
|
||||
goal="BASIC")
|
||||
|
||||
response = self.get_json('/audit_templates?goal=BASIC')
|
||||
self.assertEqual(3, len(response['audit_templates']))
|
||||
|
||||
|
||||
class TestPatch(api_base.FunctionalTest):
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
|
||||
import wsme
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from watcher.api.controllers.v1 import utils
|
||||
from watcher.tests import base
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
@@ -47,3 +47,21 @@ class TestApiUtils(base.TestCase):
|
||||
self.assertRaises(wsme.exc.ClientSideError,
|
||||
utils.validate_sort_dir,
|
||||
'fake-sort')
|
||||
|
||||
def test_validate_search_filters(self):
|
||||
allowed_fields = ["allowed", "authorized"]
|
||||
|
||||
test_filters = {"allowed": 1, "authorized": 2}
|
||||
try:
|
||||
utils.validate_search_filters(test_filters, allowed_fields)
|
||||
except Exception as exc:
|
||||
self.fail(exc)
|
||||
|
||||
def test_validate_search_filters_with_invalid_key(self):
|
||||
allowed_fields = ["allowed", "authorized"]
|
||||
|
||||
test_filters = {"allowed": 1, "unauthorized": 2}
|
||||
|
||||
self.assertRaises(
|
||||
wsme.exc.ClientSideError, utils.validate_search_filters,
|
||||
test_filters, allowed_fields)
|
||||
|
||||
@@ -227,7 +227,7 @@ class TestClients(base.BaseTestCase):
|
||||
@mock.patch.object(clients.OpenStackClients, 'session')
|
||||
def test_clients_neutron_diff_vers(self, mock_session):
|
||||
'''neutronclient currently only has one version (v2)'''
|
||||
cfg.CONF.set_override('api_version', '2',
|
||||
cfg.CONF.set_override('api_version', '2.0',
|
||||
group='neutron_client')
|
||||
osc = clients.OpenStackClients()
|
||||
osc._neutron = None
|
||||
|
||||
Reference in New Issue
Block a user