def testSave(self, getStubMock): stubMock = mock.Mock() stubMock.Save.return_value = comment_pb2.CommentSaveResponse() getStubMock.return_value = stubMock comment = opencue.wrappers.comment.Comment( comment_pb2.Comment(message=TEST_COMMENT_MESSAGE)) comment.save() stubMock.Save.assert_called_with( comment_pb2.CommentSaveRequest(comment=comment.data), timeout=mock.ANY)
def addComment(self, subject, message): """Appends a comment to the job's comment list @type subject: str @param subject: Subject data @type message: str @param message: Message data""" comment = comment_pb2.Comment(user=os.getenv("USER", "unknown"), subject=subject, message=message or " ", timestamp=0) self.stub.AddComment(job_pb2.JobAddCommentRequest(job=self.data, new_comment=comment), timeout=Cuebot.Timeout)
def testGetComments(self, getStubMock): message = 'this is a test.' stubMock = mock.Mock() stubMock.GetComments.return_value = host_pb2.HostGetCommentsResponse( comments=comment_pb2.CommentSeq( comments=[comment_pb2.Comment(message=message)])) getStubMock.return_value = stubMock host = opencue.wrappers.host.Host(host_pb2.Host(name=TEST_HOST_NAME)) comments = host.getComments() stubMock.GetComments.assert_called_with( host_pb2.HostGetCommentsRequest(host=host.data), timeout=mock.ANY) self.assertEqual(len(comments), 1) self.assertEqual(comments[0].message(), message)
def testGetComments(self, getStubMock): message = 'this is a test.' stubMock = mock.Mock() stubMock.GetComments.return_value = job_pb2.JobGetCommentsResponse( comments=comment_pb2.CommentSeq( comments=[comment_pb2.Comment(message=message)])) getStubMock.return_value = stubMock job = opencue.wrappers.job.Job(job_pb2.Job(name=TEST_JOB_NAME)) comments = job.getComments() stubMock.GetComments.assert_called_with( job_pb2.JobGetCommentsRequest(job=job.data), timeout=mock.ANY) self.assertEqual(len(comments), 1) self.assertEqual(comments[0].message(), message)
def testAddComment(self, getStubMock): stubMock = mock.Mock() stubMock.AddComment.return_value = job_pb2.JobAddCommentResponse() getStubMock.return_value = stubMock subject = 'test' message = 'this is a test.' comment = comment_pb2.Comment(user=os.getenv('USER', 'unknown'), subject=subject, message=message, timestamp=0) job = opencue.wrappers.job.Job( job_pb2.Job(name=TEST_JOB_NAME)) job.addComment(subject, message) stubMock.AddComment.assert_called_with( job_pb2.JobAddCommentRequest(job=job.data, new_comment=comment), timeout=mock.ANY)
def testAddComment(self, getStubMock): stubMock = mock.Mock() stubMock.AddComment.return_value = host_pb2.HostAddCommentResponse() getStubMock.return_value = stubMock subject = 'test' message = 'this is a test.' comment = comment_pb2.Comment(user=os.getenv("USER", "unknown"), subject=subject, message=message, timestamp=0) host = opencue.wrappers.host.Host(host_pb2.Host(name=TEST_HOST_NAME)) host.addComment(subject, message) stubMock.AddComment.assert_called_with(host_pb2.HostAddCommentRequest( host=host.data, new_comment=comment), timeout=mock.ANY)