def getHosts(self): """Get a list of all hosts this owner is responsible for. :rtype: List<opencue.wrappers.host.Host Wrapper> :return: List of hosts the owned by this owner.""" response = self.stub.GetHosts(host_pb2.OwnerGetHostsRequest(owner=self.data), timeout=Cuebot.Timeout) return [opencue.wrappers.host.Host(host) for host in response.hosts.hosts]
def testGetHosts(self, getStubMock): stubMock = mock.Mock() stubMock.GetHosts.return_value = host_pb2.OwnerGetHostsResponse( hosts=host_pb2.HostSeq(hosts=[host_pb2.Host(id=TEST_HOST_ID)])) getStubMock.return_value = stubMock owner = opencue.wrappers.owner.Owner( host_pb2.Owner(id=TEST_OWNER_ID, name=TEST_OWNER_NAME)) hosts = owner.getHosts() stubMock.GetHosts.assert_called_with( host_pb2.OwnerGetHostsRequest(owner=owner.data), timeout=mock.ANY) self.assertEqual(len(hosts), 1) self.assertEqual(hosts[0].id(), TEST_HOST_ID)