diff --git a/pycue/opencue/search.py b/pycue/opencue/search.py index 1a42f696a..80ad0fa5e 100644 --- a/pycue/opencue/search.py +++ b/pycue/opencue/search.py @@ -381,4 +381,8 @@ def _setOptions(criteria, options): criteria.first_result = int(v) elif k == "include_finished": criteria.include_finished = v + elif len(k) == 0: + return criteria + else: + raise Exception("Criteria for search does not exist") return criteria diff --git a/pycue/tests/api_test.py b/pycue/tests/api_test.py index b20acfff9..5dc4872d3 100644 --- a/pycue/tests/api_test.py +++ b/pycue/tests/api_test.py @@ -189,7 +189,7 @@ def testGetJobs(self, getStubMock): jobs=job_pb2.JobSeq(jobs=[job_pb2.Job(name=TEST_JOB_NAME)])) getStubMock.return_value = stubMock - jobsByShow = opencue.api.getJobs(show=[TEST_SHOW_NAME], all=True) + jobsByShow = opencue.api.getJobs(show=[TEST_SHOW_NAME]) stubMock.GetJobs.assert_called_with( job_pb2.JobGetJobsRequest( @@ -206,6 +206,28 @@ def testGetJobs(self, getStubMock): self.assertEqual(1, len(jobsByName)) self.assertEqual(TEST_JOB_NAME, jobsByName[0].name()) + @mock.patch('opencue.cuebot.Cuebot.getStub') + def testGetAllJobs(self, getStubMock): + stubMock = mock.Mock() + stubMock.GetJobs.return_value = job_pb2.JobGetJobsResponse( + jobs=job_pb2.JobSeq(jobs=[job_pb2.Job(name=TEST_JOB_NAME)])) + getStubMock.return_value = stubMock + + jobs = opencue.api.getJobs() + + stubMock.GetJobs.assert_called_with( + job_pb2.JobGetJobsRequest( + r=job_pb2.JobSearchCriteria()), timeout=mock.ANY) + self.assertEqual(1, len(jobs)) + self.assertEqual(TEST_JOB_NAME, jobs[0].name()) + + def testRaiseExceptionOnBadCriteriaSearch(self): + with self.assertRaises(Exception) as context: + opencue.api.getJobs(bad_criteria=["00000000-0000-0000-0000-012345678980"]) + + self.assertTrue("Criteria for search does not exist" in context.exception) + return + @mock.patch('opencue.cuebot.Cuebot.getStub') def testGetJob(self, getStubMock): arbitraryId = '00000000-0000-0000-0000-012345678980'