Пример #1
0
 def test_json_out_date(self):
     inpt = LiteralInput(
         identifier="date",
         mode=2,
         data_type='date')
     inpt.data = "2017-04-20"
     out = inpt.json
     self.assertEqual(out['data'], datetime.date(2017, 4, 20), 'date set')
Пример #2
0
 def test_json_out_time(self):
     inpt = LiteralInput(
         identifier="time",
         mode=2,
         data_type='time')
     inpt.data = "12:30:00"
     out = inpt.json
     self.assertEqual(out['data'], datetime.time(12, 30, 0), 'time set')
Пример #3
0
    def setUp(self):

        self.literal_input = LiteralInput(identifier="literalinput",
                                          mode=2,
                                          allowed_values=(1, 2, (3, 3, 12)),
                                          default=6,
                                          uoms=(UOM("metre"), ))
Пример #4
0
    def json(self, value):
        """init this request from json back again

        :param value: the json (not string) representation
        """

        self.operation = value['operation']
        self.version = value['version']
        self.language = value['language']
        self.identifier = value['identifier']
        self.identifiers = value['identifiers']
        self.store_execute = value['store_execute']
        self.status = value['status']
        self.lineage = value['lineage']
        self.outputs = value['outputs']
        self.raw = value['raw']
        self.inputs = {}

        for identifier in value['inputs']:
            inpt = None
            inpt_defs = value['inputs'][identifier]

            for inpt_def in inpt_defs:

                if inpt_def['type'] == 'complex':
                    inpt = ComplexInput(
                        identifier=inpt_def['identifier'],
                        title=inpt_def.get('title'),
                        abstract=inpt_def.get('abstract'),
                        workdir=inpt_def.get('workdir'),
                        data_format=Format(
                            schema=inpt_def['data_format'].get('schema'),
                            extension=inpt_def['data_format'].get('extension'),
                            mime_type=inpt_def['data_format']['mime_type'],
                            encoding=inpt_def['data_format'].get('encoding')),
                        supported_formats=[
                            Format(schema=infrmt.get('schema'),
                                   extension=infrmt.get('extension'),
                                   mime_type=infrmt['mime_type'],
                                   encoding=infrmt.get('encoding'))
                            for infrmt in inpt_def['supported_formats']
                        ],
                        mode=MODE.NONE)
                    inpt.file = inpt_def['file']
                elif inpt_def['type'] == 'literal':

                    allowed_values = []
                    for allowed_value in inpt_def['allowed_values']:
                        if allowed_value['type'] == 'anyvalue':
                            allowed_values.append(AnyValue())
                        elif allowed_value['type'] == 'novalue':
                            allowed_values.append(NoValue())
                        elif allowed_value['type'] == 'valuesreference':
                            allowed_values.append(ValuesReference())
                        elif allowed_value['type'] == 'allowedvalue':
                            allowed_values.append(
                                AllowedValue(
                                    allowed_type=allowed_value['allowed_type'],
                                    value=allowed_value['value'],
                                    minval=allowed_value['minval'],
                                    maxval=allowed_value['maxval'],
                                    spacing=allowed_value['spacing'],
                                    range_closure=allowed_value[
                                        'range_closure']))

                    inpt = LiteralInput(identifier=inpt_def['identifier'],
                                        title=inpt_def.get('title'),
                                        abstract=inpt_def.get('abstract'),
                                        data_type=inpt_def.get('data_type'),
                                        workdir=inpt_def.get('workdir'),
                                        allowed_values=AnyValue,
                                        uoms=inpt_def.get('uoms'),
                                        mode=inpt_def.get('mode'))
                    inpt.uom = inpt_def.get('uom')
                    inpt.data = inpt_def.get('data')

                elif inpt_def['type'] == 'bbox':
                    inpt = BBoxInput(identifier=inpt_def['identifier'],
                                     title=inpt_def['title'],
                                     abstract=inpt_def['abstract'],
                                     crss=inpt_def['crs'],
                                     dimensions=inpt_def['dimensions'],
                                     workdir=inpt_def['workdir'],
                                     mode=inpt_def['mode'])
                    inpt.ll = inpt_def['bbox'][0]
                    inpt.ur = inpt_def['bbox'][1]

            if identifier in self.inputs:
                self.inputs[identifier].append(inpt)
            else:
                self.inputs[identifier] = [inpt]
Пример #5
0
    def setUp(self):

        self.literal_input = LiteralInput(identifier="literalinput")
Пример #6
0
    def setUp(self):

        self.literal_input = LiteralInput(
                identifier="literalinput",
                mode=2,
                allowed_values=(1, 2, (3, 3, 12)))