Skip to content

Commit

Permalink
Merge pull request #575 from JJ/develop
Browse files Browse the repository at this point in the history
I found it kind of hard to create a test from the example provided
  • Loading branch information
timothycrosley committed Oct 22, 2017
2 parents 5abb32d + 07730bf commit 4d26316
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -69,3 +69,6 @@ venv/

# Cython
*.c

# Emacs backup
*~
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -105,6 +105,16 @@ import happy_birthday
hug.test.get(happy_birthday, 'happy_birthday', {'name': 'Timothy', 'age': 25}) # Returns a Response object
```

You can use this `Response` object for test assertions (check
out [`test_happy_birthday.py`](examples/test_happy_birthday.py) ):

```python
def tests_happy_birthday():
response = hug.test.get(happy_birthday, 'happy_birthday', {'name': 'Timothy', 'age': 25})
assert response.status == HTTP_200
assert response.data is not None
```


Running hug with other WSGI based servers
===================
Expand Down
8 changes: 8 additions & 0 deletions examples/test_happy_birthday.py
@@ -0,0 +1,8 @@
import hug
import happy_birthday
from falcon import HTTP_400, HTTP_404, HTTP_200

def tests_happy_birthday():
response = hug.test.get(happy_birthday, 'happy_birthday', {'name': 'Timothy', 'age': 25})
assert response.status == HTTP_200
assert response.data is not None

0 comments on commit 4d26316

Please sign in to comment.