Merge "Fix pool_list filter tests to match pools exactly"

This commit is contained in:
Jenkins 2015-09-18 17:50:00 +00:00 committed by Gerrit Code Review
commit ba06619ee3

View File

@ -50,9 +50,9 @@ class SchedulerStatsAdminTest(base.BaseSharesAdminTest):
# Build search opts from data and get pools again with filter # Build search opts from data and get pools again with filter
search_opts = { search_opts = {
'host': pool.get('host'), 'host': self._wrap_regex_for_exact_match(pool.get('host')),
'backend': pool.get('backend'), 'backend': self._wrap_regex_for_exact_match(pool.get('backend')),
'pool': pool.get('pool'), 'pool': self._wrap_regex_for_exact_match(pool.get('pool')),
} }
pool_response = self.shares_client.list_pools( pool_response = self.shares_client.list_pools(
search_opts=search_opts) search_opts=search_opts)
@ -63,7 +63,7 @@ class SchedulerStatsAdminTest(base.BaseSharesAdminTest):
# Match the key values, not the timestamp. # Match the key values, not the timestamp.
for k, v in search_opts.items(): for k, v in search_opts.items():
self.assertEqual(v, filtered_pool_list[0][k]) self.assertEqual(v[1:-1], filtered_pool_list[0][k])
@test.attr(type=["gate", "smoke", ]) @test.attr(type=["gate", "smoke", ])
def test_pool_list_with_filters_negative(self): def test_pool_list_with_filters_negative(self):
@ -108,9 +108,9 @@ class SchedulerStatsAdminTest(base.BaseSharesAdminTest):
# Build search opts from data and get pools again with filter # Build search opts from data and get pools again with filter
search_opts = { search_opts = {
'host': pool.get('host'), 'host': self._wrap_regex_for_exact_match(pool.get('host')),
'backend': pool.get('backend'), 'backend': self._wrap_regex_for_exact_match(pool.get('backend')),
'pool': pool.get('pool'), 'pool': self._wrap_regex_for_exact_match(pool.get('pool')),
} }
pool_response = self.shares_client.list_pools( pool_response = self.shares_client.list_pools(
detail=True, search_opts=search_opts) detail=True, search_opts=search_opts)
@ -121,7 +121,7 @@ class SchedulerStatsAdminTest(base.BaseSharesAdminTest):
# Match the key values, not the timestamp. # Match the key values, not the timestamp.
for k, v in search_opts.items(): for k, v in search_opts.items():
self.assertEqual(v, filtered_pool_list[0][k]) self.assertEqual(v[1:-1], filtered_pool_list[0][k])
@test.attr(type=["gate", "smoke", ]) @test.attr(type=["gate", "smoke", ])
def test_pool_list_detail_with_filters_negative(self): def test_pool_list_detail_with_filters_negative(self):
@ -138,3 +138,6 @@ class SchedulerStatsAdminTest(base.BaseSharesAdminTest):
# Ensure we got no pools # Ensure we got no pools
self.assertEmpty(pool_list) self.assertEmpty(pool_list)
def _wrap_regex_for_exact_match(self, regex):
return '^%s$' % regex