def test_deserialize(self):
        source = Source('/source.jpg')
        destination = Destination('/path.png', None, ACL.private)

        data = {
            'job': {
                'status': 'pending',
                'dateCreated': '2001-12-25T00:00:00Z',
                'sources': [],
                'result': None,
                'id': 'group-id_job-key',
                'issuer': 'urn:member:xxx',
                'specification': {
                    'source': source.serialize(),
                    'destination': destination.serialize(),
                    'extractedFilesReport': {
                        'destination': destination.serialize(),
                        'format': 'json'
                    }
                },
                'groupId': 'group-id',
                'flowId': None,
                'dateUpdated': '2001-12-25T00:00:00Z',
                'type': 'urn:job:archive.extract'
            },
            'attachment': {
                'dog': 'bull'
            }
        }

        payload = JobCallbackPayload.deserialize(data)

        assert_that(payload.attachment, is_({'dog': 'bull'}))
        assert_that(payload.job.id, is_('group-id_job-key'))
Exemplo n.º 2
0
    def test_serialize(self):
        destination = Destination('/fish.jpg')

        assert_that(
            destination.serialize(),
            is_({
                'directory': None,
                'path': '/fish.jpg',
                'lifecycle': None,
                'acl': 'public',
                'bucket': None
            }))
Exemplo n.º 3
0
from media_platform.job.job import Job
from media_platform.service.source import Source

source = Source('/source.jpg')
destination = Destination('/path.png', acl=ACL.private)

data = {
    'status': 'pending',
    'dateCreated': '2001-12-25T00:00:00Z',
    'sources': [source.serialize()],
    'result': None,
    'id': 'group-id_job-key',
    'issuer': 'urn:member:xxx',
    'specification': {
        'source': source.serialize(),
        'destination': destination.serialize(),
        'extractedFilesReport': {
            'destination': destination.serialize(),
            'format': 'json'
        }
    },
    'groupId': 'group-id',
    'flowId': None,
    'dateUpdated': '2001-12-25T00:00:00Z',
    'type': 'urn:job:archive.extract',
    'callback': None
}

frozen_time = datetime_serialization.deserialize('2001-12-25T00:00:00Z')

extraction_report = ExtractionReport(destination, ExtractionReportFormat.json)