Skip to content

Commit

Permalink
Merge pull request #745 from akaihola/744-extend_api-cli
Browse files Browse the repository at this point in the history
Add unit test for `extend_api()` with CLI commands (#744)
  • Loading branch information
timothycrosley committed Mar 19, 2019
2 parents fe1b10d + c0e110c commit 2fb53b8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Changelog
=========

### 2.4.4 - TBD
- Add unit test for `extend_api()` with CLI commands
- Fix running tests using `python setup.py test`
- Documented the `multiple_files` example

Expand Down
7 changes: 7 additions & 0 deletions tests/module_fake_http_and_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import hug


@hug.get()
@hug.cli()
def made_up_go():
return 'Going!'
13 changes: 13 additions & 0 deletions tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,19 @@ def extend_with():
assert hug.test.get(api, '/api/made_up_hello').data == 'hello'


def test_extending_api_with_http_and_cli():
"""Test to ensure it's possible to extend the current API so both HTTP and CLI APIs are extended"""
import tests.module_fake_http_and_cli

@hug.extend_api(base_url='/api')
def extend_with():
return (tests.module_fake_http_and_cli, )

assert hug.test.get(api, '/api/made_up_go').data == 'Going!'
assert tests.module_fake_http_and_cli.made_up_go() == 'Going!'
assert hug.test.cli(tests.module_fake_http_and_cli.made_up_go) == 'Going!'


def test_cli():
"""Test to ensure the CLI wrapper works as intended"""
@hug.cli('command', '1.0.0', output=str)
Expand Down

0 comments on commit 2fb53b8

Please sign in to comment.