def getHostWhiteboard(): """ :rtype: list<Host> :return: NestedHost """ nestedHostSeq = Cuebot.getStub('host').GetHostWhiteboard( host_pb2.HostGetHostWhiteboardRequest(), timeout=Cuebot.Timeout).nested_hosts return [NestedHost(nh) for nh in nestedHostSeq.nested_hosts]
def testGetHostWhiteboard(self, getStubMock): hostId1 = 'host-one' hostId2 = 'host-two' stubMock = mock.Mock() stubMock.GetHostWhiteboard.return_value = host_pb2.HostGetHostWhiteboardResponse( nested_hosts=host_pb2.NestedHostSeq( nested_hosts=[host_pb2.NestedHost(id=hostId1), host_pb2.NestedHost(id=hostId2)])) getStubMock.return_value = stubMock hosts = opencue.api.getHostWhiteboard() stubMock.GetHostWhiteboard.assert_called_with( host_pb2.HostGetHostWhiteboardRequest(), timeout=mock.ANY) self.assertEqual([hostId1, hostId2], [host.id() for host in hosts])