def setUp(self): self.uuid = uuid.uuid1() self.dummy_process = InOut() self.dummy_process._set_uuid(self.uuid) self.dummy_process.set_workdir('/tmp') self.wps_request = WPSRequest() self.wps_response = ExecuteResponse(self.wps_request, self.uuid, process=self.dummy_process) self.job = Job( process=self.dummy_process, wps_request=self.wps_request, wps_response=self.wps_response)
def test_job_dump(self): new_job = Job.load(self.job.dump()) self.assertEqual(new_job.name, 'inout') self.assertEqual(new_job.uuid, str(self.uuid)) self.assertEqual(new_job.workdir, '/tmp') self.assertEqual(len(new_job.process.inputs), 3) self.assertEqual(new_job.json, self.job.json) # idempotent test
class InOutProcessingTest(unittest.TestCase): """Processing test case with InOut process""" def setUp(self): self.uuid = uuid.uuid1() self.dummy_process = InOut() self.dummy_process._set_uuid(self.uuid) self.dummy_process.set_workdir('/tmp') self.wps_request = WPSRequest() self.wps_response = ExecuteResponse(self.wps_request, self.uuid, process=self.dummy_process) self.job = Job( process=self.dummy_process, wps_request=self.wps_request, wps_response=self.wps_response) def test_job_json(self): new_job = Job.from_json(json.loads(self.job.json)) self.assertEqual(new_job.name, 'inout') self.assertEqual(new_job.uuid, str(self.uuid)) self.assertEqual(new_job.workdir, '/tmp') self.assertEqual(len(new_job.process.inputs), 3) self.assertEqual(new_job.json, self.job.json) # idempotent test def test_job_dump(self): new_job = Job.load(self.job.dump()) self.assertEqual(new_job.name, 'inout') self.assertEqual(new_job.uuid, str(self.uuid)) self.assertEqual(new_job.workdir, '/tmp') self.assertEqual(len(new_job.process.inputs), 3) self.assertEqual(new_job.json, self.job.json) # idempotent test
def launch_process(): """Look at the queue of async process, if the queue is not empty launch the next pending request. """ try: from pywps.processing.job import Job LOGGER.debug("Checking for stored requests") stored_request = dblog.pop_first_stored() if not stored_request: LOGGER.debug("No stored request found, sleeping") return value = { 'process': json.loads(stored_request.process.decode("utf-8")), 'wps_request': json.loads(stored_request.request.decode("utf-8")) } job = Job.from_json(value) processing_process = pywps.processing.Process( process=job.process, wps_request=job.wps_request, wps_response=job.wps_response) processing_process.start() except Exception as e: LOGGER.exception("Could not run stored process. {}".format(e)) raise e
def test_insert_request(self): requests = self.session.query(RequestInstance) assert requests.count() == 0 obj = { 'operation': 'execute', 'version': '1.0.0', 'language': 'eng', 'identifier': 'multiple-outputs', 'store_execute': True, 'status': True, 'lineage': True, 'inputs': { 'count': [{ 'identifier': 'count', 'type': 'literal', 'data': 3 }] }, 'outputs': {}, 'raw': False } request = WPSRequest() request.json = obj from .processes.metalinkprocess import MultipleOutputs process = MultipleOutputs() process.uuid = uuid.uuid4() store_request(process.uuid, request, process) requests = self.session.query(RequestInstance) assert requests.count() == 1 stored_request = pop_first_stored() job = Job.from_json({ "process": json.loads(stored_request.process), "wps_request": json.loads(stored_request.request) }) assert job.process.identifier == "multiple-outputs" assert str(job.process.uuid) == str(process.uuid) requests = self.session.query(RequestInstance) assert requests.count() == 0
class GreeterProcessingTest(unittest.TestCase): """Processing test case with Greeter process""" def setUp(self): self.uuid = uuid.uuid1() self.dummy_process = Greeter() self.dummy_process._set_uuid(self.uuid) self.dummy_process.set_workdir('/tmp') self.wps_request = WPSRequest() self.wps_response = ExecuteResponse(self.wps_request, self.uuid, process=self.dummy_process) self.job = Job( process=self.dummy_process, wps_request=self.wps_request, wps_response=self.wps_response) def test_default_mode(self): """Test pywps.formats.Format class """ self.assertEqual(configuration.get_config_value('processing', 'mode'), 'default') process = pywps.processing.Process( process=self.dummy_process, wps_request=self.wps_request, wps_response=self.wps_response) # process.start() self.assertTrue(isinstance(process, MultiProcessing)) def test_job_json(self): new_job = Job.from_json(json.loads(self.job.json)) self.assertEqual(new_job.name, 'greeter') self.assertEqual(new_job.uuid, str(self.uuid)) self.assertEqual(new_job.workdir, '/tmp') self.assertEqual(len(new_job.process.inputs), 1) def test_job_dump(self): new_job = Job.load(self.job.dump()) self.assertEqual(new_job.name, 'greeter') self.assertEqual(new_job.uuid, str(self.uuid)) self.assertEqual(new_job.workdir, '/tmp') self.assertEqual(len(new_job.process.inputs), 1)
def test_job_dump(self): new_job = Job.load(self.job.dump()) self.assertEqual(new_job.name, 'greeter') self.assertEqual(new_job.uuid, str(self.uuid)) self.assertEqual(new_job.workdir, '/tmp') self.assertEqual(len(new_job.process.inputs), 1)
def test_job_json(self): new_job = Job.from_json(json.loads(self.job.json)) self.assertEqual(new_job.name, 'greeter') self.assertEqual(new_job.uuid, str(self.uuid)) self.assertEqual(new_job.workdir, '/tmp') self.assertEqual(len(new_job.process.inputs), 1)
def __init__(self, process, wps_request, wps_response): self.job = Job(process, wps_request, wps_response)