Esempio n. 1
0
    def testSetGroup(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.SetGroup.return_value = job_pb2.GroupSetGroupResponse()
        getStubMock.return_value = stubMock

        parentGroup = opencue.wrappers.group.Group(job_pb2.Group(name='parentGroup'))
        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        group.setGroup(parentGroup)

        stubMock.SetGroup.assert_called_with(
            job_pb2.GroupSetGroupRequest(group=group.data, parent_group=parentGroup.data),
            timeout=mock.ANY)
Esempio n. 2
0
    def testReparentGroups(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.ReparentGroups.return_value = job_pb2.GroupReparentGroupsResponse()
        getStubMock.return_value = stubMock

        groups = [opencue.wrappers.group.Group(job_pb2.Group())]
        groupSeq = job_pb2.GroupSeq(groups=[grp.data for grp in groups])
        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        group.reparentGroups(groups)

        stubMock.ReparentGroups.assert_called_with(
            job_pb2.GroupReparentGroupsRequest(group=group.data, groups=groupSeq),
            timeout=mock.ANY)
Esempio n. 3
0
    def testSetDepartment(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.SetDepartment.return_value = job_pb2.GroupSetDeptResponse()
        getStubMock.return_value = stubMock

        dept = 'pipeline'
        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        group.setDepartment(dept)

        expected = job_pb2.Group(name=TEST_GROUP_NAME)
        stubMock.SetDepartment.assert_called_with(
            job_pb2.GroupSetDeptRequest(group=expected, dept=dept),
            timeout=mock.ANY)
Esempio n. 4
0
    def testCreateSubGroup(self, getStubMock):
        subgroupName = 'testSubgroup'
        stubMock = mock.Mock()
        stubMock.CreateSubGroup.return_value = job_pb2.GroupCreateSubGroupResponse(
            group=job_pb2.Group(name=subgroupName))
        getStubMock.return_value = stubMock

        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        subgroup = group.createSubGroup(subgroupName)

        stubMock.CreateSubGroup.assert_called_with(
            job_pb2.GroupCreateSubGroupRequest(group=group.data, name=subgroupName),
            timeout=mock.ANY)
        self.assertEqual(subgroup.name(), subgroupName)
Esempio n. 5
0
    def testGetGroups(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.GetGroups.return_value = job_pb2.GroupGetGroupsResponse(
            groups=job_pb2.GroupSeq(groups=[job_pb2.Group(name=TEST_GROUP_NAME)]))
        getStubMock.return_value = stubMock

        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        groups = group.getGroups()

        stubMock.GetGroups.assert_called_with(
            job_pb2.GroupGetGroupsRequest(group=group.data),
            timeout=mock.ANY)
        self.assertEqual(len(groups), 1)
        self.assertEqual(groups[0].name(), TEST_GROUP_NAME)
Esempio n. 6
0
    def testProxyObjectArray(self, getStubMock):
        """convert a list of proto object and a class name to a proxy"""
        ids = ['A0000000-0000-0000-0000-000000000000', 'B0000000-0000-0000-0000-000000000000']
        protos = [job_pb2.Group(id=id) for id in ids]
        stubMock = mock.Mock()
        stubMock.GetGroup.side_effect = lambda request: job_pb2.GroupGetGroupResponse(
            group=job_pb2.Group(id=request.id))
        getStubMock.return_value = stubMock

        proxyList = opencue.proxy(protos, 'Group')

        stubMock.GetGroup.assert_has_calls([
            mock.call(job_pb2.GroupGetGroupRequest(id=ids[0])),
            mock.call(job_pb2.GroupGetGroupRequest(id=ids[1])),
        ])
        self.assertEqual(ids, [proxy.group.id for proxy in proxyList])
Esempio n. 7
0
    def reparentGroupIds(self, groupIds):
        """Moves the given group ids into this group.

        :type  groups: list<str>
        :param groups: The group ids to move into"""
        groups = [opencue.wrappers.group.Group(job_pb2.Group(id=groupId)) for groupId in groupIds]
        self.reparentGroups(groups)
Esempio n. 8
0
    def reparentGroupIds(self, groupIds):
        """Moves the given group ids into this group.

        :type  groupIds: list<str>
        :param groupIds: The group ids to make subgroups of this group
        """
        groups = [Group(job_pb2.Group(id=groupId)) for groupId in groupIds]
        self.reparentGroups(groups)
Esempio n. 9
0
    def testProxyUniqueId(self, getStubMock):
        """convert a string and class name to proxy"""
        id = 'A0000000-0000-0000-0000-000000000000'
        stubMock = mock.Mock()
        stubMock.GetGroup.return_value = job_pb2.GroupGetGroupResponse(group=job_pb2.Group(id=id))
        getStubMock.return_value = stubMock

        proxy = opencue.proxy(id, 'Group')

        stubMock.GetGroup.assert_called_with(job_pb2.GroupGetGroupRequest(id=id))
        self.assertEqual(id, proxy.group.id)
Esempio n. 10
0
    def testDelete(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.Delete.return_value = job_pb2.GroupDeleteResponse()
        getStubMock.return_value = stubMock

        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        group.delete()

        stubMock.Delete.assert_called_with(
            job_pb2.GroupDeleteRequest(group=group.data), timeout=mock.ANY)
Esempio n. 11
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)
Esempio n. 12
0
    def testGetGroup(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.GetGroup.return_value = job_pb2.GroupGetGroupResponse(
            group=job_pb2.Group(id=TEST_GROUP_ID))
        getStubMock.return_value = stubMock

        group = opencue.api.getGroup(TEST_GROUP_ID)

        stubMock.GetGroup.assert_called_with(
            job_pb2.GroupGetGroupRequest(id=TEST_GROUP_ID), timeout=mock.ANY)
        self.assertEqual(TEST_GROUP_ID, group.id())
Esempio n. 13
0
    def testRunFilterOnGroup(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.RunFilterOnGroup.return_value = filter_pb2.FilterRunFilterOnGroupResponse()
        getStubMock.return_value = stubMock

        group = opencue.wrappers.group.Group(job_pb2.Group(name='testGroup'))
        filterToRun = opencue.wrappers.filter.Filter(filter_pb2.Filter(name=TEST_FILTER_NAME))
        filterToRun.runFilterOnGroup(group)

        stubMock.RunFilterOnGroup.assert_called_with(
            filter_pb2.FilterRunFilterOnGroupRequest(filter=filterToRun.data, group=group.data),
            timeout=mock.ANY)
Esempio n. 14
0
    def testFindGroup(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.FindGroup.return_value = job_pb2.GroupFindGroupResponse(
            group=job_pb2.Group(name=TEST_GROUP_NAME))
        getStubMock.return_value = stubMock

        group = opencue.api.findGroup(TEST_SHOW_NAME, TEST_GROUP_NAME)

        stubMock.FindGroup.assert_called_with(
            job_pb2.GroupFindGroupRequest(
                show=TEST_SHOW_NAME, name=TEST_GROUP_NAME), timeout=mock.ANY)
        self.assertEqual(TEST_GROUP_NAME, group.name())
Esempio n. 15
0
    def testSetGroup(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.SetGroup.return_value = job_pb2.JobSetGroupResponse()
        getStubMock.return_value = stubMock

        groupId = 'ggg-gggg-ggg'
        group = job_pb2.Group(id=groupId)
        job = opencue.wrappers.job.Job(job_pb2.Job(name=TEST_JOB_NAME))
        job.setGroup(group)

        stubMock.SetGroup.assert_called_with(job_pb2.JobSetGroupRequest(
            job=job.data, group_id=groupId),
                                             timeout=mock.ANY)
Esempio n. 16
0
    def testSetName(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.SetName.return_value = job_pb2.GroupSetNameResponse()
        getStubMock.return_value = stubMock

        newName = 'changedName'
        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        group.setName(newName)

        stubMock.SetName.assert_called_with(
            job_pb2.GroupSetNameRequest(group=group.data, name=newName),
            timeout=mock.ANY)
Esempio n. 17
0
    def testSetDefaultJobPriority(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.SetDefaultJobPriority.return_value = job_pb2.GroupSetDefJobPriorityResponse()
        getStubMock.return_value = stubMock

        value = 500
        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        group.setDefaultJobPriority(value)

        stubMock.SetDefaultJobPriority.assert_called_with(
            job_pb2.GroupSetDefJobPriorityRequest(group=group.data, priority=value),
            timeout=mock.ANY)
Esempio n. 18
0
    def testSetMinCores(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.SetMinCores.return_value = job_pb2.GroupSetMinCoresResponse()
        getStubMock.return_value = stubMock

        value = 2
        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        group.setMinCores(value)

        stubMock.SetMinCores.assert_called_with(
            job_pb2.GroupSetMinCoresRequest(group=group.data, min_cores=value),
            timeout=mock.ANY)
Esempio n. 19
0
    def testGetRootGroup(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.GetRootGroup.return_value = show_pb2.ShowGetRootGroupResponse(
            group=job_pb2.Group(name=TEST_GROUP_NAME,
                                department=TEST_GROUP_DEPT))
        getStubMock.return_value = stubMock

        show = opencue.wrappers.show.Show(show_pb2.Show(name=TEST_SHOW_NAME))
        rootGroup = show.getRootGroup()

        stubMock.GetRootGroup.assert_called_with(
            show_pb2.ShowGetRootGroupRequest(show=show.data), timeout=mock.ANY)
        self.assertEqual(rootGroup.name(), TEST_GROUP_NAME)
        self.assertEqual(rootGroup.department(), TEST_GROUP_DEPT)
Esempio n. 20
0
 def asGroup(self):
     """returns a Group object from this NestedGroup"""
     return job_pb2.Group(
         id=self.data.id,
         name=self.data.name,
         department=self.data.department,
         default_job_priority=self.data.default_job_priority,
         default_job_min_cores=self.data.default_job_min_cores,
         default_job_max_cores=self.data.default_job_max_cores,
         min_cores=self.data.min_cores,
         max_cores=self.data.max_cores,
         level=self.data.level,
         group_stats=self.data.stats,
     )
Esempio n. 21
0
    def testGetJobs(self, getStubMock):
        jobName = 'testJob'
        stubMock = mock.Mock()
        stubMock.GetJobs.return_value = job_pb2.GroupGetJobsResponse(
            jobs=job_pb2.JobSeq(jobs=[job_pb2.Job(name=jobName)]))
        getStubMock.return_value = stubMock

        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        jobs = group.getJobs()

        stubMock.GetJobs.assert_called_with(
            job_pb2.GroupGetJobsRequest(group=group.data), timeout=mock.ANY)
        self.assertEqual(len(jobs), 1)
        self.assertEqual(jobs[0].name(), jobName)
Esempio n. 22
0
    def testGetGroups(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.GetGroups.return_value = show_pb2.ShowGetGroupsResponse(
            groups=job_pb2.GroupSeq(groups=[
                job_pb2.Group(name=TEST_GROUP_NAME, department=TEST_GROUP_DEPT)
            ]))
        getStubMock.return_value = stubMock

        show = opencue.wrappers.show.Show(show_pb2.Show(name=TEST_SHOW_NAME))
        groups = show.getGroups()

        stubMock.GetGroups.assert_called_with(
            show_pb2.ShowGetGroupsRequest(show=show.data), timeout=mock.ANY)
        self.assertEqual(len(groups), 1)
        self.assertEqual(groups[0].name(), TEST_GROUP_NAME)
        self.assertEqual(groups[0].department(), TEST_GROUP_DEPT)
Esempio n. 23
0
    def asGroup(self):
        """Returns a Group object from this NestedGroup.

        :rtype: opencue.wrappers.group.Group
        :return: Group version of this NestedGroup
        """
        return Group(job_pb2.Group(
            id=self.data.id,
            name=self.data.name,
            department=self.data.department,
            default_job_priority=self.data.default_job_priority,
            default_job_min_cores=self.data.default_job_min_cores,
            default_job_max_cores=self.data.default_job_max_cores,
            min_cores=self.data.min_cores,
            max_cores=self.data.max_cores,
            level=self.data.level,
            group_stats=self.data.stats,
        ))
Esempio n. 24
0
    def testReparentJobs(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.ReparentJobs.return_value = job_pb2.GroupReparentJobsResponse()
        getStubMock.return_value = stubMock

        testJob = job_pb2.Job(name='testJob')
        testNestedJob = job_pb2.NestedJob(name='testNestedJob')
        jobs = [opencue.wrappers.job.Job(testJob), opencue.wrappers.job.NestedJob(testNestedJob)]
        group = opencue.wrappers.group.Group(
            job_pb2.Group(name=TEST_GROUP_NAME))
        group.reparentJobs(jobs)

        expected = job_pb2.JobSeq(jobs=[job_pb2.Job(name='testJob'),
                                        job_pb2.Job(name='testNestedJob',
                                                    job_stats=job_pb2.JobStats())])
        stubMock.ReparentJobs.assert_called_with(
            job_pb2.GroupReparentJobsRequest(group=group.data, jobs=expected),
            timeout=mock.ANY)