Merge "Move skipping conditions under skip_checks method"
diff --git a/manila_tempest_tests/tests/api/admin/test_user_messages.py b/manila_tempest_tests/tests/api/admin/test_user_messages.py
index 9d69f90..83c5e37 100644
--- a/manila_tempest_tests/tests/api/admin/test_user_messages.py
+++ b/manila_tempest_tests/tests/api/admin/test_user_messages.py
@@ -124,7 +124,7 @@
         time_1 = created_at_1 - datetime.timedelta(seconds=1)
         time_2 = created_at_2 - datetime.timedelta(seconds=1)
 
-        params1 = {'created_since': str(created_at_1)}
+        params1 = {'created_since': str(time_1)}
         # should return all user messages created by this test including
         # self.message
         messages = self.shares_v2_client.list_messages(params=params1)
@@ -132,6 +132,10 @@
         self.assertGreaterEqual(len(ids), 2)
         self.assertIn(self.message['id'], ids)
         self.assertIn(new_message['id'], ids)
+        for message in messages:
+            time_diff_with_created_since = timeutils.delta_seconds(
+                time_1, timeutils.parse_strtime(message['created_at']))
+            self.assertGreaterEqual(time_diff_with_created_since, 0)
 
         params2 = {'created_since': str(time_1),
                    'created_before': str(time_2)}
@@ -143,6 +147,13 @@
         self.assertGreaterEqual(len(ids), 1)
         self.assertIn(self.message['id'], ids)
         self.assertNotIn(new_message['id'], ids)
+        for message in messages:
+            time_diff_with_created_since = timeutils.delta_seconds(
+                time_1, timeutils.parse_strtime(message['created_at']))
+            time_diff_with_created_before = timeutils.delta_seconds(
+                time_2, timeutils.parse_strtime(message['created_at']))
+            self.assertGreaterEqual(time_diff_with_created_since, 0)
+            self.assertGreaterEqual(0, time_diff_with_created_before)
 
         params3 = {'created_before': str(time_2)}
         # should not include self.message
@@ -151,3 +162,7 @@
         self.assertGreaterEqual(len(ids), 1)
         self.assertNotIn(new_message['id'], ids)
         self.assertIn(self.message['id'], ids)
+        for message in messages:
+            time_diff_with_created_before = timeutils.delta_seconds(
+                time_2, timeutils.parse_strtime(message['created_at']))
+            self.assertGreaterEqual(0, time_diff_with_created_before)
diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py
index c4cf027..23fc4c4 100644
--- a/manila_tempest_tests/tests/scenario/manager_share.py
+++ b/manila_tempest_tests/tests/scenario/manager_share.py
@@ -61,18 +61,14 @@
         super(ShareScenarioTest, cls).skip_checks()
         if not CONF.service_available.manila:
             raise cls.skipException("Manila support is required")
+        if cls.ipv6_enabled and not CONF.share.run_ipv6_tests:
+            raise cls.skipException("IPv6 tests are disabled")
+        if cls.protocol not in CONF.share.enable_protocols:
+            message = "%s tests are disabled" % cls.protocol
+            raise cls.skipException(message)
 
     def setUp(self):
         base.verify_test_has_appropriate_tags(self)
-        if self.ipv6_enabled and not CONF.share.run_ipv6_tests:
-            raise self.skipException("IPv6 tests are disabled")
-        if self.protocol not in CONF.share.enable_protocols:
-            message = "%s tests are disabled" % self.protocol
-            raise self.skipException(message)
-        if self.protocol not in CONF.share.enable_ip_rules_for_protocols:
-            message = ("%s tests for access rules other than IP are disabled" %
-                       self.protocol)
-            raise self.skipException(message)
         super(ShareScenarioTest, self).setUp()
 
         self.image_id = None
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 3ead5df..5603fab 100644
--- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
+++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
@@ -44,6 +44,14 @@
      * Terminate the instance
     """
 
+    @classmethod
+    def skip_checks(cls):
+        super(ShareBasicOpsBase, cls).skip_checks()
+        if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
+            message = ("%s tests for access rules other than IP are disabled" %
+                       cls.protocol)
+            raise cls.skipException(message)
+
     def get_ip_and_version_from_export_location(self, export):
         export = export.replace('[', '').replace(']', '')
         if self.protocol == 'nfs' and ':/' in export:
@@ -116,11 +124,6 @@
     @tc.attr(base.TAG_NEGATIVE, base.TAG_BACKEND)
     def test_write_with_ro_access(self):
         '''Test if an instance with ro access can write on the share.'''
-        if self.protocol.upper() == 'CIFS':
-            msg = ("Skipped for CIFS protocol because RO access is not "
-                   "supported for shares by IP.")
-            raise self.skipException(msg)
-
         test_data = "Some test data to write"
 
         instance = self.boot_instance(wait_until="BUILD")
@@ -289,10 +292,6 @@
     @testtools.skipUnless(
         CONF.share.run_snapshot_tests, "Snapshot tests are disabled.")
     def test_write_data_to_share_created_from_snapshot(self):
-        if self.protocol.upper() == 'CIFS':
-            msg = "Skipped for CIFS protocol because of bug/1649573"
-            raise self.skipException(msg)
-
         # 1 - Create UVM, ok, created
         instance = self.boot_instance(wait_until="BUILD")
 
@@ -377,10 +376,6 @@
     @testtools.skipUnless(CONF.share.run_snapshot_tests,
                           "Snapshot tests are disabled.")
     def test_read_mountable_snapshot(self):
-        if self.protocol.upper() == 'CIFS':
-            msg = "Skipped for CIFS protocol because of bug/1649573"
-            raise self.skipException(msg)
-
         # 1 - Create UVM, ok, created
         instance = self.boot_instance(wait_until="BUILD")
 
@@ -463,6 +458,22 @@
             "sudo mount.cifs \"%s\" %s -o guest" % (location, target_dir)
         )
 
+    @tc.attr(base.TAG_NEGATIVE, base.TAG_BACKEND)
+    def test_write_with_ro_access(self):
+        msg = ("Skipped for CIFS protocol because RO access is not "
+               "supported for shares by IP.")
+        raise self.skipException(msg)
+
+    @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
+    def test_read_mountable_snapshot(self):
+        msg = "Skipped for CIFS protocol because of bug/1649573"
+        raise self.skipException(msg)
+
+    @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
+    def test_write_data_to_share_created_from_snapshot(self):
+        msg = "Skipped for CIFS protocol because of bug/1649573"
+        raise self.skipException(msg)
+
 
 class TestShareBasicOpsNFSIPv6(TestShareBasicOpsNFS):
     ip_version = 6
diff --git a/manila_tempest_tests/tests/scenario/test_share_extend.py b/manila_tempest_tests/tests/scenario/test_share_extend.py
index 446ec25..66d4a87 100644
--- a/manila_tempest_tests/tests/scenario/test_share_extend.py
+++ b/manila_tempest_tests/tests/scenario/test_share_extend.py
@@ -45,6 +45,14 @@
      * Terminate the instance
     """
 
+    @classmethod
+    def skip_checks(cls):
+        super(ShareExtendBase, cls).skip_checks()
+        if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
+            message = ("%s tests for access rules other than IP are disabled" %
+                       cls.protocol)
+            raise cls.skipException(message)
+
     @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
     def test_create_extend_and_write(self):
         default_share_size = CONF.share.share_size
diff --git a/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py b/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py
index 8e93335..d58378c 100644
--- a/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py
+++ b/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py
@@ -51,6 +51,14 @@
      * Terminate the instance
     """
 
+    @classmethod
+    def skip_checks(cls):
+        super(ShareManageUnmanageBase, cls).skip_checks()
+        if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
+            message = ("%s tests for access rules other than IP are disabled" %
+                       cls.protocol)
+            raise cls.skipException(message)
+
     @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
     @testtools.skipUnless(
         CONF.share.run_manage_unmanage_tests,
diff --git a/manila_tempest_tests/tests/scenario/test_share_shrink.py b/manila_tempest_tests/tests/scenario/test_share_shrink.py
index 44882c8..1595fbc 100644
--- a/manila_tempest_tests/tests/scenario/test_share_shrink.py
+++ b/manila_tempest_tests/tests/scenario/test_share_shrink.py
@@ -46,6 +46,14 @@
      * Terminate the instance
     """
 
+    @classmethod
+    def skip_checks(cls):
+        super(ShareShrinkBase, cls).skip_checks()
+        if cls.protocol not in CONF.share.enable_ip_rules_for_protocols:
+            message = ("%s tests for access rules other than IP are disabled" %
+                       cls.protocol)
+            raise cls.skipException(message)
+
     @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
     @testtools.skipUnless(
         CONF.share.run_shrink_tests, 'Shrink share tests are disabled.')