Example #1
0
 def test_deserialize(self):
     job_1, job_2, job_3, job_4, job_5 = (Job('spam'), Job('eggs'),
                                          Job('ham'), Job('python'),
                                          Job('answer_42'))
     pipeline = Pipeline({job_1: job_2, job_2: (job_3, job_4), job_5: None},
                         data={'key': 42})
     serialized = pipeline.serialize()
     new_pipeline = Pipeline.deserialize(serialized)
     self.assertEqual(pipeline, new_pipeline)
     self.assertEqual(serialized, new_pipeline.serialize())
Example #2
0
 def test_deserialize(self):
     job_1, job_2, job_3, job_4, job_5 = (Job('spam'), Job('eggs'),
                                          Job('ham'), Job('python'),
                                          Job('answer_42'))
     pipeline = Pipeline({
         job_1: job_2,
         job_2: (job_3, job_4),
         job_5: None
     },
                         data={'key': 42})
     serialized = pipeline.serialize()
     new_pipeline = Pipeline.deserialize(serialized)
     self.assertEqual(pipeline, new_pipeline)
     self.assertEqual(serialized, new_pipeline.serialize())
Example #3
0
    def test_should_send_add_pipeline_with_serialized_pipeline(self):
        result, pool = run_in_parallel(send_pipeline)
        message = self.api.recv_json()
        received = Pipeline.deserialize(message['pipeline']).serialize()
        expected = self.pipeline.serialize()
        self.assertEqual(set(message.keys()), set(['command', 'pipeline']))
        self.assertEqual(message['command'], 'add pipeline')
        self.assertEqual(received, expected)

        pipeline_id = uuid4().hex
        self.api.send_json({'answer': 'pipeline accepted',
                            'pipeline id': pipeline_id})
        result.get()
        pool.terminate()
Example #4
0
    def test_should_send_add_pipeline_with_serialized_pipeline(self):
        result, pool = run_in_parallel(send_pipeline)
        message = self.api.recv_json()
        received = Pipeline.deserialize(message['pipeline']).serialize()
        expected = self.pipeline.serialize()
        self.assertEqual(set(message.keys()), set(['command', 'pipeline']))
        self.assertEqual(message['command'], 'add pipeline')
        self.assertEqual(received, expected)

        pipeline_id = uuid4().hex
        self.api.send_json({
            'answer': 'pipeline accepted',
            'pipeline id': pipeline_id
        })
        result.get()
        pool.terminate()
Example #5
0
    def test_serialize(self):
        job_1, job_2, job_3, job_4 = (Job('spam'), Job('eggs'), Job('ham'),
                                      Job('python'))
        pipeline = Pipeline({job_1: job_2, job_2: (job_3, job_4)})
        result = pipeline.serialize()
        expected = {'graph': ((job_1.serialize(), job_2.serialize()),
                              (job_2.serialize(), job_3.serialize()),
                              (job_2.serialize(), job_4.serialize())),
                    'data': None}
        expected = tuple(expected.items())

        result = dict(result)
        expected = dict(expected)
        result['graph'] = dict(result['graph'])
        expected['graph'] = dict(expected['graph'])
        self.assertEqual(result, expected)

        pipeline = Pipeline({job_1: job_2}, data={'python': 42})
        self.assertEqual(pipeline, Pipeline.deserialize(pipeline.serialize()))
Example #6
0
    def test_serialize(self):
        job_1, job_2, job_3, job_4 = (Job('spam'), Job('eggs'), Job('ham'),
                                      Job('python'))
        pipeline = Pipeline({job_1: job_2, job_2: (job_3, job_4)})
        result = pipeline.serialize()
        expected = {
            'graph':
            ((job_1.serialize(), job_2.serialize()),
             (job_2.serialize(), job_3.serialize()), (job_2.serialize(),
                                                      job_4.serialize())),
            'data':
            None
        }
        expected = tuple(expected.items())

        result = dict(result)
        expected = dict(expected)
        result['graph'] = dict(result['graph'])
        expected['graph'] = dict(expected['graph'])
        self.assertEqual(result, expected)

        pipeline = Pipeline({job_1: job_2}, data={'python': 42})
        self.assertEqual(pipeline, Pipeline.deserialize(pipeline.serialize()))