Merge "[TrivialFix] Move share type filter tempest to test_scheduler_stats.py"
diff --git a/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py b/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py
index d77b7ea..fe4cc43 100644
--- a/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py
+++ b/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py
@@ -12,7 +12,9 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import ddt
 from tempest import config
+from tempest.lib.common.utils import data_utils
 from testtools import testcase as tc
 
 from manila_tempest_tests.tests.api import base
@@ -20,8 +22,30 @@
 CONF = config.CONF
 
 
+@ddt.ddt
 class SchedulerStatsAdminTest(base.BaseSharesAdminTest):
 
+    @classmethod
+    def _create_share_type(cls, negative=False):
+        name = data_utils.rand_name("unique_st_name")
+        extra_specs = None
+
+        if negative:
+            extra_specs = {
+                'share_backend_name': data_utils.rand_name("fake_name"),
+            }
+
+        extra_specs = cls.add_required_extra_specs_to_dict(
+            extra_specs=extra_specs)
+        return cls.create_share_type(
+            name, extra_specs=extra_specs,
+            client=cls.admin_client)
+
+    @classmethod
+    def resource_setup(cls):
+        super(SchedulerStatsAdminTest, cls).resource_setup()
+        cls.admin_client = cls.shares_v2_client
+
     @tc.attr(base.TAG_POSITIVE, base.TAG_API)
     def test_pool_list(self):
 
@@ -138,5 +162,44 @@
         # Ensure we got no pools
         self.assertEmpty(pool_list)
 
+    @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
+    @base.skip_if_microversion_not_supported("2.23")
+    @ddt.data((True, "name"), (True, "id"), (False, "name"), (False, "id"))
+    @ddt.unpack
+    def test_pool_list_with_share_type_filter_with_detail(
+            self, detail, share_type_key):
+        st = self._create_share_type()
+        search_opts = {"share_type": st["share_type"][share_type_key]}
+        kwargs = {'search_opts': search_opts}
+
+        if detail:
+            kwargs.update({'detail': True})
+
+        pools = self.admin_client.list_pools(**kwargs)['pools']
+
+        self.assertIsNotNone(pools, 'No pools returned from pools API')
+        self.assertNotEmpty(pools)
+        for pool in pools:
+            pool_keys = list(pool.keys())
+            self.assertIn("name", pool_keys)
+            self.assertIn("host", pool_keys)
+            self.assertIn("backend", pool_keys)
+            self.assertIn("pool", pool_keys)
+            self.assertIs(detail, "capabilities" in pool_keys)
+
+    @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+    @base.skip_if_microversion_not_supported("2.23")
+    @ddt.data((True, "name"), (True, "id"), (False, "name"), (False, "id"))
+    @ddt.unpack
+    def test_pool_list_with_share_type_filter_with_detail_negative(
+            self, detail, share_type_key):
+        st_negative = self._create_share_type(negative=True)
+        search_opts = {"share_type": st_negative["share_type"][share_type_key]}
+
+        pools = self.admin_client.list_pools(
+            detail=detail, search_opts=search_opts)['pools']
+
+        self.assertEmpty(pools)
+
     def _wrap_regex_for_exact_match(self, regex):
         return '^%s$' % regex
diff --git a/manila_tempest_tests/tests/api/admin/test_share_type_filter.py b/manila_tempest_tests/tests/api/admin/test_share_type_filter.py
deleted file mode 100644
index e34f943..0000000
--- a/manila_tempest_tests/tests/api/admin/test_share_type_filter.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-import ddt
-from tempest.lib.common.utils import data_utils
-from testtools import testcase as tc
-
-from manila_tempest_tests.tests.api import base
-
-
-@ddt.ddt
-class ShareTypeFilterTest(base.BaseSharesAdminTest):
-
-    @classmethod
-    def _create_share_type(cls):
-        name = data_utils.rand_name("unique_st_name")
-        extra_specs = cls.add_required_extra_specs_to_dict()
-        return cls.create_share_type(
-            name, extra_specs=extra_specs,
-            client=cls.admin_client)
-
-    @classmethod
-    def resource_setup(cls):
-        super(ShareTypeFilterTest, cls).resource_setup()
-        cls.admin_client = cls.shares_v2_client
-        cls.st = cls._create_share_type()
-
-    @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
-    @base.skip_if_microversion_not_supported("2.23")
-    @ddt.data(True, False)
-    def test_get_pools_with_share_type_filter_with_detail(self, detail):
-        share_type = self.st["share_type"]["id"]
-        search_opts = {"share_type": share_type}
-        kwargs = {'search_opts': search_opts}
-
-        if detail:
-            kwargs.update({'detail': True})
-
-        pools = self.admin_client.list_pools(**kwargs)['pools']
-        for pool in pools:
-            pool_keys = pool.keys()
-            self.assertIn("name", pool_keys)
-            self.assertIn("host", pool_keys)
-            self.assertIn("backend", pool_keys)
-            self.assertIn("pool", pool_keys)
-            self.assertIs(detail, "capabilities" in pool_keys)
diff --git a/manila_tempest_tests/tests/api/admin/test_share_type_filter_negative.py b/manila_tempest_tests/tests/api/admin/test_share_type_filter_negative.py
deleted file mode 100644
index 80f8d66..0000000
--- a/manila_tempest_tests/tests/api/admin/test_share_type_filter_negative.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-import ddt
-from oslo_utils import uuidutils
-from tempest import config
-from tempest.lib.common.utils import data_utils
-from testtools import testcase as tc
-
-from manila_tempest_tests.tests.api import base
-
-CONF = config.CONF
-
-
-@ddt.ddt
-class ShareTypeFilterNegativeTest(base.BaseSharesAdminTest):
-
-    @classmethod
-    def _create_share_type(cls):
-        name = data_utils.rand_name("unique_st_name")
-        extra_specs = {
-            'share_backend_name': uuidutils.generate_uuid(),
-        }
-        extra_specs = cls.add_required_extra_specs_to_dict(
-            extra_specs=extra_specs)
-        return cls.create_share_type(
-            name, extra_specs=extra_specs,
-            client=cls.admin_client)
-
-    @classmethod
-    def resource_setup(cls):
-        super(ShareTypeFilterNegativeTest, cls).resource_setup()
-        cls.admin_client = cls.shares_v2_client
-        cls.st = cls._create_share_type()
-
-    @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
-    @base.skip_if_microversion_not_supported("2.23")
-    @ddt.data(True, False)
-    def test_get_pools_invalid_share_type_filter_with_detail(self, detail):
-        share_type = self.st["share_type"]["name"]
-        search_opts = {"share_type": share_type}
-        pools = self.admin_client.list_pools(
-            detail=detail, search_opts=search_opts)['pools']
-
-        self.assertEmpty(pools)