diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 51543027d4..ea86d6dfe0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -91,7 +91,7 @@ Changed * Move from udatetime to ciso8601 for date functionality ahead of supporting python3.9 #5692 Contributed by Amanda McGuinness (@amanda11 intive) -* Refactor tests to use python imports to identify test fixtures. #5699 #5702 #5703 +* Refactor tests to use python imports to identify test fixtures. #5699 #5702 #5703 #5704 Contributed by @cognifloyd Removed diff --git a/contrib/runners/python_runner/tests/unit/test_pythonrunner.py b/contrib/runners/python_runner/tests/unit/test_pythonrunner.py index 940d087af6..a9699f1df9 100644 --- a/contrib/runners/python_runner/tests/unit/test_pythonrunner.py +++ b/contrib/runners/python_runner/tests/unit/test_pythonrunner.py @@ -42,6 +42,11 @@ from st2tests.base import CleanDbTestCase from st2tests.base import blocking_eventlet_spawn from st2tests.base import make_mock_stream_readline +from st2tests.fixtures.packs.dummy_pack_9.fixture import PACK_PATH as DUMMY_PACK_9_PATH +from st2tests.fixtures.packs.test_content_version_fixture.fixture import ( + PACK_NAME as TEST_CONTENT_VERSION, + PACK_PATH as TEST_CONTENT_VERSION_PATH, +) from st2tests.fixturesloader import assert_submodules_are_checked_out import st2tests.base as tests_base @@ -58,25 +63,18 @@ PATHS_ACTION_PATH = os.path.join( tests_base.get_resources_path(), "packs", "pythonactions/actions/python_paths.py" ) -ACTION_1_PATH = os.path.join( - tests_base.get_fixtures_path(), - "packs/dummy_pack_9/actions/list_repos_doesnt_exist.py", -) -ACTION_2_PATH = os.path.join( - tests_base.get_fixtures_path(), "packs/dummy_pack_9/actions/invalid_syntax.py" -) +ACTION_1_PATH = os.path.join(DUMMY_PACK_9_PATH, "actions/list_repos_doesnt_exist.py") +ACTION_2_PATH = os.path.join(DUMMY_PACK_9_PATH, "actions/invalid_syntax.py") NON_SIMPLE_TYPE_ACTION = os.path.join( tests_base.get_resources_path(), "packs", "pythonactions/actions/non_simple_type.py" ) PRINT_VERSION_ACTION = os.path.join( - tests_base.get_fixtures_path(), - "packs", - "test_content_version/actions/print_version.py", + TEST_CONTENT_VERSION_PATH, + "actions/print_version.py", ) PRINT_VERSION_LOCAL_MODULE_ACTION = os.path.join( - tests_base.get_fixtures_path(), - "packs", - "test_content_version/actions/print_version_local_import.py", + TEST_CONTENT_VERSION_PATH, + "actions/print_version_local_import.py", ) PRINT_CONFIG_ITEM_ACTION = os.path.join( @@ -894,7 +892,7 @@ def test_content_version_success(self, mock_get_sandbox_virtualenv_path): mock_get_sandbox_virtualenv_path.return_value = None # 1. valid version - 0.2.0 - runner = self._get_mock_runner_obj(pack="test_content_version", sandbox=False) + runner = self._get_mock_runner_obj(pack=TEST_CONTENT_VERSION, sandbox=False) runner.entry_point = PRINT_VERSION_ACTION runner.runner_parameters = {"content_version": "v0.2.0"} runner.pre_run() @@ -906,7 +904,7 @@ def test_content_version_success(self, mock_get_sandbox_virtualenv_path): self.assertEqual(output["stdout"].strip(), "v0.2.0") # 2. valid version - 0.23.0 - runner = self._get_mock_runner_obj(pack="test_content_version", sandbox=False) + runner = self._get_mock_runner_obj(pack=TEST_CONTENT_VERSION, sandbox=False) runner.entry_point = PRINT_VERSION_ACTION runner.runner_parameters = {"content_version": "v0.3.0"} runner.pre_run() @@ -918,7 +916,7 @@ def test_content_version_success(self, mock_get_sandbox_virtualenv_path): self.assertEqual(output["stdout"].strip(), "v0.3.0") # 3. invalid version = 0.30.0 - runner = self._get_mock_runner_obj(pack="test_content_version", sandbox=False) + runner = self._get_mock_runner_obj(pack=TEST_CONTENT_VERSION, sandbox=False) runner.entry_point = PRINT_VERSION_ACTION runner.runner_parameters = {"content_version": "v0.30.0"} @@ -942,7 +940,7 @@ def test_content_version_contains_common_libs_config_enabled( mock_process.communicate.return_value = ("", "") mock_popen.return_value = mock_process - runner = self._get_mock_runner_obj(pack="test_content_version", sandbox=False) + runner = self._get_mock_runner_obj(pack=TEST_CONTENT_VERSION, sandbox=False) runner._enable_common_pack_libs = True runner.auth_token = mock.Mock() runner.auth_token.token = "ponies" @@ -964,7 +962,7 @@ def test_content_version_success_local_modules_work_fine( # Verify that local module import correctly use git worktree directory mock_get_sandbox_virtualenv_path.return_value = None - runner = self._get_mock_runner_obj(pack="test_content_version", sandbox=False) + runner = self._get_mock_runner_obj(pack=TEST_CONTENT_VERSION, sandbox=False) runner.entry_point = PRINT_VERSION_LOCAL_MODULE_ACTION runner.runner_parameters = {"content_version": "v0.2.0"} runner.pre_run() diff --git a/st2api/tests/unit/controllers/v1/test_packs.py b/st2api/tests/unit/controllers/v1/test_packs.py index 5b89d67361..a6771c6c92 100644 --- a/st2api/tests/unit/controllers/v1/test_packs.py +++ b/st2api/tests/unit/controllers/v1/test_packs.py @@ -35,7 +35,7 @@ PACK_PATH as DUMMY_PACK_1_PATH, ) from st2tests.fixtures.packs.dummy_pack_10.fixture import ( - PACK_NAME as DUMMY_PACK_10, + PACK_DIR_NAME as DUMMY_PACK_10, PACK_PATH as DUMMY_PACK_10_PATH, ) from st2tests.fixtures.packs.dummy_pack_15.fixture import ( diff --git a/st2api/tests/unit/controllers/v1/test_packs_views.py b/st2api/tests/unit/controllers/v1/test_packs_views.py index a1b96a4aea..d5fed094db 100644 --- a/st2api/tests/unit/controllers/v1/test_packs_views.py +++ b/st2api/tests/unit/controllers/v1/test_packs_views.py @@ -133,8 +133,8 @@ def test_get_pack_files_and_pack_file_ref_doesnt_equal_pack_name(self): # Ref is not equal to the name, controller should still work resp = self.app.get("/v1/packs/views/files/dummy_pack_16") self.assertEqual(resp.status_int, http_client.OK) - self.assertEqual(len(resp.json), 1) - self.assertEqual(resp.json[0]["file_path"], "pack.yaml") + self.assertEqual(len(resp.json), 3) + self.assertIn("pack.yaml", [f["file_path"] for f in resp.json]) resp = self.app.get("/v1/packs/views/file/dummy_pack_16/pack.yaml") self.assertEqual(resp.status_int, http_client.OK) diff --git a/st2common/tests/unit/services/test_workflow.py b/st2common/tests/unit/services/test_workflow.py index 11b082f092..bcce91af00 100644 --- a/st2common/tests/unit/services/test_workflow.py +++ b/st2common/tests/unit/services/test_workflow.py @@ -42,13 +42,14 @@ from st2common.transport import liveaction as lv_ac_xport from st2common.transport import publishers from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_PATH +from st2tests.fixtures.packs.dummy_pack_7.fixture import ( + PACK_DIR_NAME as PACK_7, + PACK_PATH as PACK_7_PATH, +) from st2tests.fixtures.packs.orquesta_tests.fixture import PACK_PATH as TEST_PACK_PATH from st2tests.mocks import liveaction as mock_lv_ac_xport -PACK_7 = "dummy_pack_7" -PACK_7_PATH = st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + PACK_7 - PACKS = [TEST_PACK_PATH, PACK_7_PATH, CORE_PACK_PATH] diff --git a/st2common/tests/unit/test_config_loader.py b/st2common/tests/unit/test_config_loader.py index aa8a5b00fb..c123d52db2 100644 --- a/st2common/tests/unit/test_config_loader.py +++ b/st2common/tests/unit/test_config_loader.py @@ -28,7 +28,7 @@ from st2tests.fixtures.packs.dummy_pack_1.fixture import PACK_NAME as DUMMY_PACK_1 from st2tests.fixtures.packs.dummy_pack_4.fixture import PACK_NAME as DUMMY_PACK_4 from st2tests.fixtures.packs.dummy_pack_5.fixture import PACK_NAME as DUMMY_PACK_5 -from st2tests.fixtures.packs.dummy_pack_17.fixture import PACK_NAME as DUMMY_PACK_17 +from st2tests.fixtures.packs.dummy_pack_17.fixture import PACK_DIR_NAME as DUMMY_PACK_17 from st2tests.fixtures.packs.dummy_pack_schema_with_additional_items_1.fixture import ( PACK_NAME as DUMMY_PACK_SCHEMA_WITH_ADDITIONAL_ITEMS_1, ) diff --git a/st2common/tests/unit/test_config_parser.py b/st2common/tests/unit/test_config_parser.py index fde0385369..883ee66260 100644 --- a/st2common/tests/unit/test_config_parser.py +++ b/st2common/tests/unit/test_config_parser.py @@ -19,6 +19,9 @@ from st2common.util.config_parser import ContentPackConfigParser import st2tests.config as tests_config +from st2tests.fixtures.packs.dummy_pack_1.fixture import PACK_NAME as DUMMY_PACK_1 +from st2tests.fixtures.packs.dummy_pack_2.fixture import PACK_NAME as DUMMY_PACK_2 +from st2tests.fixtures.packs.dummy_pack_18.fixture import PACK_DIR_NAME as DUMMY_PACK_18 class ContentPackConfigParserTestCase(TestCase): @@ -32,14 +35,14 @@ def test_get_config_inexistent_pack(self): self.assertEqual(config, None) def test_get_config_no_config(self): - pack_name = "dummy_pack_1" + pack_name = DUMMY_PACK_1 parser = ContentPackConfigParser(pack_name=pack_name) config = parser.get_config() self.assertEqual(config, None) def test_get_config_existing_config(self): - pack_name = "dummy_pack_2" + pack_name = DUMMY_PACK_2 parser = ContentPackConfigParser(pack_name=pack_name) config = parser.get_config() @@ -47,7 +50,7 @@ def test_get_config_existing_config(self): self.assertEqual(config.config["section2"]["key10"], "value10") def test_get_config_for_unicode_char(self): - pack_name = "dummy_pack_18" + pack_name = DUMMY_PACK_18 parser = ContentPackConfigParser(pack_name=pack_name) config = parser.get_config() self.assertEqual(config.config["section1"]["key1"], "测试") diff --git a/st2common/tests/unit/test_pack_action_alias_unit_testing_utils.py b/st2common/tests/unit/test_pack_action_alias_unit_testing_utils.py index 630b14ed37..18251fb947 100644 --- a/st2common/tests/unit/test_pack_action_alias_unit_testing_utils.py +++ b/st2common/tests/unit/test_pack_action_alias_unit_testing_utils.py @@ -14,21 +14,19 @@ # limitations under the License. from __future__ import absolute_import -import os import mock from st2tests.base import BaseActionAliasTestCase -from st2tests.fixturesloader import get_fixtures_base_path +from st2tests.fixtures.packs.pack_dir_name_doesnt_match_ref.fixture import ( + PACK_NAME as PACK_NAME_NOT_THE_SAME_AS_DIR_NAME, + PACK_PATH as PACK_PATH_1, +) from st2common.exceptions.content import ParseException from st2common.models.db.actionalias import ActionAliasDB __all__ = ["PackActionAliasUnitTestUtils"] -PACK_PATH_1 = os.path.join( - get_fixtures_base_path(), "packs/pack_dir_name_doesnt_match_ref" -) - class PackActionAliasUnitTestUtils(BaseActionAliasTestCase): action_alias_name = "mock" @@ -119,7 +117,7 @@ def test_base_class_works_when_pack_directory_name_doesnt_match_pack_name(self): action_alias_db = self._get_action_alias_db_by_name(name="alias1") self.assertEqual(action_alias_db.name, "alias1") - self.assertEqual(action_alias_db.pack, "pack_name_not_the_same_as_dir_name") + self.assertEqual(action_alias_db.pack, PACK_NAME_NOT_THE_SAME_AS_DIR_NAME) # Note: We mock the original method to make testing of all the edge cases easier def _get_action_alias_db_by_name(self, name): diff --git a/st2common/tests/unit/test_resource_registrar.py b/st2common/tests/unit/test_resource_registrar.py index cf619cd983..b03cf7f645 100644 --- a/st2common/tests/unit/test_resource_registrar.py +++ b/st2common/tests/unit/test_resource_registrar.py @@ -15,8 +15,6 @@ from __future__ import absolute_import -import os - import six import mock from jsonschema import ValidationError @@ -27,7 +25,6 @@ from st2common.persistence.pack import ConfigSchema from st2tests.base import CleanDbTestCase -from st2tests.fixturesloader import get_fixtures_base_path from st2tests.fixtures.packs.dummy_pack_1.fixture import ( PACK_NAME as DUMMY_PACK_1, PACK_PATH as PACK_PATH_1, @@ -36,7 +33,16 @@ PACK_NAME as DUMMY_PACK_6, PACK_PATH as PACK_PATH_6, ) +from st2tests.fixtures.packs.dummy_pack_7.fixture import ( + PACK_NAME as DUMMY_PACK_7_NAME, + PACK_PATH as PACK_PATH_7, +) from st2tests.fixtures.packs.dummy_pack_8.fixture import PACK_PATH as PACK_PATH_8 +from st2tests.fixtures.packs.dummy_pack_9.fixture import ( + PACK_DIR_NAME as DUMMY_PACK_9, + PACK_NAME as DUMMY_PACK_9_DEPS, + PACK_PATH as PACK_PATH_9, +) from st2tests.fixtures.packs.dummy_pack_10.fixture import PACK_PATH as PACK_PATH_10 from st2tests.fixtures.packs.dummy_pack_13.fixture import PACK_PATH as PACK_PATH_13 from st2tests.fixtures.packs.dummy_pack_14.fixture import PACK_PATH as PACK_PATH_14 @@ -64,9 +70,6 @@ __all__ = ["ResourceRegistrarTestCase"] -PACK_PATH_7 = os.path.join(get_fixtures_base_path(), "packs/dummy_pack_7") -PACK_PATH_9 = os.path.join(get_fixtures_base_path(), "packs/dummy_pack_9") - class ResourceRegistrarTestCase(CleanDbTestCase): def test_register_packs(self): @@ -156,8 +159,8 @@ def test_register_pack_pack_ref(self): # "ref" is not provided, but "name" is registrar._register_pack_db(pack_name=None, pack_dir=PACK_PATH_7) - pack_db = Pack.get_by_name("dummy_pack_7_name") - self.assertEqual(pack_db.ref, "dummy_pack_7_name") + pack_db = Pack.get_by_name(DUMMY_PACK_7_NAME) + self.assertEqual(pack_db.ref, DUMMY_PACK_7_NAME) # "ref" is not provided and "name" contains invalid characters expected_msg = "contains invalid characters" @@ -214,12 +217,12 @@ def test_register_pack_pack_stackstorm_version_and_future_parameters(self): registrar = ResourceRegistrar(use_pack_cache=False) registrar._pack_loader.get_packs = mock.Mock() - registrar._pack_loader.get_packs.return_value = {"dummy_pack_9": PACK_PATH_9} + registrar._pack_loader.get_packs.return_value = {DUMMY_PACK_9: PACK_PATH_9} packs_base_paths = content_utils.get_packs_base_paths() registrar.register_packs(base_dirs=packs_base_paths) # Dependencies, stackstorm_version and future values - pack_db = Pack.get_by_name("dummy_pack_9_deps") + pack_db = Pack.get_by_name(DUMMY_PACK_9_DEPS) self.assertEqual(pack_db.dependencies, ["core=0.2.0"]) self.assertEqual(pack_db.stackstorm_version, ">=1.6.0, <2.2.0") self.assertEqual(pack_db.system, {"centos": {"foo": ">= 1.0"}}) diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_10/fixture.py b/st2tests/st2tests/fixtures/packs/dummy_pack_10/fixture.py index 50c698989e..8d9b8115cf 100644 --- a/st2tests/st2tests/fixtures/packs/dummy_pack_10/fixture.py +++ b/st2tests/st2tests/fixtures/packs/dummy_pack_10/fixture.py @@ -13,4 +13,5 @@ # limitations under the License. from st2tests import fixturesloader -PACK_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) +PACK_NAME = "dummy_pack_10_wrong_deps" +PACK_DIR_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_14/fixture.py b/st2tests/st2tests/fixtures/packs/dummy_pack_14/fixture.py index 50c698989e..d53646fa26 100644 --- a/st2tests/st2tests/fixtures/packs/dummy_pack_14/fixture.py +++ b/st2tests/st2tests/fixtures/packs/dummy_pack_14/fixture.py @@ -13,4 +13,5 @@ # limitations under the License. from st2tests import fixturesloader -PACK_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) +PACK_NAME = "dummy pack 14" +PACK_DIR_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_16/__init__.py b/st2tests/st2tests/fixtures/packs/dummy_pack_16/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_16/fixture.py b/st2tests/st2tests/fixtures/packs/dummy_pack_16/fixture.py new file mode 100644 index 0000000000..50c698989e --- /dev/null +++ b/st2tests/st2tests/fixtures/packs/dummy_pack_16/fixture.py @@ -0,0 +1,16 @@ +# Copyright 2022 The StackStorm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from st2tests import fixturesloader + +PACK_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_17/fixture.py b/st2tests/st2tests/fixtures/packs/dummy_pack_17/fixture.py index 50c698989e..4374ad48df 100644 --- a/st2tests/st2tests/fixtures/packs/dummy_pack_17/fixture.py +++ b/st2tests/st2tests/fixtures/packs/dummy_pack_17/fixture.py @@ -13,4 +13,5 @@ # limitations under the License. from st2tests import fixturesloader -PACK_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) +PACK_NAME = "Dummy Pack 17" +PACK_DIR_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_18/fixture.py b/st2tests/st2tests/fixtures/packs/dummy_pack_18/fixture.py index 50c698989e..228c707687 100644 --- a/st2tests/st2tests/fixtures/packs/dummy_pack_18/fixture.py +++ b/st2tests/st2tests/fixtures/packs/dummy_pack_18/fixture.py @@ -13,4 +13,5 @@ # limitations under the License. from st2tests import fixturesloader -PACK_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) +PACK_NAME = "Dummy Pack 18" +PACK_DIR_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_7/__init__.py b/st2tests/st2tests/fixtures/packs/dummy_pack_7/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_7/fixture.py b/st2tests/st2tests/fixtures/packs/dummy_pack_7/fixture.py new file mode 100644 index 0000000000..991ae8c8e5 --- /dev/null +++ b/st2tests/st2tests/fixtures/packs/dummy_pack_7/fixture.py @@ -0,0 +1,17 @@ +# Copyright 2022 The StackStorm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from st2tests import fixturesloader + +PACK_NAME = "dummy_pack_7_name" +PACK_DIR_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_8/fixture.py b/st2tests/st2tests/fixtures/packs/dummy_pack_8/fixture.py index 50c698989e..9c303aadb4 100644 --- a/st2tests/st2tests/fixtures/packs/dummy_pack_8/fixture.py +++ b/st2tests/st2tests/fixtures/packs/dummy_pack_8/fixture.py @@ -13,4 +13,5 @@ # limitations under the License. from st2tests import fixturesloader -PACK_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) +PACK_NAME = "Dummy Pack 8 Invalid Name" +PACK_DIR_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_9/__init__.py b/st2tests/st2tests/fixtures/packs/dummy_pack_9/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/st2tests/st2tests/fixtures/packs/dummy_pack_9/fixture.py b/st2tests/st2tests/fixtures/packs/dummy_pack_9/fixture.py new file mode 100644 index 0000000000..d59bd3ae8c --- /dev/null +++ b/st2tests/st2tests/fixtures/packs/dummy_pack_9/fixture.py @@ -0,0 +1,17 @@ +# Copyright 2022 The StackStorm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from st2tests import fixturesloader + +PACK_NAME = "dummy_pack_9_deps" +PACK_DIR_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) diff --git a/st2tests/st2tests/fixtures/packs/pack_dir_name_doesnt_match_ref/__init__.py b/st2tests/st2tests/fixtures/packs/pack_dir_name_doesnt_match_ref/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/st2tests/st2tests/fixtures/packs/pack_dir_name_doesnt_match_ref/fixture.py b/st2tests/st2tests/fixtures/packs/pack_dir_name_doesnt_match_ref/fixture.py new file mode 100644 index 0000000000..b0004fe774 --- /dev/null +++ b/st2tests/st2tests/fixtures/packs/pack_dir_name_doesnt_match_ref/fixture.py @@ -0,0 +1,17 @@ +# Copyright 2022 The StackStorm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from st2tests import fixturesloader + +PACK_NAME = "pack_name_not_the_same_as_dir_name" +PACK_DIR_NAME, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) diff --git a/st2tests/st2tests/fixtures/packs/test_content_version_fixture/__init__.py b/st2tests/st2tests/fixtures/packs/test_content_version_fixture/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/st2tests/st2tests/fixtures/packs/test_content_version_fixture/fixture.py b/st2tests/st2tests/fixtures/packs/test_content_version_fixture/fixture.py new file mode 100644 index 0000000000..df86ee5e16 --- /dev/null +++ b/st2tests/st2tests/fixtures/packs/test_content_version_fixture/fixture.py @@ -0,0 +1,18 @@ +# Copyright 2022 The StackStorm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from st2tests import fixturesloader + +PACK_NAME = "test_content_version" +_, PACK_PATH = fixturesloader.get_fixture_name_and_path(__file__) +PACK_PATH = PACK_PATH[: -len("_fixture")] diff --git a/st2tests/st2tests/fixturesloader.py b/st2tests/st2tests/fixturesloader.py index bf7f826034..dfd9d4efcd 100644 --- a/st2tests/st2tests/fixturesloader.py +++ b/st2tests/st2tests/fixturesloader.py @@ -444,8 +444,10 @@ def assert_submodules_are_checked_out(): root of the directory and that the "st2tests/st2tests/fixtures/packs/test" git repo submodule used by the tests is checked out. """ - pack_path = os.path.join(get_fixtures_packs_base_path(), "test_content_version/") - pack_path = os.path.abspath(pack_path) + # late import to prevent circular import + from st2tests.fixtures.packs.test_content_version_fixture.fixture import PACK_PATH + + pack_path = os.path.abspath(PACK_PATH) submodule_git_dir_or_file_path = os.path.join(pack_path, ".git") # NOTE: In newer versions of git, that .git is a file and not a directory