def testGetService(self, getStubMock): stubMock = mock.Mock() stubMock.GetService.return_value = service_pb2.ServiceGetServiceResponse( service=service_pb2.Service(name=TEST_SERVICE_NAME)) getStubMock.return_value = stubMock wrapper = opencue.wrappers.service.Service() service = wrapper.getService(name=TEST_SERVICE_NAME) stubMock.GetService.assert_called_with( service_pb2.ServiceGetServiceRequest(name=TEST_SERVICE_NAME), timeout=mock.ANY) self.assertEqual(service.name(), TEST_SERVICE_NAME)
def testCreateService(self, getStubMock): stubMock = mock.Mock() stubMock.CreateService.return_value = service_pb2.ServiceCreateServiceResponse( service=service_pb2.Service(name=TEST_SERVICE_NAME)) getStubMock.return_value = stubMock wrapper = opencue.wrappers.service.Service( service_pb2.Service(name=TEST_SERVICE_NAME)) service = wrapper.create() stubMock.CreateService.assert_called_with( service_pb2.ServiceCreateServiceRequest(data=wrapper.data), timeout=mock.ANY) self.assertEqual(wrapper.name(), service.name())
def testGpus(self, getStubMock): stubMock = mock.Mock() stubMock.GetService.return_value = service_pb2.ServiceGetServiceResponse( service=service_pb2.Service(name=TEST_SERVICE_NAME)) getStubMock.return_value = stubMock wrapper = opencue.wrappers.service.Service() service = wrapper.getService(name=TEST_SERVICE_NAME) self.assertEqual(service.minGpus(), 0) self.assertEqual(service.maxGpus(), 0) self.assertEqual(service.minGpuMemory(), 0) service.setMinGpus(TEST_MIN_GPUS) service.setMaxGpus(TEST_MAX_GPUS) service.setMinGpuMemory(TEST_MIN_GPU_MEMORY) self.assertEqual(service.minGpus(), TEST_MIN_GPUS) self.assertEqual(service.maxGpus(), TEST_MAX_GPUS) self.assertEqual(service.minGpuMemory(), TEST_MIN_GPU_MEMORY) stubMock.GetService.assert_called_with( service_pb2.ServiceGetServiceRequest(name=TEST_SERVICE_NAME), timeout=mock.ANY) self.assertEqual(service.name(), TEST_SERVICE_NAME)