Skip to content
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
* Refactor tests to use python imports to identify test fixtures. #5699 #5702
Contributed by @cognifloyd

Removed
Expand Down
Empty file added contrib/core/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions contrib/core/fixture.py
Original file line number Diff line number Diff line change
@@ -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__)
9 changes: 7 additions & 2 deletions contrib/core/tests/test_action_sendmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from st2common.constants import action as action_constants

from st2tests.fixtures.packs.core.fixture import PACK_NAME
from st2tests.fixturesloader import FixturesLoader
from st2tests.base import RunnerTestCase
from st2tests.base import CleanDbTestCase
Expand All @@ -38,6 +39,10 @@
MOCK_EXECUTION.id = "598dbf0c0640fd54bffc688b"
HOSTNAME = socket.gethostname()

# we need the core pack to also be in st2tests.fixtures so we can use FixturesLoader()
# The PACK_NAME import tells pants to include that, so use the var here.
FIXTURE_PACK = "packs/" + PACK_NAME


class SendmailActionTestCase(RunnerTestCase, CleanDbTestCase, CleanFilesTestCase):
"""
Expand Down Expand Up @@ -237,11 +242,11 @@ def _run_action(self, action_parameters):
parse the output email data.
"""
models = self.fixtures_loader.load_models(
fixtures_pack="packs/core", fixtures_dict={"actions": ["sendmail.yaml"]}
fixtures_pack=FIXTURE_PACK, fixtures_dict={"actions": ["sendmail.yaml"]}
)
action_db = models["actions"]["sendmail.yaml"]
entry_point = self.fixtures_loader.get_fixture_file_path_abs(
"packs/core", "actions", "send_mail/send_mail"
FIXTURE_PACK, "actions", "send_mail/send_mail"
)

runner = self._get_runner(action_db, entry_point=entry_point)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
from st2common.transport.publishers import CUDPublisher

from st2tests import ExecutionDbTestCase
from st2tests import fixturesloader
from st2tests.fixtures.packs.action_chain_tests.fixture import (
PACK_NAME as TEST_PACK,
PACK_PATH as TEST_PACK_PATH,
)
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_PATH
from st2tests.mocks.liveaction import MockLiveActionPublisherNonBlocking
from six.moves import range

Expand All @@ -45,10 +49,7 @@
"actions": ["test_cancel.yaml", "test_cancel_with_subworkflow.yaml"],
}

TEST_PACK = "action_chain_tests"
TEST_PACK_PATH = fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK

PACKS = [TEST_PACK_PATH, fixturesloader.get_fixtures_packs_base_path() + "/core"]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]

USERNAME = "stanley"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
from st2common.transport.liveaction import LiveActionPublisher
from st2common.transport.publishers import CUDPublisher

from st2tests.fixtures.packs.action_chain_tests.fixture import (
PACK_NAME as TEST_PACK,
PACK_PATH as TEST_PACK_PATH,
)
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_PATH
from st2tests.mocks.liveaction import MockLiveActionPublisherNonBlocking


Expand All @@ -60,10 +65,7 @@ def __init__(self, status=action_constants.LIVEACTION_STATUS_SUCCEEDED, result="
FIXTURES_PACK, "actionchains", "chain_with_notifications.yaml"
)

TEST_PACK = "action_chain_tests"
TEST_PACK_PATH = fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK

PACKS = [TEST_PACK_PATH, fixturesloader.get_fixtures_packs_base_path() + "/core"]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]

MOCK_NOTIFY = {
"on-complete": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
from st2common.util import date as date_utils

from st2tests import ExecutionDbTestCase
from st2tests import fixturesloader
from st2tests.fixtures.packs.action_chain_tests.fixture import (
PACK_NAME as TEST_PACK,
PACK_PATH as TEST_PACK_PATH,
)
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_PATH
from st2tests.mocks.liveaction import MockLiveActionPublisherNonBlocking
from six.moves import range

Expand Down Expand Up @@ -67,10 +71,7 @@
],
}

TEST_PACK = "action_chain_tests"
TEST_PACK_PATH = fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK

PACKS = [TEST_PACK_PATH, fixturesloader.get_fixtures_packs_base_path() + "/core"]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]

USERNAME = "stanley"

Expand Down
12 changes: 3 additions & 9 deletions contrib/runners/orquesta_runner/tests/unit/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,13 @@
from st2common.transport import liveaction as lv_ac_xport
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_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
from st2tests.mocks import workflow as mock_wf_ex_xport


TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]


@mock.patch.object(
Expand Down
12 changes: 3 additions & 9 deletions contrib/runners/orquesta_runner/tests/unit/test_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,13 @@
from st2common.transport import liveaction as lv_ac_xport
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_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
from st2tests.mocks import workflow as mock_wf_ex_xport


TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]


@mock.patch.object(
Expand Down
12 changes: 3 additions & 9 deletions contrib/runners/orquesta_runner/tests/unit/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,12 @@
from st2common.transport import liveaction as lv_ac_xport
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_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
from st2tests.mocks import workflow as mock_wf_ex_xport

TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]


@mock.patch.object(
Expand Down
12 changes: 3 additions & 9 deletions contrib/runners/orquesta_runner/tests/unit/test_data_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,13 @@
from st2common.transport import liveaction as lv_ac_xport
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_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
from st2tests.mocks import workflow as mock_wf_ex_xport


TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]

TEST_1 = "xyz"
TEST_2 = "床前明月光 疑是地上霜 舉頭望明月 低頭思故鄉"
Expand Down
12 changes: 3 additions & 9 deletions contrib/runners/orquesta_runner/tests/unit/test_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,13 @@
from st2common.transport import liveaction as lv_ac_xport
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_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
from st2tests.mocks import workflow as mock_wf_ex_xport


TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]


@mock.patch.object(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,16 @@
from st2common.transport import liveaction as lv_ac_xport
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_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
from st2tests.mocks import workflow as mock_wf_ex_xport
from st2common.models.db.workflow import WorkflowExecutionDB
from st2common.models.db.workflow import TaskExecutionDB
from st2common.models.db.execution_queue import ActionExecutionSchedulingQueueItemDB


TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]

RUNNER_RESULT_FAILED = (
ac_const.LIVEACTION_STATUS_FAILED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,13 @@
from st2common.transport import liveaction as lv_ac_xport
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_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
from st2tests.mocks import workflow as mock_wf_ex_xport


TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]


@mock.patch.object(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,13 @@
from st2common.transport import liveaction as lv_ac_xport
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_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
from st2tests.mocks import workflow as mock_wf_ex_xport


TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]


@mock.patch.object(
Expand Down
12 changes: 3 additions & 9 deletions contrib/runners/orquesta_runner/tests/unit/test_inquiries.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,13 @@
from st2common.transport import liveaction as lv_ac_xport
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_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
from st2tests.mocks import workflow as mock_wf_ex_xport


TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]


@mock.patch.object(
Expand Down
12 changes: 3 additions & 9 deletions contrib/runners/orquesta_runner/tests/unit/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,13 @@
from st2common.transport import liveaction as lv_ac_xport
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_PATH
from st2tests.fixtures.packs.orquesta_tests.fixture import PACK_PATH as TEST_PACK_PATH
from st2tests.mocks import execution as mock_ac_ex_xport
from st2tests.mocks import liveaction as mock_lv_ac_xport
from st2tests.mocks import workflow as mock_wf_ex_xport

TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]

MOCK_NOTIFY = {
"on-complete": {
Expand Down
12 changes: 3 additions & 9 deletions contrib/runners/orquesta_runner/tests/unit/test_output_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,15 @@
from st2common.transport import workflow as wf_ex_xport
from st2common.transport import publishers
from st2common.constants import action as ac_const
from st2tests.fixtures.packs.core.fixture import PACK_PATH as CORE_PACK_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
from st2tests.mocks import workflow as mock_wf_ex_xport
from st2tests.base import RunnerTestCase

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

TEST_PACK = "orquesta_tests"
TEST_PACK_PATH = (
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/" + TEST_PACK
)

PACKS = [
TEST_PACK_PATH,
st2tests.fixturesloader.get_fixtures_packs_base_path() + "/core",
]
PACKS = [TEST_PACK_PATH, CORE_PACK_PATH]

FAIL_SCHEMA = {
"notvalid": {
Expand Down
Loading