def getAllocations(): """Returns a list of allocation objects. @rtype: list<Allocation> @return: a list of Allocation objects""" allocationSeq = Cuebot.getStub('allocation').GetAll( facility_pb2.AllocGetAllRequest(), timeout=Cuebot.Timeout).allocations return [Allocation(a) for a in allocationSeq.allocations]
def testGetAllocs(self, getStubMock): stubMock = mock.Mock() stubMock.GetAll.return_value = facility_pb2.AllocGetAllResponse( allocations=facility_pb2.AllocationSeq(allocations=[facility_pb2.Allocation(name=TEST_ALLOC_NAME)])) getStubMock.return_value = stubMock allocs = opencue.api.getAllocations() stubMock.GetAll.assert_called_with( facility_pb2.AllocGetAllRequest(), timeout=mock.ANY) self.assertEqual([TEST_ALLOC_NAME], [alloc.name() for alloc in allocs])