Skip to content

Commit

Permalink
python runner test depends on dummy_pack_5
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd committed Sep 14, 2024
1 parent 8321a8a commit b9330c6
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions contrib/runners/python_runner/tests/unit/test_pythonrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from st2tests.base import blocking_eventlet_spawn
from st2tests.base import make_mock_stream_readline
from st2tests.fixtures.packs.dummy_pack_1.fixture import PACK_NAME as DUMMY_PACK_1
from st2tests.fixtures.packs.dummy_pack_5.fixture import PACK_NAME as DUMMY_PACK_5
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,
Expand Down Expand Up @@ -232,32 +233,30 @@ def test_simple_action_no_status_backward_compatibility(self):
self.assertEqual(output["result"], [1, 2])

def test_simple_action_config_value_provided_overriden_in_datastore(self):
pack = "dummy_pack_5"
user = "joe"

# No values provided in the datastore
runner = self._get_mock_runner_obj_from_container(pack=pack, user=user)

runner = self._get_mock_runner_obj_from_container(pack=DUMMY_PACK_5, user=user)
self.assertEqual(runner._config["api_key"], "some_api_key") # static value
self.assertEqual(runner._config["regions"], ["us-west-1"]) # static value
self.assertEqual(runner._config["api_secret"], None)
self.assertEqual(runner._config["private_key_path"], None)

# api_secret overriden in the datastore (user scoped value)
config_service.set_datastore_value_for_config_key(
pack_name="dummy_pack_5",
pack_name=DUMMY_PACK_5,
key_name="api_secret",
user="joe",
user=user,
value="foosecret",
secret=True,
)

# private_key_path overriden in the datastore (global / non-user scoped value)
config_service.set_datastore_value_for_config_key(
pack_name="dummy_pack_5", key_name="private_key_path", value="foopath"
pack_name=DUMMY_PACK_5, key_name="private_key_path", value="foopath"
)

runner = self._get_mock_runner_obj_from_container(pack=pack, user=user)
runner = self._get_mock_runner_obj_from_container(pack=DUMMY_PACK_5, user=user)
self.assertEqual(runner._config["api_key"], "some_api_key") # static value
self.assertEqual(runner._config["regions"], ["us-west-1"]) # static value
self.assertEqual(runner._config["api_secret"], "foosecret")
Expand Down Expand Up @@ -717,7 +716,7 @@ def test_python_action_wrapper_script_doesnt_get_added_to_sys_path(self):
def test_python_action_wrapper_action_script_file_doesnt_exist_friendly_error(self):
# File in a directory which is not a Python package
wrapper = PythonActionWrapper(
pack="dummy_pack_5", file_path="/tmp/doesnt.exist", user="joe"
pack=DUMMY_PACK_5, file_path="/tmp/doesnt.exist", user="joe"
)

expected_msg = (
Expand All @@ -727,7 +726,7 @@ def test_python_action_wrapper_action_script_file_doesnt_exist_friendly_error(se

# File in a directory which is a Python package
wrapper = PythonActionWrapper(
pack="dummy_pack_5", file_path=ACTION_1_PATH, user="joe"
pack=DUMMY_PACK_5, file_path=ACTION_1_PATH, user="joe"
)

expected_msg = (
Expand All @@ -741,7 +740,7 @@ def test_python_action_wrapper_action_script_file_contains_invalid_syntax_friend
self,
):
wrapper = PythonActionWrapper(
pack="dummy_pack_5", file_path=ACTION_2_PATH, user="joe"
pack=DUMMY_PACK_5, file_path=ACTION_2_PATH, user="joe"
)
expected_msg = (
r'Failed to load action class from file ".*?invalid_syntax.py" '
Expand Down

0 comments on commit b9330c6

Please sign in to comment.