From b0b6f872a34e4bf998ef337e5ae1ce55ae49d6e2 Mon Sep 17 00:00:00 2001 From: Diego Tavares Date: Fri, 10 May 2024 13:53:29 -0700 Subject: [PATCH 1/4] Fix comments ui unit tests --- .gitignore | 1 + cuegui/tests/Comments_tests.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ea2769780..7f4857d09 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ htmlcov/ /.env .envrc .vscode +.venv/ \ No newline at end of file diff --git a/cuegui/tests/Comments_tests.py b/cuegui/tests/Comments_tests.py index 29bdf613f..133bd7a6c 100644 --- a/cuegui/tests/Comments_tests.py +++ b/cuegui/tests/Comments_tests.py @@ -54,7 +54,7 @@ def setUp(self, getStubMock): self.job = opencue.wrappers.job.Job(opencue.compiled_proto.job_pb2.Job(name='fooJob')) self.parentWidget = QtWidgets.QWidget() self.commentListDialog = cuegui.Comments.CommentListDialog( - self.job, parent=self.parentWidget) + [self.job], parent=self.parentWidget) def test_shouldDisplayComment(self): self.assertEqual( From d0cf9ab3f700cad80ea50afbccc653c4c30d7e13 Mon Sep 17 00:00:00 2001 From: Diego Tavares Date: Mon, 13 May 2024 09:20:01 -0700 Subject: [PATCH 2/4] Fix comments unit tests --- cuegui/cuegui/Comments.py | 14 +++++++++++++- cuegui/tests/Comments_tests.py | 15 ++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/cuegui/cuegui/Comments.py b/cuegui/cuegui/Comments.py index 2e54b19cd..5b108f91f 100644 --- a/cuegui/cuegui/Comments.py +++ b/cuegui/cuegui/Comments.py @@ -230,7 +230,13 @@ def refreshComments(self): last_items = [] for i in range(self.__treeSubjects.topLevelItemCount()): comment_source = self.__treeSubjects.topLevelItem(i) - last_items.append(comment_source.child(comment_source.childCount()-1)) + comment = comment_source.child(comment_source.childCount()-1) + if comment: + last_items.append(comment) + if not last_items: + self.__createNewComment() + return + identical = all(item.getInstance().message() == last_items[0].getInstance().message() and item.getInstance().subject() == last_items[0].getInstance().subject() for item in last_items) @@ -342,6 +348,12 @@ def __addComment(self, subject, message): for source in self.__source: source.addComment(str(subject), str(message) or " ") + def getComments(self): + comments = {} + for source in self.__source: + comments[source.data.name] = source.getComments() + return comments + class CommentMacroDialog(QtWidgets.QDialog): """A dialog for adding or modifying macro comments""" diff --git a/cuegui/tests/Comments_tests.py b/cuegui/tests/Comments_tests.py index 133bd7a6c..d294ecb15 100644 --- a/cuegui/tests/Comments_tests.py +++ b/cuegui/tests/Comments_tests.py @@ -51,7 +51,8 @@ def setUp(self, getStubMock): opencue.compiled_proto.job_pb2.JobGetCommentsResponse( comments=opencue.compiled_proto.comment_pb2.CommentSeq(comments=[commentProto])) - self.job = opencue.wrappers.job.Job(opencue.compiled_proto.job_pb2.Job(name='fooJob')) + self.job_name = "fooJob" + self.job = opencue.wrappers.job.Job(opencue.compiled_proto.job_pb2.Job(name=self.job_name)) self.parentWidget = QtWidgets.QWidget() self.commentListDialog = cuegui.Comments.CommentListDialog( [self.job], parent=self.parentWidget) @@ -59,12 +60,12 @@ def setUp(self, getStubMock): def test_shouldDisplayComment(self): self.assertEqual( 1, self.commentListDialog._CommentListDialog__treeSubjects.topLevelItemCount()) - gotTreeWidgetItem = self.commentListDialog._CommentListDialog__treeSubjects.topLevelItem(0) - gotComment = gotTreeWidgetItem._Comment__comment - self.assertEqual(self.comment.timestamp(), gotComment.timestamp()) - self.assertEqual(self.comment.user(), gotComment.user()) - self.assertEqual(self.comment.subject(), gotComment.subject()) - self.assertEqual(self.comment.message(), gotComment.message()) + comments_per_job = self.commentListDialog.getComments() + comment = comments_per_job[self.job_name][0] + self.assertEqual(self.comment.timestamp(), comment.timestamp()) + self.assertEqual(self.comment.user(), comment.user()) + self.assertEqual(self.comment.subject(), comment.subject()) + self.assertEqual(self.comment.message(), comment.message()) def test_shouldRefreshJobComments(self): self.job.getComments = mock.Mock(return_value=[]) From a3ee8a2e60cc463b0221b2147a6156640de4157c Mon Sep 17 00:00:00 2001 From: Diego Tavares Date: Mon, 13 May 2024 10:14:50 -0700 Subject: [PATCH 3/4] Fix python2/3 compatibility issue --- cuesubmit/cuesubmit/ui/Widgets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cuesubmit/cuesubmit/ui/Widgets.py b/cuesubmit/cuesubmit/ui/Widgets.py index 055853821..425567529 100644 --- a/cuesubmit/cuesubmit/ui/Widgets.py +++ b/cuesubmit/cuesubmit/ui/Widgets.py @@ -293,7 +293,7 @@ def __init__(self, label=None, parent=None, max_value=999, float_precision=None): super(CueLabelSlider, self).__init__(parent=parent) - self._labelValue = f'{label} ({{value}})' + self._labelValue = "%s ({value})" % label self.float_mult = 1 if float_precision: self.float_mult = 10**float_precision From 570e98729bc2ffedfbdd21f836d5896a63f4d351 Mon Sep 17 00:00:00 2001 From: Diego Tavares Date: Mon, 13 May 2024 10:25:26 -0700 Subject: [PATCH 4/4] Fix pylint --- cuegui/cuegui/Comments.py | 8 +++++--- cuegui/cuegui/ServiceDialog.py | 2 +- cuesubmit/cuesubmit/ui/Widgets.py | 2 ++ pycue/opencue/wrappers/service.py | 14 ++++++++------ pycue/opencue/wrappers/show.py | 1 - 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cuegui/cuegui/Comments.py b/cuegui/cuegui/Comments.py index 5b108f91f..d1fdbc12d 100644 --- a/cuegui/cuegui/Comments.py +++ b/cuegui/cuegui/Comments.py @@ -260,9 +260,10 @@ def refreshComments(self): def __macroLoad(self): """Loads the defined comment macros from settings""" comments_macro = self.app.settings.value("Comments", pickle.dumps({})) - try: - self.__macroList = pickle.loads( - comments_macro if isinstance(comments_macro, bytes) else comments_macro.encode('UTF-8')) + try: + self.__macroList = pickle.loads( + comments_macro if isinstance(comments_macro, bytes) \ + else comments_macro.encode('UTF-8')) except TypeError: self.__macroList = pickle.loads(str(comments_macro)) self.__macroRefresh() @@ -349,6 +350,7 @@ def __addComment(self, subject, message): source.addComment(str(subject), str(message) or " ") def getComments(self): + """Get Comments""" comments = {} for source in self.__source: comments[source.data.name] = source.getComments() diff --git a/cuegui/cuegui/ServiceDialog.py b/cuegui/cuegui/ServiceDialog.py index 1fac432af..8c6ebec2a 100644 --- a/cuegui/cuegui/ServiceDialog.py +++ b/cuegui/cuegui/ServiceDialog.py @@ -27,11 +27,11 @@ from qtpy import QtWidgets import opencue +from opencue.wrappers.service import ServiceOverride import cuegui.Constants import cuegui.TagsWidget import cuegui.Utils -from opencue.wrappers.service import ServiceOverride class ServiceForm(QtWidgets.QWidget): diff --git a/cuesubmit/cuesubmit/ui/Widgets.py b/cuesubmit/cuesubmit/ui/Widgets.py index 425567529..bc658a3a7 100644 --- a/cuesubmit/cuesubmit/ui/Widgets.py +++ b/cuesubmit/cuesubmit/ui/Widgets.py @@ -322,11 +322,13 @@ def setupUi(self): def setupConnections(self): """Sets up widget signals.""" self.valueChanged.connect(self.updateLabelValue) + # pylint: disable=no-member self.slider.valueChanged.connect(self.valueChanged.emit) self.slider.sliderMoved.connect(self.sliderMoved.emit) self.slider.sliderReleased.connect(self.sliderReleased.emit) self.slider.actionTriggered.connect(self.actionTriggered.emit) self.slider.rangeChanged.connect(self.rangeChanged.emit) + # pylint: enable=no-member def updateLabelValue(self, value): """ Updates the label with the slider's value at the end diff --git a/pycue/opencue/wrappers/service.py b/pycue/opencue/wrappers/service.py index 92cafe7fc..216380942 100644 --- a/pycue/opencue/wrappers/service.py +++ b/pycue/opencue/wrappers/service.py @@ -261,22 +261,24 @@ def setMinMemoryIncrease(self, min_memory_increase): raise ValueError("Minimum memory increase must be > 0") class ServiceOverride(object): + """Represents a display override of a service assigned to a show""" def __init__(self, serviceOverride=None): + defaultServiceOverride = service_pb2.ServiceOverride() + # pylint: disable=no-member + self.id = defaultServiceOverride.id + self.data = defaultServiceOverride.data if serviceOverride: self.id = serviceOverride.id self.data = serviceOverride.data or service_pb2.Service().data - else: - defaultServiceOverride = service_pb2.ServiceOverride() - self.id = defaultServiceOverride.id - self.data = defaultServiceOverride.data - self.stub = Cuebot.getStub("serviceOverride") + # pylint: enable=no-member def delete(self): + """Remove service override""" self.stub.Delete( service_pb2.ServiceOverrideDeleteRequest(service=self.data), timeout=Cuebot.Timeout) - + def update(self): """Commit a ServiceOverride change to the database""" self.stub.Update( diff --git a/pycue/opencue/wrappers/show.py b/pycue/opencue/wrappers/show.py index c7594aaa3..7d426cd4c 100644 --- a/pycue/opencue/wrappers/show.py +++ b/pycue/opencue/wrappers/show.py @@ -74,7 +74,6 @@ def createServiceOverride(self, data): # min_memory_increase has to be greater than 0. if data.min_memory_increase <= 0: raise ValueError("Minimum memory increase must be > 0") - self.stub.CreateServiceOverride(show_pb2.ShowCreateServiceOverrideRequest( show=self.data, service=data), timeout=Cuebot.Timeout)