• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cenobites / flask-jsonrpc / 119 / 1
100%
master: 100%

Build:
Build:
LAST BUILD BRANCH: feature/github-actions
DEFAULT BRANCH: master
Ran 13 Jul 2020 05:04PM UTC
Files 13
Run time 3min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

13 Jul 2020 05:00PM UTC coverage: 100.0%. First build
FLASK_ENV=TESTING

push

travis-ci

nycholas
Fix the JSON-RPC method signature (return) validation

The return of method can't be known before the evaluation. The code
bellow will work on validate, but will break on execution:

```
@jsonrpc.method('add(a=int, b=int)')
def add(a: int, b: int):
    ...
    return 0
```

The test:

```
def test_app_create_with_method_without_annotation_on_return():
    app = Flask(__name__, instance_relative_config=True)
    jsonrpc = JSONRPC(app, '/api', enable_web_browsable_api=True)

    # pylint: disable=W0612
    @jsonrpc.method('app.fn1')
    def fn1(s: str):
        return 'Foo {0}'.format(s)

    # pylint: disable=W0612
    @jsonrpc.method('app.fn2')
    def fn2(s: str) -> str:
        return 'Bar {0}'.format(s)

    with app.test_client() as client:
        rv = client.post('/api', json={'id': 1, 'jsonrpc': '2.0', 'method': 'app.fn1', 'params': [':)']})
        assert rv.json == {
            'error': {
                'code': -32602,
                'data': {
                    'message': 'return type of str must be a type; got NoneType instead'
                },
                'message': 'Invalid params',
                'name': 'InvalidParamsError',
            },
            'id': 1,
            'jsonrpc': '2.0',
        }
        assert rv.status_code == 400

        rv = client.post('/api', json={'id': 1, 'jsonrpc': '2.0', 'method': 'app.fn2', 'params': [':)']})
        assert rv.json == {'id': 1, 'jsonrpc': '2.0', 'result': 'Bar :)'}
        assert rv.status_code == 200
```

Resolves: #77
See also: #74

118 of 118 branches covered (100.0%)

384 of 384 relevant lines covered (100.0%)

1.0 hits per line

Source Files on job 119.1 (FLASK_ENV=TESTING)
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 114
  • Travis Job 119.1
  • 4fddee36 on github
  • Next Job for FLASK_ENV=TESTING on hotfix/77-method-validate (#121.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc