From 776b590bd6af2517238336a114a2b68332228fb2 Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Thu, 24 Sep 2020 13:18:00 +0700 Subject: [PATCH] Adjust Actions API tests * Some more adjustements to the Actions API tests related to the Action Provider transition. Some tests have to be temporarily disabled because there's no way to make them on both current version of Mistral and the version including action providers. Change-Id: I13033253d5098655a001135c8702d1b1d13e76d4 --- .../tests/api/v2/test_actions.py | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/mistral_tempest_tests/tests/api/v2/test_actions.py b/mistral_tempest_tests/tests/api/v2/test_actions.py index 98a56d1..1ab073b 100644 --- a/mistral_tempest_tests/tests/api/v2/test_actions.py +++ b/mistral_tempest_tests/tests/api/v2/test_actions.py @@ -12,7 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime from tempest.lib import decorators from tempest.lib import exceptions import testtools @@ -199,14 +198,27 @@ class ActionTestsV2(base.TestCase): @decorators.attr(type='smoke') @decorators.idempotent_id('20b3d527-447d-492b-8cb7-ac5e3757d7d5') def test_get_list_actions_greater_than_filter(self): - time = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + resp, body = self.client.create_action('action_v2.yaml') - resp, body = self.client.get_list_obj( - 'actions?created_at=gt:' + time.replace(' ', '%20') - ) + self.assertEqual(201, resp.status) + + # NOTE(rakhmerov): The filter "name=gt:freeting" might seem weird + # but we can use it because Mistral compare alphabetical order + # of action names with filter value. + resp, body = self.client.get_list_obj('actions?name=gt:freeting') self.assertEqual(200, resp.status) - self.assertEmpty(body['actions']) + + # There should be at least "greeting" action in the result set + # and possible some other standard actions whose names go after + # "freeting" in the alphabet order. + self.assertGreater(len(body['actions']), 0) + + # Make sure the "greeting" action is in the result set. + self.assertEqual( + 1, + len([act for act in body['actions'] if act['name'] == 'greeting']) + ) # TODO(rakhmerov): Come up with a good test, we can't use 'created_at' # anymore. @@ -290,8 +302,13 @@ class ActionTestsV2(base.TestCase): self.assertEqual(201, resp.status) + # TODO(rakhmerov): Both filters are temporarily related to the + # field 'name', there's no other suitable field right now to + # to apply a filter to. We could use "&tags=has:hello", for + # example, but it will work only after the Action Provider + # transition is completed, now this filter is broken. resp, body = self.client.get_list_obj( - 'actions?name=in:greeting,farewell&input=name' + 'actions?name=in:greeting,farewell&name=greeting' ) self.assertEqual(200, resp.status) @@ -421,7 +438,8 @@ class ActionTestsV2(base.TestCase): self.assertRaises( exceptions.BadRequest, self.client.update_request, - 'actions', 'wb_v2.yaml' + 'actions', + 'wb_v2.yaml' ) @decorators.attr(type='negative') @@ -430,9 +448,13 @@ class ActionTestsV2(base.TestCase): self.assertRaises( exceptions.NotFound, self.client.delete_obj, - 'actions', 'nonexist' + 'actions', + 'nonexist' ) + # TODO(rakhmerov): Rewrite it after https://review.opendev.org/#/c/746022/ + # is merged. + @testtools.skip('Needs to be rewritten.') @decorators.attr(type='negative') @decorators.idempotent_id('74d0d480-793a-46ca-b88a-8336c1897f3a') def test_delete_standard_action(self):