Add function to test user messages query by timestamp
-Updates the user messages tests to test query users messages by timestamp. -Updates the negative user messages tests to test query users messages with invalid time format. Depends-On: I3d94bac4304c236f275abe7ce31432b0e2384247 Change-Id: I7a048c754cb703eebee709e35d379a4c51a80b3a
This commit is contained in:
parent
da28812242
commit
af6f44ad82
|
@ -30,7 +30,7 @@ ShareGroup = [
|
|||
help="The minimum api microversion is configured to be the "
|
||||
"value of the minimum microversion supported by Manila."),
|
||||
cfg.StrOpt("max_api_microversion",
|
||||
default="2.51",
|
||||
default="2.52",
|
||||
help="The maximum api microversion is configured to be the "
|
||||
"value of the latest microversion supported by Manila."),
|
||||
cfg.StrOpt("region",
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from tempest import config
|
||||
|
@ -21,6 +23,7 @@ from manila_tempest_tests import utils
|
|||
CONF = config.CONF
|
||||
|
||||
MICROVERSION = '2.37'
|
||||
QUERY_BY_TIMESTAMP_MICROVERSION = '2.52'
|
||||
MESSAGE_KEYS = (
|
||||
'created_at',
|
||||
'action_id',
|
||||
|
@ -111,3 +114,40 @@ class UserMessageTest(base.BaseSharesAdminTest):
|
|||
self.shares_v2_client.delete_message(self.message['id'])
|
||||
self.shares_v2_client.wait_for_resource_deletion(
|
||||
message_id=self.message['id'])
|
||||
|
||||
@decorators.attr(type=[base.TAG_POSITIVE, base.TAG_API])
|
||||
@base.skip_if_microversion_not_supported(QUERY_BY_TIMESTAMP_MICROVERSION)
|
||||
def test_list_messages_with_since_and_before_filters(self):
|
||||
new_message = self.create_user_message()
|
||||
created_at_1 = timeutils.parse_strtime(self.message['created_at'])
|
||||
created_at_2 = timeutils.parse_strtime(new_message['created_at'])
|
||||
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)}
|
||||
# should return all user messages created by this test including
|
||||
# self.message
|
||||
messages = self.shares_v2_client.list_messages(params=params1)
|
||||
ids = [x['id'] for x in messages]
|
||||
self.assertGreaterEqual(len(ids), 2)
|
||||
self.assertIn(self.message['id'], ids)
|
||||
self.assertIn(new_message['id'], ids)
|
||||
|
||||
params2 = {'created_since': str(time_1),
|
||||
'created_before': str(time_2)}
|
||||
# should not return new_message, but return a list that is equal to 1
|
||||
# and include self.message
|
||||
messages = self.shares_v2_client.list_messages(params=params2)
|
||||
self.assertIsInstance(messages, list)
|
||||
ids = [x['id'] for x in messages]
|
||||
self.assertGreaterEqual(len(ids), 1)
|
||||
self.assertIn(self.message['id'], ids)
|
||||
self.assertNotIn(new_message['id'], ids)
|
||||
|
||||
params3 = {'created_before': str(time_2)}
|
||||
# should not include self.message
|
||||
messages = self.shares_v2_client.list_messages(params=params3)
|
||||
ids = [x['id'] for x in messages]
|
||||
self.assertGreaterEqual(len(ids), 1)
|
||||
self.assertNotIn(new_message['id'], ids)
|
||||
self.assertIn(self.message['id'], ids)
|
||||
|
|
|
@ -21,6 +21,7 @@ from manila_tempest_tests import utils
|
|||
CONF = config.CONF
|
||||
|
||||
MICROVERSION = '2.37'
|
||||
QUERY_BY_TIMESTAMP_MICROVERSION = '2.52'
|
||||
|
||||
|
||||
class UserMessageNegativeTest(base.BaseSharesAdminTest):
|
||||
|
@ -61,3 +62,13 @@ class UserMessageNegativeTest(base.BaseSharesAdminTest):
|
|||
self.assertRaises(lib_exc.NotFound,
|
||||
self.shares_v2_client.delete_message,
|
||||
six.text_type(uuidutils.generate_uuid()))
|
||||
|
||||
@decorators.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
|
||||
@base.skip_if_microversion_not_supported(QUERY_BY_TIMESTAMP_MICROVERSION)
|
||||
def test_list_messages_with_invalid_time_format(self):
|
||||
params_key = ['created_since', 'created_before']
|
||||
for key in params_key:
|
||||
params = {key: 'invalid_time'}
|
||||
self.assertRaises(lib_exc.BadRequest,
|
||||
self.shares_v2_client.list_messages,
|
||||
params=params)
|
||||
|
|
Loading…
Reference in New Issue