Merge "Add function to test user messages query by timestamp"
diff --git a/manila_tempest_tests/services/share/json/shares_client.py b/manila_tempest_tests/services/share/json/shares_client.py
index 3481151..b2eabb4 100644
--- a/manila_tempest_tests/services/share/json/shares_client.py
+++ b/manila_tempest_tests/services/share/json/shares_client.py
@@ -467,9 +467,9 @@
             metadata = {}
         post_body = {"metadata": metadata}
         body = json.dumps(post_body)
-        if method is "post":
+        if method == "post":
             resp, metadata = self.post(uri, body)
-        if method is "put":
+        if method == "put":
             resp, metadata = self.put(uri, body)
         self.expected_success(200, resp.status)
         return self._parse_resp(metadata)
diff --git a/manila_tempest_tests/services/share/v2/json/shares_client.py b/manila_tempest_tests/services/share/v2/json/shares_client.py
index 3c1f5a4..b19872b 100644
--- a/manila_tempest_tests/services/share/v2/json/shares_client.py
+++ b/manila_tempest_tests/services/share/v2/json/shares_client.py
@@ -869,7 +869,6 @@
         self.expected_success(200, resp.status)
         return body
 
-
 ###############
 
     def list_availability_zones(self, url='availability-zones',
diff --git a/manila_tempest_tests/tests/api/admin/test_export_locations_negative.py b/manila_tempest_tests/tests/api/admin/test_export_locations_negative.py
index fe211ff..ef4f80b 100644
--- a/manila_tempest_tests/tests/api/admin/test_export_locations_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_export_locations_negative.py
@@ -33,8 +33,12 @@
     @classmethod
     def resource_setup(cls):
         super(ExportLocationsNegativeTest, cls).resource_setup()
+        # admin_client and different_project_client pertain to isolated
+        # projects, admin_member_client is a regular user in admin's project
         cls.admin_client = cls.admin_shares_v2_client
-        cls.member_client = cls.shares_v2_client
+        cls.admin_member_client = (
+            cls.admin_project_member_client.shares_v2_client)
+        cls.different_project_client = cls.shares_v2_client
         # create share type
         cls.share_type = cls._create_share_type()
         cls.share_type_id = cls.share_type['id']
@@ -65,26 +69,43 @@
             )
 
     @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
-    def test_list_share_instance_export_locations_by_member(self):
+    def test_list_share_instance_export_locations_as_member(self):
         for share_instance in self.share_instances:
             self.assertRaises(
                 lib_exc.Forbidden,
-                self.member_client.list_share_instance_export_locations,
-                "fake-inexistent-share-instance-id",
-            )
+                self.admin_member_client.list_share_instance_export_locations,
+                share_instance['id'])
 
     @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
-    def test_get_share_instance_export_location_by_member(self):
+    def test_get_share_instance_export_locations_as_member(self):
         for share_instance in self.share_instances:
             export_locations = (
                 self.admin_client.list_share_instance_export_locations(
                     share_instance['id']))
             for el in export_locations:
-                self.assertRaises(
-                    lib_exc.Forbidden,
-                    self.member_client.get_share_instance_export_location,
-                    share_instance['id'], el['id'],
-                )
+                self.assertRaises(lib_exc.Forbidden,
+                                  (self.admin_member_client.
+                                   get_share_instance_export_location),
+                                  share_instance['id'], el['id'])
+
+    @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+    def test_list_share_export_locations_by_different_project_user(self):
+        self.assertRaises(
+            lib_exc.Forbidden,
+            self.different_project_client.list_share_export_locations,
+            self.share['id'])
+
+    @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+    def test_get_share_export_location_by_different_project_user(self):
+        export_locations = self.admin_client.list_share_export_locations(
+            self.share['id'])
+
+        for export_location in export_locations:
+            self.assertRaises(
+                lib_exc.Forbidden,
+                self.different_project_client.get_share_export_location,
+                self.share['id'],
+                export_location['id'])
 
 
 class ExportLocationsAPIOnlyNegativeTest(base.BaseSharesAdminTest):
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index 89f2e92..22b1d72 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -980,7 +980,7 @@
                 res_id = res['id']
                 client = res["client"]
                 with handle_cleanup_exceptions():
-                    if res["type"] is "share":
+                    if res["type"] == "share":
                         cls.clear_share_replicas(res_id)
                         share_group_id = res.get('share_group_id')
                         if share_group_id:
@@ -989,35 +989,35 @@
                         else:
                             client.delete_share(res_id)
                         client.wait_for_resource_deletion(share_id=res_id)
-                    elif res["type"] is "snapshot":
+                    elif res["type"] == "snapshot":
                         client.delete_snapshot(res_id)
                         client.wait_for_resource_deletion(snapshot_id=res_id)
-                    elif (res["type"] is "share_network" and
+                    elif (res["type"] == "share_network" and
                             res_id != CONF.share.share_network_id):
                         client.delete_share_network(res_id)
                         client.wait_for_resource_deletion(sn_id=res_id)
-                    elif res["type"] is "security_service":
+                    elif res["type"] == "security_service":
                         client.delete_security_service(res_id)
                         client.wait_for_resource_deletion(ss_id=res_id)
-                    elif res["type"] is "share_type":
+                    elif res["type"] == "share_type":
                         client.delete_share_type(res_id)
                         client.wait_for_resource_deletion(st_id=res_id)
-                    elif res["type"] is "share_group":
+                    elif res["type"] == "share_group":
                         client.delete_share_group(res_id)
                         client.wait_for_resource_deletion(
                             share_group_id=res_id)
-                    elif res["type"] is "share_group_type":
+                    elif res["type"] == "share_group_type":
                         client.delete_share_group_type(res_id)
                         client.wait_for_resource_deletion(
                             share_group_type_id=res_id)
-                    elif res["type"] is "share_group_snapshot":
+                    elif res["type"] == "share_group_snapshot":
                         client.delete_share_group_snapshot(res_id)
                         client.wait_for_resource_deletion(
                             share_group_snapshot_id=res_id)
-                    elif res["type"] is "share_replica":
+                    elif res["type"] == "share_replica":
                         client.delete_share_replica(res_id)
                         client.wait_for_resource_deletion(replica_id=res_id)
-                    elif res["type"] is "share_network_subnet":
+                    elif res["type"] == "share_network_subnet":
                         sn_id = res["extra_params"]["share_network_id"]
                         client.delete_subnet(sn_id, res_id)
                         client.wait_for_resource_deletion(
diff --git a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
index b9b17da..3ead5df 100644
--- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
+++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
@@ -187,8 +187,8 @@
 
         if (force_host_assisted and
                 not CONF.share.run_host_assisted_migration_tests):
-                raise self.skipException("Host-assisted migration tests are "
-                                         "disabled.")
+            raise self.skipException("Host-assisted migration tests are "
+                                     "disabled.")
         elif (not force_host_assisted and
               not CONF.share.run_driver_assisted_migration_tests):
             raise self.skipException("Driver-assisted migration tests are "
diff --git a/test-requirements.txt b/test-requirements.txt
index 337b82e..6a6ab89 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -2,7 +2,7 @@
 # of appearance. Changing the order has an impact on the overall integration
 # process, which may cause wedges in the gate later.
 
-hacking<0.13,>=0.12.0 # Apache-2.0
+hacking>=3.0,<3.1.0;python_version>'3' # Apache-2.0
 
 coverage!=4.4,>=4.0 # Apache-2.0
 python-subunit>=1.0.0 # Apache-2.0/BSD
diff --git a/tox.ini b/tox.ini
index 0218477..59764db 100644
--- a/tox.ini
+++ b/tox.ini
@@ -35,8 +35,9 @@
 
 [flake8]
 # E123, E125 skipped as they are invalid PEP-8.
-
+# W503 line break before binary operator
+# W504 line break after binary operator
 show-source = True
-ignore = E123,E125
+ignore = E123,E125,W503,W504
 builtins = _
 exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build