Exemple #1
0
    def testName(self, getStubMock):
        actionInt = opencue.wrappers.filter.Action(filter_pb2.Action(
            id=TEST_ACTION_ID, type=filter_pb2.PAUSE_JOB, value_type=filter_pb2.INTEGER_TYPE,
            integer_value=22))
        self.assertEqual(actionInt.name(), "PAUSE_JOB 22")

        actionNone = opencue.wrappers.filter.Action(filter_pb2.Action(
            id=TEST_ACTION_ID, type=filter_pb2.PAUSE_JOB, value_type=filter_pb2.NONE_TYPE))
        self.assertEqual(actionNone.name(), "PAUSE_JOB")
Exemple #2
0
    def testValue(self, getStubMock):
        groupValue = 'testGroup'
        stringValue = 'testString'
        intValue = 22
        floatValue = 22.2
        boolValue = True
        action = opencue.wrappers.filter.Action(
            filter_pb2.Action(
                id=TEST_ACTION_ID,
                type=filter_pb2.PAUSE_JOB,
                group_value=groupValue,
                string_value=stringValue,
                integer_value=intValue,
                float_value=floatValue,
                boolean_value=boolValue))

        action.data.value_type = filter_pb2.GROUP_TYPE
        self.assertEqual(action.value(), groupValue)

        action.data.value_type = filter_pb2.STRING_TYPE
        self.assertEqual(action.value(), stringValue)

        action.data.value_type = filter_pb2.INTEGER_TYPE
        self.assertEqual(action.value(), intValue)

        action.data.value_type = filter_pb2.FLOAT_TYPE
        threshold = abs(action.value() - floatValue)
        self.assertTrue(threshold < 0.0001)

        action.data.value_type = filter_pb2.BOOLEAN_TYPE
        self.assertEqual(action.value(), boolValue)

        action.data.value_type = filter_pb2.NONE_TYPE
        self.assertEqual(action.value(), None)
Exemple #3
0
    def testCreateAction(self, getStubMock):
        actionId = 'aaa-aaaa-aaa'
        stubMock = mock.Mock()
        stubMock.CreateAction.return_value = filter_pb2.FilterCreateActionResponse(
            action=filter_pb2.Action(id=actionId))
        getStubMock.return_value = stubMock

        actionType = filter_pb2.PAUSE_JOB
        value = 10
        filter = opencue.wrappers.filter.Filter(
            filter_pb2.Filter(name=TEST_FILTER_NAME))
        action = filter.createAction(actionType, value)
        actionData = opencue.wrappers.filter.ActionData(
            type=actionType,
            value_type=filter_pb2.INTEGER_TYPE,
            group_value=None,
            string_value=None,
            integer_value=value,
            float_value=0.0,
            boolean_value=False)

        stubMock.CreateAction.assert_called_with(
            filter_pb2.FilterCreateActionRequest(filter=filter.data,
                                                 data=actionData),
            timeout=mock.ANY)
        self.assertEqual(action.id(), actionId)
Exemple #4
0
    def testIsNew(self, getStubMock):
        actionFalse = opencue.wrappers.filter.Action(
            filter_pb2.Action(id=TEST_ACTION_ID))
        self.assertFalse(actionFalse.isNew())

        actionTrue = opencue.wrappers.filter.Action()
        self.assertTrue(actionTrue.isNew())
Exemple #5
0
    def testSetTypeAndValueFail(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.Commit.return_value = filter_pb2.ActionCommitResponse()
        getStubMock.return_value = stubMock

        action = opencue.wrappers.filter.Action(filter_pb2.Action(id=TEST_ACTION_ID))

        with self.assertRaises(Exception):
            action.setTypeAndValue('foo', 'bar')
Exemple #6
0
    def testCommit(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.Commit.return_value = filter_pb2.ActionCommitResponse()
        getStubMock.return_value = stubMock

        action = opencue.wrappers.filter.Action(filter_pb2.Action(id=TEST_ACTION_ID))
        action.commit()

        stubMock.Commit.assert_called_with(
            filter_pb2.ActionCommitRequest(action=action.data), timeout=mock.ANY)
Exemple #7
0
    def testSetTypeAndValueNone(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.Commit.return_value = filter_pb2.ActionCommitResponse()
        getStubMock.return_value = stubMock

        testData = (filter_pb2.STOP_PROCESSING, None)
        action = opencue.wrappers.filter.Action(filter_pb2.Action(id=TEST_ACTION_ID))

        action.setTypeAndValue(testData[0], testData[1])
        stubMock.Commit.assert_called_with(
            filter_pb2.ActionCommitRequest(action=action.data), timeout=mock.ANY)
Exemple #8
0
    def testSetTypeAndValueString(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.Commit.return_value = filter_pb2.ActionCommitResponse()
        getStubMock.return_value = stubMock

        testData = (filter_pb2.SET_ALL_RENDER_LAYER_TAGS, 'testString')
        action = opencue.wrappers.filter.Action(filter_pb2.Action(id=TEST_ACTION_ID))

        action.setTypeAndValue(testData[0], testData[1])
        stubMock.Commit.assert_called_with(
            filter_pb2.ActionCommitRequest(action=action.data), timeout=mock.ANY)
Exemple #9
0
    def testSetTypeAndValueGroup(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.Commit.return_value = filter_pb2.ActionCommitResponse()
        getStubMock.return_value = stubMock

        testData = (filter_pb2.MOVE_JOB_TO_GROUP, job_pb2.Group(id='testGroup'))
        action = opencue.wrappers.filter.Action(filter_pb2.Action(id=TEST_ACTION_ID))

        action.setTypeAndValue(testData[0], testData[1])
        stubMock.Commit.assert_called_with(
            filter_pb2.ActionCommitRequest(action=action.data), timeout=mock.ANY)
Exemple #10
0
    def testGetParentFilter(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.GetParentFilter.return_value = filter_pb2.ActionGetParentFilterResponse(
            filter=filter_pb2.Filter(name=TEST_FILTER_NAME))
        getStubMock.return_value = stubMock

        action = opencue.wrappers.filter.Action(filter_pb2.Action(id=TEST_ACTION_ID))
        filterReturned = action.getParentFilter()

        stubMock.GetParentFilter.assert_called_with(
            filter_pb2.ActionGetParentFilterRequest(action=action.data), timeout=mock.ANY)
        self.assertEqual(filterReturned.name(), TEST_FILTER_NAME)
Exemple #11
0
    def testGetActions(self, getStubMock):
        actionId = 'aaa-aaaa-aaa'
        stubMock = mock.Mock()
        stubMock.GetActions.return_value = filter_pb2.FilterGetActionsResponse(
            actions=filter_pb2.ActionSeq(actions=[filter_pb2.Action(id=actionId)]))
        getStubMock.return_value = stubMock

        filterForActions = opencue.wrappers.filter.Filter(filter_pb2.Filter(name=TEST_FILTER_NAME))
        actions = filterForActions.getActions()

        stubMock.GetActions.assert_called_with(
            filter_pb2.FilterGetActionsRequest(filter=filterForActions.data), timeout=mock.ANY)
        self.assertEqual(len(actions), 1)
        self.assertEqual(actions[0].id(), actionId)