diff --git a/mistral/tests/unit/db/v2/test_sqlalchemy_db_api.py b/mistral/tests/unit/db/v2/test_sqlalchemy_db_api.py index f3a3964f4..cfa530346 100644 --- a/mistral/tests/unit/db/v2/test_sqlalchemy_db_api.py +++ b/mistral/tests/unit/db/v2/test_sqlalchemy_db_api.py @@ -144,6 +144,142 @@ class WorkbookTest(SQLAlchemyTest): self.assertEqual(created0, fetched[0]) self.assertEqual(created1, fetched[1]) + def test_filter_workbooks_by_equal_value(self): + db_api.create_workbook(WORKBOOKS[0]) + + created = db_api.create_workbook(WORKBOOKS[1]) + _filter = filter_utils.create_or_update_filter( + 'name', + created.name, + 'eq' + ) + fetched = db_api.get_workbooks(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created, fetched[0]) + + def test_filter_workbooks_by_not_equal_value(self): + created0 = db_api.create_workbook(WORKBOOKS[0]) + created1 = db_api.create_workbook(WORKBOOKS[1]) + + _filter = filter_utils.create_or_update_filter( + 'name', + created0.name, + 'neq' + ) + + fetched = db_api.get_workbooks(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created1, fetched[0]) + + def test_filter_workbooks_by_greater_than_value(self): + created0 = db_api.create_workbook(WORKBOOKS[0]) + created1 = db_api.create_workbook(WORKBOOKS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + created0['created_at'], + 'gt' + ) + fetched = db_api.get_workbooks(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created1, fetched[0]) + + def test_filter_workbooks_by_greater_than_equal_value(self): + created0 = db_api.create_workbook(WORKBOOKS[0]) + created1 = db_api.create_workbook(WORKBOOKS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + created0['created_at'], + 'gte' + ) + fetched = db_api.get_workbooks(**_filter) + + self.assertEqual(2, len(fetched)) + self.assertEqual(created0, fetched[0]) + self.assertEqual(created1, fetched[1]) + + def test_filter_workbooks_by_less_than_value(self): + created0 = db_api.create_workbook(WORKBOOKS[0]) + created1 = db_api.create_workbook(WORKBOOKS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + created1['created_at'], + 'lt' + ) + fetched = db_api.get_workbooks(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created0, fetched[0]) + + def test_filter_workbooks_by_less_than_equal_value(self): + created0 = db_api.create_workbook(WORKBOOKS[0]) + created1 = db_api.create_workbook(WORKBOOKS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + created1['created_at'], + 'lte' + ) + fetched = db_api.get_workbooks(**_filter) + + self.assertEqual(2, len(fetched)) + self.assertEqual(created0, fetched[0]) + self.assertEqual(created1, fetched[1]) + + def test_filter_workbooks_by_values_in_list(self): + created0 = db_api.create_workbook(WORKBOOKS[0]) + + db_api.create_workbook(WORKBOOKS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + [created0['created_at']], + 'in' + ) + fetched = db_api.get_workbooks(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created0, fetched[0]) + + def test_filter_workbooks_by_values_notin_list(self): + created0 = db_api.create_workbook(WORKBOOKS[0]) + created1 = db_api.create_workbook(WORKBOOKS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + [created0['created_at']], + 'nin' + ) + fetched = db_api.get_workbooks(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created1, fetched[0]) + + def test_filter_workbooks_by_multiple_columns(self): + created0 = db_api.create_workbook(WORKBOOKS[0]) + created1 = db_api.create_workbook(WORKBOOKS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + [created0['created_at'], created1['created_at']], + 'in' + ) + _filter = filter_utils.create_or_update_filter( + 'name', + 'my_workbook2', + 'eq', + _filter + ) + fetched = db_api.get_workbooks(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created1, fetched[0]) + def test_delete_workbook(self): created = db_api.create_workbook(WORKBOOKS[0]) @@ -280,6 +416,142 @@ class WorkflowDefinitionTest(SQLAlchemyTest): self.assertEqual(created, fetched) + def test_filter_workflow_definitions_by_equal_value(self): + db_api.create_workbook(WF_DEFINITIONS[0]) + + created = db_api.create_workflow_definition(WF_DEFINITIONS[1]) + _filter = filter_utils.create_or_update_filter( + 'name', + created.name, + 'eq' + ) + fetched = db_api.get_workflow_definitions(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created, fetched[0]) + + def test_filter_workflow_definition_by_not_equal_valiue(self): + created0 = db_api.create_workflow_definition(WF_DEFINITIONS[0]) + created1 = db_api.create_workflow_definition(WF_DEFINITIONS[1]) + + _filter = filter_utils.create_or_update_filter( + 'name', + created0.name, + 'neq' + ) + + fetched = db_api.get_workflow_definitions(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created1, fetched[0]) + + def test_filter_workflow_definition_by_greater_than_value(self): + created0 = db_api.create_workflow_definition(WF_DEFINITIONS[0]) + created1 = db_api.create_workflow_definition(WF_DEFINITIONS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + created0['created_at'], + 'gt' + ) + fetched = db_api.get_workflow_definitions(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created1, fetched[0]) + + def test_filter_workflow_definition_by_greater_than_equal_value(self): + created0 = db_api.create_workflow_definition(WF_DEFINITIONS[0]) + created1 = db_api.create_workflow_definition(WF_DEFINITIONS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + created0['created_at'], + 'gte' + ) + fetched = db_api.get_workflow_definitions(**_filter) + + self.assertEqual(2, len(fetched)) + self.assertEqual(created0, fetched[0]) + self.assertEqual(created1, fetched[1]) + + def test_filter_workflow_definition_by_less_than_value(self): + created0 = db_api.create_workflow_definition(WF_DEFINITIONS[0]) + created1 = db_api.create_workflow_definition(WF_DEFINITIONS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + created1['created_at'], + 'lt' + ) + fetched = db_api.get_workflow_definitions(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created0, fetched[0]) + + def test_filter_workflow_definition_by_less_than_equal_value(self): + created0 = db_api.create_workflow_definition(WF_DEFINITIONS[0]) + created1 = db_api.create_workflow_definition(WF_DEFINITIONS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + created1['created_at'], + 'lte' + ) + fetched = db_api.get_workflow_definitions(**_filter) + + self.assertEqual(2, len(fetched)) + self.assertEqual(created0, fetched[0]) + self.assertEqual(created1, fetched[1]) + + def test_filter_workflow_definition_by_values_in_list(self): + created0 = db_api.create_workflow_definition(WF_DEFINITIONS[0]) + + db_api.create_workflow_definition(WF_DEFINITIONS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + [created0['created_at']], + 'in' + ) + fetched = db_api.get_workflow_definitions(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created0, fetched[0]) + + def test_filter_workflow_definition_by_values_notin_list(self): + created0 = db_api.create_workflow_definition(WF_DEFINITIONS[0]) + created1 = db_api.create_workflow_definition(WF_DEFINITIONS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + [created0['created_at']], + 'nin' + ) + fetched = db_api.get_workflow_definitions(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created1, fetched[0]) + + def test_filter_workflow_definition_by_multiple_columns(self): + created0 = db_api.create_workflow_definition(WF_DEFINITIONS[0]) + created1 = db_api.create_workflow_definition(WF_DEFINITIONS[1]) + + _filter = filter_utils.create_or_update_filter( + 'created_at', + [created0['created_at'], created1['created_at']], + 'in' + ) + _filter = filter_utils.create_or_update_filter( + 'name', + 'my_wf2', + 'eq', + _filter + ) + fetched = db_api.get_workflow_definitions(**_filter) + + self.assertEqual(1, len(fetched)) + self.assertEqual(created1, fetched[0]) + def test_create_workflow_definition_duplicate_without_auth(self): cfg.CONF.set_default('auth_enable', False, group='pecan') db_api.create_workflow_definition(WF_DEFINITIONS[0]) @@ -630,7 +902,7 @@ class ActionDefinitionTest(SQLAlchemyTest): self.assertEqual(1, len(fetched)) self.assertEqual(created2, fetched[0]) - def test_filter_action_definitions_by_notEqual_value(self): + def test_filter_action_definitions_by_not_equal_value(self): created0 = db_api.create_action_definition(ACTION_DEFINITIONS[0]) created1 = db_api.create_action_definition(ACTION_DEFINITIONS[1]) @@ -647,7 +919,7 @@ class ActionDefinitionTest(SQLAlchemyTest): self.assertEqual(created0, fetched[0]) self.assertEqual(created1, fetched[1]) - def test_filter_action_definitions_by_greaterThan_value(self): + def test_filter_action_definitions_by_greater_than_value(self): created0 = db_api.create_action_definition(ACTION_DEFINITIONS[0]) created1 = db_api.create_action_definition(ACTION_DEFINITIONS[1]) created2 = db_api.create_action_definition(ACTION_DEFINITIONS[2]) @@ -663,7 +935,7 @@ class ActionDefinitionTest(SQLAlchemyTest): self.assertEqual(created1, fetched[0]) self.assertEqual(created2, fetched[1]) - def test_filter_action_definitions_by_greaterThanEqual_value(self): + def test_filter_action_definitions_by_greater_than_equal_value(self): created0 = db_api.create_action_definition(ACTION_DEFINITIONS[0]) created1 = db_api.create_action_definition(ACTION_DEFINITIONS[1]) created2 = db_api.create_action_definition(ACTION_DEFINITIONS[2]) @@ -680,7 +952,7 @@ class ActionDefinitionTest(SQLAlchemyTest): self.assertEqual(created1, fetched[1]) self.assertEqual(created2, fetched[2]) - def test_filter_action_definitions_by_lessThan_value(self): + def test_filter_action_definitions_by_less_than_value(self): created0 = db_api.create_action_definition(ACTION_DEFINITIONS[0]) created1 = db_api.create_action_definition(ACTION_DEFINITIONS[1]) created2 = db_api.create_action_definition(ACTION_DEFINITIONS[2]) @@ -696,7 +968,7 @@ class ActionDefinitionTest(SQLAlchemyTest): self.assertEqual(created0, fetched[0]) self.assertEqual(created1, fetched[1]) - def test_filter_action_definitions_by_lessThanEqual_value(self): + def test_filter_action_definitions_by_less_than_equal_value(self): created0 = db_api.create_action_definition(ACTION_DEFINITIONS[0]) created1 = db_api.create_action_definition(ACTION_DEFINITIONS[1]) created2 = db_api.create_action_definition(ACTION_DEFINITIONS[2]) diff --git a/mistral_tempest_tests/tests/api/v2/test_actions.py b/mistral_tempest_tests/tests/api/v2/test_actions.py index 55374ee9e..a2ef48a72 100644 --- a/mistral_tempest_tests/tests/api/v2/test_actions.py +++ b/mistral_tempest_tests/tests/api/v2/test_actions.py @@ -127,7 +127,7 @@ class ActionTestsV2(base.TestCase): ) @test.attr(type='smoke') - def test_get_list_actions_equalto_filter(self): + def test_get_list_actions_equal_to_filter(self): resp, body = self.client.create_action('action_v2.yaml') self.assertEqual(201, resp.status) @@ -142,7 +142,7 @@ class ActionTestsV2(base.TestCase): self.assertFalse(act['is_system']) @test.attr(type='smoke') - def test_get_list_actions_notEqualto_filter(self): + def test_get_list_actions_not_equal_to_filter(self): resp, body = self.client.create_action('action_v2.yaml') self.assertEqual(201, resp.status) @@ -157,7 +157,7 @@ class ActionTestsV2(base.TestCase): self.assertTrue(act['is_system']) @test.attr(type='smoke') - def test_get_list_actions_inList_filter(self): + def test_get_list_actions_in_list_filter(self): resp, body = self.client.create_action('action_v2.yaml') self.assertEqual(201, resp.status) @@ -173,7 +173,7 @@ class ActionTestsV2(base.TestCase): self.assertListEqual(created_acts, action_names) @test.attr(type='smoke') - def test_get_list_actions_notinList_filter(self): + def test_get_list_actions_not_in_list_filter(self): resp, body = self.client.create_action('action_v2.yaml') self.assertEqual(201, resp.status) @@ -190,7 +190,7 @@ class ActionTestsV2(base.TestCase): self.assertNotIn(act, action_names) @test.attr(type='smoke') - def test_get_list_actions_greaterThan_filter(self): + def test_get_list_actions_greater_than_filter(self): time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") resp, body = self.client.get_list_obj( 'actions?created_at=gt:' + time.replace(' ', '%20') @@ -200,7 +200,7 @@ class ActionTestsV2(base.TestCase): self.assertEqual([], body['actions']) @test.attr(type='smoke') - def test_get_list_actions_greaterThanEqualto_filter(self): + def test_get_list_actions_greater_than_equal_to_filter(self): resp, body = self.client.create_action('action_v2.yaml') self.assertEqual(201, resp.status) @@ -216,7 +216,7 @@ class ActionTestsV2(base.TestCase): self.assertIn(created_acts[0], actions) @test.attr(type='smoke') - def test_get_list_actions_lessThan_filter(self): + def test_get_list_actions_less_than_filter(self): resp, body = self.client.create_action('action_v2.yaml') self.assertEqual(201, resp.status) @@ -232,7 +232,7 @@ class ActionTestsV2(base.TestCase): self.assertNotIn(created_acts[0], actions) @test.attr(type='smoke') - def test_get_list_actions_lessThanEqualto_filter(self): + def test_get_list_actions_less_than_equal_to_filter(self): resp, body = self.client.create_action('action_v2.yaml') self.assertEqual(201, resp.status)