Пример #1
0
    def take_action(self, parsed_args):
        _fields = list(FIELDS)
        if parsed_args.long:
            _fields.append(('Result', ))

        result = models.TaskResult.query.get(parsed_args.result_id)
        return utils.fields_from_object(
            _fields,
            result,
            xforms={
                'Task': lambda t: '{0} ({1})'.format(t.name, t.id),
                'Result': lambda r: utils.format_json(r),
            })
Пример #2
0
Файл: result.py Проект: 40a/ara
    def take_action(self, args):
        _fields = list(FIELDS)
        if args.long:
            _fields.append(('Result',))

        result = models.TaskResult.query.get(args.result_id)
        if result is None:
            raise RuntimeError('Result %s could not be found' %
                               args.result_id)

        return utils.fields_from_object(
            _fields, result,
            xforms={
                'Task': lambda t: '{0} ({1})'.format(t.name, t.id),
                'Result': lambda r: utils.format_json(r),
            })
Пример #3
0
 def test_format_json_fail(self):
     res = u.format_json('{invalid:}')
     self.assertEqual(res, '{invalid:}')
Пример #4
0
 def test_format_json(self):
     data = json.dumps({'name': 'value'})
     res = u.format_json(json.dumps(data))
     self.assertEqual(res,
                      '"{\\"name\\": \\"value\\"}"')
Пример #5
0
 def test_format_json(self):
     data = json.dumps({'name': 'value'})
     res = u.format_json(json.dumps(data))
     self.assertEqual(res,
                      '"{\\"name\\": \\"value\\"}"')
Пример #6
0
 def test_format_json_fail(self):
     res = u.format_json('{invalid:}')
     self.assertEqual(res, '{invalid:}')