コード例 #1
0
    def test_generate_from_config(self):
        fd, filepath = tempfile.mkstemp()
        os.close(fd)

        with open(filepath, 'w') as f:
            f.write(CONFIG)

        schema = gen.generate_from_config(filepath)

        self.assertEqual(
            schema.todict(), {
                'dummy': {
                    '0.1.0': {
                        'methods': {
                            'rpc_method': {
                                'name': 'rpc_method',
                                'args': ['values'],
                                'kwargs': {
                                    'foo': None
                                },
                                'doc': 'a dummy rpc function',
                                'raises': ['ValueError'],
                                'returns': {},
                            },
                            'raw_rpc_method': {
                                'name': 'raw_rpc_method',
                                'args': ['values'],
                                'kwargs': {},
                                'doc': '',
                                'raises': [],
                                'returns': {},
                            },
                        },
                    },
                    '1.0.2': {
                        'methods': {
                            'another_rpc_method': {
                                'name': 'another_rpc_method',
                                'args': ['values'],
                                'kwargs': {},
                                'doc': '',
                                'raises': ['TypeError', 'ValueError'],
                                'returns': {},
                            },
                        },
                    },
                }
            })
コード例 #2
0
    def test_generate_from_config(self):
        fd, filepath = tempfile.mkstemp()
        os.close(fd)

        with open(filepath, 'w') as f:
            f.write(CONFIG)

        schema = gen.generate_from_config(filepath)

        self.assertEqual(schema.todict(), {
            'dummy': {
                '0.1.0': {
                    'methods': {
                        'rpc_method': {
                            'name': 'rpc_method',
                            'args': ['values'],
                            'kwargs': {'foo': None},
                            'doc': 'a dummy rpc function',
                            'raises': ['ValueError'],
                            'returns': {},
                        },
                        'raw_rpc_method': {
                            'name': 'raw_rpc_method',
                            'args': ['values'],
                            'kwargs': {},
                            'doc': '',
                            'raises': [],
                            'returns': {},
                        },
                    },
                },
                '1.0.2': {
                    'methods': {
                        'another_rpc_method': {
                            'name': 'another_rpc_method',
                            'args': ['values'],
                            'kwargs': {},
                            'doc': '',
                            'raises': ['TypeError', 'ValueError'],
                            'returns': {},
                        },
                    },
                },
            }
        })
コード例 #3
0
ファイル: generator.py プロジェクト: ramovsky/lymph-schema-1
    def run(self):
        config_file = self.args['<config>']

        schema = gen.generate_from_config(config_file)
        print json.dumps(schema.todict(), indent=4)