Skip to content

Commit

Permalink
fix: minor changes and fixing typos
Browse files Browse the repository at this point in the history
Signed-off-by: Ting Cheng <36546476+tincheng@users.noreply.github.com>
  • Loading branch information
tincheng committed Sep 18, 2023
1 parent 25910d2 commit 36af21e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 442 deletions.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ parallel = true
omit = [
"**/__main__.py",
"**/_version.py",
"*/deadline/nuke_submitter/ui/*"
"*/deadline/nuke_submitter/ui/*",
# The submitter will be covered by job bundle output tests
"*/deadline/nuke_submitter/deadline_submitter_for_nuke.py"
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def test_handle_complete(self, mock_update_status: Mock, init_data: dict):
assert match is not None
mock_update_status.assert_called_once_with(progress=100, status_message="RENDER COMPLETE")

handle_progess_params = [
handle_progress_params = [
(
(1, 2),
(
Expand All @@ -559,7 +559,7 @@ def test_handle_complete(self, mock_update_status: Mock, init_data: dict):
),
]

@pytest.mark.parametrize("regex_index, stdout, expected_progress", handle_progess_params)
@pytest.mark.parametrize("regex_index, stdout, expected_progress", handle_progress_params)
@patch("deadline.nuke_adaptor.NukeAdaptor.adaptor.NukeAdaptor.update_status")
@patch.object(NukeAdaptor, "_is_rendering", new_callable=PropertyMock(return_value=True))
def test_handle_progress(
Expand Down Expand Up @@ -598,7 +598,7 @@ def test_handle_progress(
("Eddy[ERROR] - Something terrible happened", 3),
]

@pytest.mark.parametrize("regex_index, stdout, expected_progress", handle_progess_params)
@pytest.mark.parametrize("regex_index, stdout, expected_progress", handle_progress_params)
@patch("deadline.nuke_adaptor.NukeAdaptor.adaptor.NukeAdaptor.update_status")
@patch.object(NukeAdaptor, "_is_rendering", new_callable=PropertyMock(return_value=False))
def test_handle_progress_not_rendering(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@
RenderSubmitterSettings,
RenderSubmitterUISettings,
)
from .test_template_output.expected_job_template_output import EXPECTED_NUKE_JOB_TEMPLATE
from .test_template_output.expected_job_template_with_wheel_output import (
EXPECTED_NUKE_JOB_TEMPLATE_WITH_WHEEL,
)

TEST_NUKE_VERSION = "13.2v1"
TEST_NUKE_SCRIPT_FILE_PATH = "/some/path.nk"
TEST_NUKE_SCRIPT_SETTINGS_PATH = "/some/path.deadline_settings.json"
REZ_PACKAGE_DEFAULT = "nuke-13 deadline_cloud_for_nuke"


Expand All @@ -50,7 +47,7 @@ def mock_nuke_file_path():
def mock_sticky_file_path():
with patch(
"deadline.nuke_submitter.deadline_submitter_for_nuke._get_sticky_settings_file",
return_value=Path("/some/path.deadline_settings.json"),
return_value=Path(TEST_NUKE_SCRIPT_SETTINGS_PATH),
) as m:
yield m

Expand Down Expand Up @@ -156,7 +153,7 @@ def mock_read_data(customized_settings) -> str:
def test_get_sticky_settings_file(mock_nuke_file_path, mock_is_file):
# This is a dummy test that just adds coverage, there are probably better ways to mock a file or create a test .nk
# GIVEN
expected_path = Path("/some/path.deadline_settings.json")
expected_path = Path(TEST_NUKE_SCRIPT_SETTINGS_PATH)

# WHEN
result = _get_sticky_settings_file()
Expand Down Expand Up @@ -248,9 +245,7 @@ def test_save_sticky_settings(mock_sticky_file_path, customized_ui_settings):
)
with patch("builtins.open", mock_open()) as mock_file:
_save_sticky_settings(customized_ui_settings)
mock_file.assert_called_with(
Path("/some/path.deadline_settings.json"), "w", encoding="utf8"
)
mock_file.assert_called_with(Path(TEST_NUKE_SCRIPT_SETTINGS_PATH), "w", encoding="utf8")
handle = mock_file()
handle.write.assert_called_with(expected_write_data)

Expand Down Expand Up @@ -304,40 +299,6 @@ def test_get_write_node_node_is_none(customized_ui_settings_no_write_node):
assert nuke.root() == result[0]


@patch(
"deadline.nuke_submitter.deadline_submitter_for_nuke.find_all_write_nodes", return_value=set()
)
def test_get_job_template(mock_fall_all_node, mock_is_dir, customized_ui_settings):
assert EXPECTED_NUKE_JOB_TEMPLATE == _get_job_template(customized_ui_settings)


@patch(
"os.listdir",
return_value=["openjd-wheel.whl", "deadline-wheel.whl", "deadline_cloud_for_nuke-wheel.whl"],
)
@patch(
"deadline.nuke_submitter.deadline_submitter_for_nuke.find_all_write_nodes", return_value=set()
)
def test_get_job_template_with_wheel(
mock_fall_all_node, mock_listdir, mock_is_dir, customized_ui_settings
):
# GIVEN
customized_ui_settings.include_adaptor_wheels = True

# WHEN
result = _get_job_template(customized_ui_settings)

# override the default wheel directory filepath from the result for comparison since each os/workstation will
# generate different path, and regex is too expensive for this comparison.
result["parameterDefinitions"]
for param in result["parameterDefinitions"]:
if param["name"] == "AdaptorWheels":
param["default"] = "/test/directory/deadline-cloud-for-nuke/wheels"

# THEN
assert EXPECTED_NUKE_JOB_TEMPLATE_WITH_WHEEL == result


def test_get_job_template_with_no_wheel_directories(customized_ui_settings):
expected_info = "The Developer Option 'Include Adaptor Wheels' is enabled, but the wheels directory does not exist:"
customized_ui_settings.include_adaptor_wheels = True
Expand Down Expand Up @@ -386,7 +347,7 @@ def test_get_parameter_values(
expected_parameter_dict = {"parameterValues": expected_parameter_values}

# WHEN
result = _get_parameter_values(customized_ui_settings)
result = _get_parameter_values(customized_ui_settings, REZ_PACKAGE_DEFAULT)

# THEN
assert expected_parameter_dict == result
Expand All @@ -411,7 +372,7 @@ def test_get_parameter_values_override_frame_range_false(
settings.override_frame_range = False

# WHEN
result = _get_parameter_values(settings)
result = _get_parameter_values(settings, REZ_PACKAGE_DEFAULT)

# THEN
assert expected_parameter_dict == result
Expand All @@ -432,7 +393,7 @@ def test_get_parameter_values_no_write_node_name(
expected_parameter_dict = {"parameterValues": expected_parameter_values}

# WHEN
result = _get_parameter_values(customized_ui_settings_no_write_node)
result = _get_parameter_values(customized_ui_settings_no_write_node, REZ_PACKAGE_DEFAULT)

# THEN
assert expected_parameter_dict == result
Expand All @@ -456,7 +417,7 @@ def test_get_parameter_values_no_view_selection(
settings.view_selection = None

# WHEN
result = _get_parameter_values(settings)
result = _get_parameter_values(settings, REZ_PACKAGE_DEFAULT)

# THEN
assert expected_parameter_dict == result
Expand All @@ -465,6 +426,7 @@ def test_get_parameter_values_no_view_selection(
def test_get_parameter_values_override_rez_packages(
base_parameters, mock_nuke_file_path, mock_nuke_version, customized_ui_settings
):
rez_package_override = "rez package override"
expected_parameter_values = base_parameters
expected_parameter_values.append({"name": "Frames", "value": "1-10:2"})
expected_parameter_values.append(
Expand All @@ -474,16 +436,16 @@ def test_get_parameter_values_override_rez_packages(
expected_parameter_values.append({"name": "View", "value": "TestView"})
expected_parameter_values.append({"name": "ProxyMode", "value": "true"})
expected_parameter_values.append({"name": "NukeVersion", "value": TEST_NUKE_VERSION})
expected_parameter_values.append({"name": "RezPackages", "value": REZ_PACKAGE_DEFAULT})
expected_parameter_values.append({"name": "RezPackages", "value": rez_package_override})

expected_parameter_dict = {"parameterValues": expected_parameter_values}

settings = customized_ui_settings
settings.override_rez_packages = True
settings.rez_packages = REZ_PACKAGE_DEFAULT
settings.rez_packages = rez_package_override

# WHEN
result = _get_parameter_values(settings)
result = _get_parameter_values(settings, REZ_PACKAGE_DEFAULT)

# THEN
assert expected_parameter_dict == result

This file was deleted.

Loading

0 comments on commit 36af21e

Please sign in to comment.