-
-
Notifications
You must be signed in to change notification settings - Fork 933
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(tutorial): Work on testing in progress.
- Loading branch information
Showing
10 changed files
with
174 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Tutorial application | ||
==================== | ||
|
||
This is the application that you can build by going along with the tutorial. | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import falcon | ||
|
||
from .images import Resource | ||
|
||
|
||
api = application = falcon.API() | ||
|
||
images = Resource() | ||
api.add_route('/images', images) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import falcon | ||
|
||
import msgpack | ||
|
||
|
||
class Resource(object): | ||
|
||
def on_get(self, req, resp): | ||
resp.data = msgpack.packb({'message': 'Hello world!'}) | ||
resp.content_type = 'application/msgpack' | ||
resp.status = falcon.HTTP_200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
falcon==1.1.0rc1 | ||
gunicorn==19.6.0 | ||
msgpack-python==0.4.8 | ||
python-mimeparse==1.6.0 | ||
six==1.10.0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
py==1.4.31 | ||
pytest==3.0.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import falcon | ||
from falcon import testing | ||
import msgpack | ||
import pytest | ||
|
||
from look.app import api | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
return testing.TestClient(api) | ||
|
||
|
||
# Pytest will inject the object returned by "client" function as a parameter | ||
# for this function. | ||
def test_get_message(client): | ||
doc = {u'message': u'Hello world!'} | ||
|
||
response = client.simulate_get('/images') | ||
result_doc = msgpack.unpackb(response.content, encoding='utf-8') | ||
|
||
assert result_doc == doc | ||
assert response.status == falcon.HTTP_OK |