Exemplo n.º 1
0
    def testCreateAlloc(self, getStubMock):
        facility = facility_pb2.Facility(name=TEST_FACILITY_NAME)
        stubMock = mock.Mock()
        stubMock.Create.return_value = facility_pb2.AllocCreateResponse(
            allocation=facility_pb2.Allocation(name=TEST_ALLOC_NAME))
        getStubMock.return_value = stubMock

        alloc = opencue.api.createAllocation(TEST_ALLOC_NAME, TEST_TAG, facility)

        stubMock.Create.assert_called_with(
            facility_pb2.AllocCreateRequest(name=TEST_ALLOC_NAME, tag=TEST_TAG, facility=facility),
            timeout=mock.ANY)
        self.assertEqual(TEST_ALLOC_NAME, alloc.name())
Exemplo n.º 2
0
def createAllocation(name, tag, facility):
    """Creates and returns an allocation.
    The host tag will be the lowercase of the allocation name.
    @type  name: str
    @param name: the name of the allocation
    @type  tag: str
    @param tag: the tag for the allocation
    @rtype:  Allocation
    @return: the newly created Allocation object"""
    return Allocation(
        Cuebot.getStub('allocation').Create(facility_pb2.AllocCreateRequest(
            name=name, tag=tag, facility=facility),
                                            timeout=Cuebot.Timeout).allocation)