Skip to content

Commit 4e9511b

Browse files
authored
Merge pull request #5705: Use python imports to identify fixtures (part 5/6)
2 parents 8acbd31 + bc952a5 commit 4e9511b

File tree

23 files changed

+123
-24
lines changed

23 files changed

+123
-24
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Changed
9191
* Move from udatetime to ciso8601 for date functionality ahead of supporting python3.9 #5692
9292
Contributed by Amanda McGuinness (@amanda11 intive)
9393

94-
* Refactor tests to use python imports to identify test fixtures. #5699 #5702 #5703 #5704
94+
* Refactor tests to use python imports to identify test fixtures. #5699 #5702 #5703 #5704 #5705
9595
Contributed by @cognifloyd
9696

9797
Removed

contrib/packs/tests/__init__.py

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2022 The StackStorm Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
import os
15+
16+
FIXTURES_DIR = os.path.dirname(os.path.abspath(__file__))

contrib/packs/tests/test_action_download.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737

3838
from pack_mgmt.download import DownloadGitRepoAction
3939

40-
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
40+
# this import allows pants to detect that the fixtures are used in this file
41+
from .fixtures import FIXTURES_DIR
4142

4243
PACK_INDEX = {
4344
"test": {
@@ -639,7 +640,7 @@ def test_run_pack_dowload_local_git_repo_detached_head_state(self):
639640
side_effect=TypeError("detached head")
640641
)
641642

642-
pack_path = os.path.join(BASE_DIR, "fixtures/stackstorm-test")
643+
pack_path = os.path.join(FIXTURES_DIR, "stackstorm-test")
643644

644645
result = action.run(
645646
packs=["file://%s" % (pack_path)], abs_repo_base=self.repo_base
@@ -665,7 +666,7 @@ def test_run_pack_download_local_directory(self):
665666
)
666667

667668
# 2. Local pack which is not a git repository
668-
pack_path = os.path.join(BASE_DIR, "fixtures/stackstorm-test4")
669+
pack_path = os.path.join(FIXTURES_DIR, "stackstorm-test4")
669670

670671
result = action.run(
671672
packs=["file://%s" % (pack_path)], abs_repo_base=self.repo_base

st2common/tests/fixtures/__init__.py

Whitespace-only changes.

st2common/tests/fixtures/local_runner/__init__.py

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2022 The StackStorm Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
import os
15+
16+
FIXTURE_DIR = os.path.abspath(os.path.dirname(__file__))

st2common/tests/integration/log_unicode_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from st2common import log as logging
4242
from st2common.service_setup import setup as common_setup
4343

44+
# Do not use helpers from st2tests to calculate this (avoid extra imports).
4445
FIXTURES_DIR = os.path.join(ST2TESTS_PATH, "st2tests/fixtures")
4546
ST2_CONFIG_DEBUG_LL_PATH = os.path.join(
4647
FIXTURES_DIR, "conf/st2.tests.api.debug_log_level.conf"

st2common/tests/integration/test_rabbitmq_ssl_listener.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525

2626
from st2common.transport import utils as transport_utils
2727

28-
from st2tests.fixturesloader import get_fixtures_base_path
28+
from st2tests.fixtures.ssl_certs.fixture import FIXTURE_PATH as CERTS_FIXTURES_PATH
2929

3030
__all__ = ["RabbitMQTLSListenerTestCase"]
3131

32-
CERTS_FIXTURES_PATH = os.path.join(get_fixtures_base_path(), "ssl_certs/")
3332
ST2_CI = os.environ.get("ST2_CI", "false").lower() == "true"
3433

3534
NON_SSL_LISTENER_PORT = 5672

st2common/tests/integration/test_register_content_script.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
# import this so that pants can infer dependencies for the glob below
2828
from st2tests.fixtures.packs.dummy_pack_1.fixture import PACK_PATH as DUMMY_PACK_1_PATH
2929
from st2tests.fixtures.packs.dummy_pack_4.fixture import PACK_PATH as DUMMY_PACK_4_PATH
30+
from st2tests.fixtures.packs.runners.fixture import FIXTURE_PATH as RUNNER_DIRS
3031
from st2tests.fixtures.packs_1.dummy_pack_4.fixture import PACK_PATH as EMPTY_PACK_PATH
3132

3233

@@ -49,7 +50,7 @@ def setUp(self):
4950

5051
def test_register_from_pack_success(self):
5152
pack_dir = DUMMY_PACK_1_PATH
52-
runner_dirs = os.path.join(get_fixtures_packs_base_path(), "runners")
53+
runner_dirs = RUNNER_DIRS
5354

5455
opts = [
5556
"--register-pack=%s" % (pack_dir),
@@ -63,7 +64,7 @@ def test_register_from_pack_success(self):
6364
def test_register_from_pack_fail_on_failure_pack_dir_doesnt_exist(self):
6465
# No fail on failure flag, should succeed
6566
pack_dir = "doesntexistblah"
66-
runner_dirs = os.path.join(get_fixtures_packs_base_path(), "runners")
67+
runner_dirs = RUNNER_DIRS
6768

6869
opts = [
6970
"--register-pack=%s" % (pack_dir),
@@ -88,7 +89,7 @@ def test_register_from_pack_fail_on_failure_pack_dir_doesnt_exist(self):
8889
def test_register_from_pack_action_metadata_fails_validation(self):
8990
# No fail on failure flag, should succeed
9091
pack_dir = DUMMY_PACK_4_PATH
91-
runner_dirs = os.path.join(get_fixtures_packs_base_path(), "runners")
92+
runner_dirs = RUNNER_DIRS
9293

9394
opts = [
9495
"--register-pack=%s" % (pack_dir),

0 commit comments

Comments
 (0)