Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ def _build_ui(
self.submit_button = QPushButton(tr("Submit"))
self.submit_button.clicked.connect(self.on_submit)
self.button_box.addButton(self.submit_button, QDialogButtonBox.AcceptRole)
if hasattr(initial_job_settings, "browse_enabled") and initial_job_settings.browse_enabled:
self.load_bundle_button = QPushButton(tr("Load a different job bundle"))
self.load_bundle_button.clicked.connect(self._on_load_bundle)
self.button_box.addButton(self.load_bundle_button, QDialogButtonBox.AcceptRole)
self.export_bundle_button = QPushButton(tr("Export bundle"))
self.export_bundle_button.clicked.connect(self.on_export_bundle)
self.button_box.addButton(self.export_bundle_button, QDialogButtonBox.AcceptRole)
Expand Down Expand Up @@ -416,6 +420,11 @@ def _on_about_button_clicked(self):
f"Failed to display About dialog: {str(e)}",
)

def _on_load_bundle(self):
"""Delegates to the job_settings widget's on_load_bundle method."""
if hasattr(self.job_settings, "on_load_bundle"):
self.job_settings.on_load_bundle()

def on_export_bundle(self):
"""
Exports a Job Bundle, but does not submit the job.
Expand Down
13 changes: 0 additions & 13 deletions src/deadline/client/ui/widgets/job_bundle_settings_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@
from typing import Any, Optional

from qtpy.QtCore import Signal # type: ignore
from .._utils import tr
from qtpy.QtWidgets import ( # type: ignore
QVBoxLayout,
QHBoxLayout,
QWidget,
QFileDialog,
QPushButton,
QSpacerItem,
QSizePolicy,
QMessageBox,
)

Expand Down Expand Up @@ -62,14 +57,6 @@ def _build_ui(self, initial_settings: JobBundleSettings):

layout = QVBoxLayout(self)

if initial_settings.browse_enabled:
btnBox = QHBoxLayout()
self.load_bundle_button = QPushButton(tr("Load a different job bundle"))
self.load_bundle_button.clicked.connect(self.on_load_bundle)
btnBox.addWidget(self.load_bundle_button)
btnBox.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum))
layout.addLayout(btnBox)

layout.addLayout(self.param_layout)
self.refresh_ui(initial_settings)

Expand Down
1 change: 1 addition & 0 deletions test/unit/deadline_client/ui/dialogs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

from unittest.mock import MagicMock, patch

import pytest

try:
from deadline.client.ui.dialogs.submit_job_to_deadline_dialog import SubmitJobToDeadlineDialog
from deadline.client.ui.dataclasses import JobBundleSettings
from deadline.client.job_bundle.submission import AssetReferences
except ImportError:
pytest.importorskip("deadline.client.ui.dialogs.submit_job_to_deadline_dialog")


@pytest.fixture
def mock_job_settings_widget():
"""Create a mock job settings widget type."""
widget = MagicMock()
widget.return_value = MagicMock()
widget.return_value.parameter_changed = MagicMock()
widget.return_value.parameter_changed.connect = MagicMock()
return widget


@patch("deadline.client.ui.dialogs.submit_job_to_deadline_dialog.DeadlineAuthenticationStatus")
def test_load_bundle_button_shown_when_browse_enabled(
mock_auth_status, qtbot, mock_job_settings_widget
):
"""Test that the Load a different job bundle button is shown when browse_enabled is True."""
mock_auth_status.getInstance.return_value = MagicMock()

settings = JobBundleSettings(browse_enabled=True)

dialog = SubmitJobToDeadlineDialog(
job_setup_widget_type=mock_job_settings_widget,
initial_job_settings=settings,
initial_shared_parameter_values={},
auto_detected_attachments=AssetReferences(),
attachments=AssetReferences(),
on_create_job_bundle_callback=MagicMock(),
)
qtbot.addWidget(dialog)

assert hasattr(dialog, "load_bundle_button")
assert dialog.load_bundle_button.text() == "Load a different job bundle"


@patch("deadline.client.ui.dialogs.submit_job_to_deadline_dialog.DeadlineAuthenticationStatus")
def test_load_bundle_button_hidden_when_browse_disabled(
mock_auth_status, qtbot, mock_job_settings_widget
):
"""Test that the Load a different job bundle button is not shown when browse_enabled is False."""
mock_auth_status.getInstance.return_value = MagicMock()

settings = JobBundleSettings(browse_enabled=False)

dialog = SubmitJobToDeadlineDialog(
job_setup_widget_type=mock_job_settings_widget,
initial_job_settings=settings,
initial_shared_parameter_values={},
auto_detected_attachments=AssetReferences(),
attachments=AssetReferences(),
on_create_job_bundle_callback=MagicMock(),
)
qtbot.addWidget(dialog)

assert not hasattr(dialog, "load_bundle_button")
Loading