def getHost(uniq): """Returns a Host object from a unique identifier. @type uniq: str @param uniq: a unique host identifier @rtype: Host @return: A Host object""" return Host( Cuebot.getStub('host').GetHost(host_pb2.HostGetHostRequest(id=uniq), timeout=Cuebot.Timeout).host)
def testGetHost(self, getStubMock): arbitraryId = '00000000-0000-0000-0000-012345678980' stubMock = mock.Mock() stubMock.GetHost.return_value = host_pb2.HostGetHostResponse( host=host_pb2.Host(id=arbitraryId)) getStubMock.return_value = stubMock host = opencue.api.getHost(arbitraryId) stubMock.GetHost.assert_called_with( host_pb2.HostGetHostRequest(id=arbitraryId), timeout=mock.ANY) self.assertEqual(arbitraryId, host.id())