Merge "Move properties handling to the test side"
diff --git a/HACKING.rst b/HACKING.rst
index 480650c..432db7d 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -160,11 +160,17 @@
 
 Negative Tests
 --------------
-TODO: Write the guideline related to negative tests.
+Error handling is an important aspect of API design and usage. Negative
+tests are a way to ensure that an application can gracefully handle
+invalid or unexpected input. However, as a black box integration test
+suite, Tempest is not suitable for handling all negative test cases, as
+the wide variety and complexity of negative tests can lead to long test
+runs and knowledge of internal implementation details. The bulk of
+negative testing should be handled with project function tests. The
+exception to this rule is API tests used for interoperability testing.
 
 Test skips because of Known Bugs
 --------------------------------
-
 If a test is broken because of a bug it is appropriate to skip the test until
 bug has been fixed. You should use the skip_because decorator so that
 Tempest's skip tracking tool can watch the bug status.
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index e6a22b0..9187e23 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -240,7 +240,7 @@
             self._try_wrapper(self.users_client.delete_user, user)
         for tenant in self.tenants:
             self._try_wrapper(self.projects_client.delete_tenant, tenant)
-        for project in self.projects:
+        for project in reversed(self.projects):
             self._try_wrapper(self.projects_client.delete_project, project)
         for role in self.roles:
             self._try_wrapper(self.roles_client.delete_role, role)
diff --git a/tempest/api/volume/admin/test_volumes_list.py b/tempest/api/volume/admin/test_volumes_list.py
new file mode 100644
index 0000000..64041b8
--- /dev/null
+++ b/tempest/api/volume/admin/test_volumes_list.py
@@ -0,0 +1,59 @@
+# Copyright 2016 Red Hat, Inc.
+# All Rights Reserved.
+#
+#    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 operator
+
+from tempest.api.volume import base
+from tempest.common import waiters
+from tempest import test
+
+
+class VolumesListAdminV2TestJSON(base.BaseVolumeAdminTest):
+
+    @classmethod
+    def resource_setup(cls):
+        super(VolumesListAdminV2TestJSON, cls).resource_setup()
+        # Create 3 test volumes
+        cls.volume_list = []
+        for i in range(3):
+            volume = cls.create_volume()
+            # Fetch volume details
+            volume_details = cls.volumes_client.show_volume(
+                volume['id'])['volume']
+            cls.volume_list.append(volume_details)
+
+    @test.idempotent_id('5866286f-3290-4cfd-a414-088aa6cdc469')
+    def test_volume_list_param_tenant(self):
+        # Test to list volumes from single tenant
+        # Create a volume in admin tenant
+        adm_vol = self.admin_volume_client.create_volume()['volume']
+        waiters.wait_for_volume_status(self.admin_volume_client,
+                                       adm_vol['id'], 'available')
+        self.addCleanup(self.admin_volume_client.delete_volume, adm_vol['id'])
+        params = {'all_tenants': 1,
+                  'project_id': self.volumes_client.tenant_id}
+        # Getting volume list from primary tenant using admin credentials
+        fetched_list = self.admin_volume_client.list_volumes(
+            detail=True, params=params)['volumes']
+        # Verifying fetched volume ids list is related to primary tenant
+        fetched_list_ids = map(operator.itemgetter('id'), fetched_list)
+        expected_list_ids = map(operator.itemgetter('id'), self.volume_list)
+        self.assertEqual(sorted(expected_list_ids), sorted(fetched_list_ids))
+        # Verifying tenant id of volumes fetched list is related to
+        # primary tenant
+        fetched_tenant_id = map(operator.itemgetter(
+            'os-vol-tenant-attr:tenant_id'), fetched_list)
+        expected_tenant_id = [self.volumes_client.tenant_id] * 3
+        self.assertEqual(expected_tenant_id, fetched_tenant_id)