Skip to content

Commit

Permalink
Fix comments unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoTavares committed May 13, 2024
1 parent b0b6f87 commit 5d9e120
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion cuegui/cuegui/Comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions cuegui/tests/Comments_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ 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
commentSource = self.commentListDialog._CommentListDialog__treeSubjects.topLevelItem(0)
self.assertEqual(1, len(commentSource.__source))
gotComment = commentSource.__source[0]._Comment__comment
self.assertEqual(self.comment.timestamp(), gotComment.timestamp())
self.assertEqual(self.comment.user(), gotComment.user())
self.assertEqual(self.comment.subject(), gotComment.subject())
Expand Down

0 comments on commit 5d9e120

Please sign in to comment.