From db7a2e30234b078b1ed53084933cd2e9477a3882 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Tue, 6 Aug 2019 13:43:49 +0100 Subject: [PATCH] Add a --modules option to the RE-SQL test suite to allow testing of specific object types. Fixes #4560 --- docs/en_US/release_notes_4_12.rst | 1 + web/pgadmin/utils/route.py | 8 +++++++- web/regression/README | 3 +++ web/regression/re_sql/tests/test_resql.py | 13 ++++++++++--- web/regression/runtests.py | 6 +++++- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/docs/en_US/release_notes_4_12.rst b/docs/en_US/release_notes_4_12.rst index 0e6a12aaa..b71efd47f 100644 --- a/docs/en_US/release_notes_4_12.rst +++ b/docs/en_US/release_notes_4_12.rst @@ -19,6 +19,7 @@ Housekeeping ************ | `Issue #4555 `_ - Add Reverse Engineered SQL tests for Exclusion Constraint. +| `Issue #4560 `_ - Add a --modules option to the RE-SQL test suite to allow testing of specific object types. Bug fixes ********* diff --git a/web/pgadmin/utils/route.py b/web/pgadmin/utils/route.py index 8629dbbdb..6e99c7ed2 100644 --- a/web/pgadmin/utils/route.py +++ b/web/pgadmin/utils/route.py @@ -65,7 +65,8 @@ class TestsGeneratorRegistry(ABCMeta): all_modules.append('regression.re_sql.tests.test_resql') # If specific modules are to be tested, exclude others - if len(for_modules) > 0: + # for modules are handled differently for resql + if not is_resql_only and len(for_modules) > 0: all_modules = [module_name for module_name in all_modules for fmod in for_modules @@ -79,6 +80,7 @@ class TestsGeneratorRegistry(ABCMeta): # Check if only reverse engineered sql test cases to run # if yes then import only that module if is_resql_only: + BaseTestGenerator.setForModules(for_modules) try: import_module('regression.re_sql.tests.test_resql') except ImportError: @@ -147,3 +149,7 @@ class BaseTestGenerator(unittest.TestCase): @classmethod def setExcludePkgs(cls, exclude_pkgs): cls.exclude_pkgs = exclude_pkgs + + @classmethod + def setForModules(cls, for_modules): + cls.for_modules = for_modules diff --git a/web/regression/README b/web/regression/README index fec091e25..abc929aed 100644 --- a/web/regression/README +++ b/web/regression/README @@ -151,6 +151,9 @@ Python Tests: - Execute only reverse engineered sql test framework for all nodes run 'python runtests.py --pkg resql' +- Execute only reverse engineered sql test framework for some modules + run 'python runtests.py --pkg resql --modules sequences,functions' + - Execute test framework for entire package Example 1) Run test framework for 'browser' package diff --git a/web/regression/re_sql/tests/test_resql.py b/web/regression/re_sql/tests/test_resql.py index ee777a6b9..8d8fd3812 100644 --- a/web/regression/re_sql/tests/test_resql.py +++ b/web/regression/re_sql/tests/test_resql.py @@ -22,7 +22,7 @@ from pgadmin.utils.versioned_template_loader import \ get_version_mapping_directories -def create_resql_module_list(all_modules, exclude_pkgs): +def create_resql_module_list(all_modules, exclude_pkgs, for_modules): """ This function is used to create the module list for reverse engineered SQL by iterating all the modules. @@ -41,7 +41,13 @@ def create_resql_module_list(all_modules, exclude_pkgs): module_name_list = complete_module_name[0].split(".") module_name = module_name_list[len(module_name_list) - 1] - resql_module_list[module_name] = os.path.join(*module_name_list) + if len(for_modules) > 0: + if module_name in for_modules: + resql_module_list[module_name] = \ + os.path.join(*module_name_list) + else: + resql_module_list[module_name] = \ + os.path.join(*module_name_list) return resql_module_list @@ -87,7 +93,8 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): resql_module_list = create_resql_module_list( BaseTestGenerator.re_sql_module_list, - BaseTestGenerator.exclude_pkgs) + BaseTestGenerator.exclude_pkgs, + getattr(BaseTestGenerator, 'for_modules', [])) for module in resql_module_list: self.table_id = None diff --git a/web/regression/runtests.py b/web/regression/runtests.py index df94be3a3..540eae65e 100644 --- a/web/regression/runtests.py +++ b/web/regression/runtests.py @@ -253,9 +253,13 @@ def get_test_modules(arguments): if arguments['pkg'] is None or arguments['pkg'] == "all": TestsGeneratorRegistry.load_generators('pgadmin', exclude_pkgs) elif arguments['pkg'] is not None and arguments['pkg'] == "resql": + for_modules = [] + if arguments['modules'] is not None: + for_modules = arguments['modules'].split(',') + # Load the reverse engineering sql test module TestsGeneratorRegistry.load_generators('pgadmin', exclude_pkgs, - is_resql_only=True) + for_modules, is_resql_only=True) else: for_modules = [] if arguments['modules'] is not None: