def findAllocation(name): """Returns the Allocation object that matches the name. :type name: str :param name: the name of the allocation :rtype: Allocation :return: an Allocation object""" return Allocation(Cuebot.getStub('allocation').Find( facility_pb2.AllocFindRequest(name=name), timeout=Cuebot.Timeout).allocation)
def testFindAlloc(self, getStubMock): stubMock = mock.Mock() stubMock.Find.return_value = facility_pb2.AllocFindResponse( allocation=facility_pb2.Allocation(name=TEST_ALLOC_NAME)) getStubMock.return_value = stubMock alloc = opencue.api.findAllocation(TEST_ALLOC_NAME) stubMock.Find.assert_called_with( facility_pb2.AllocFindRequest(name=TEST_ALLOC_NAME), timeout=mock.ANY) self.assertEqual(TEST_ALLOC_NAME, alloc.name())