-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing in the tutorial #934
Conversation
Codecov Report
@@ Coverage Diff @@
## master #934 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 31 31
Lines 2107 2031 -76
Branches 338 328 -10
=====================================
- Hits 2107 2031 -76
Continue to review full report at Codecov.
|
d17080f
to
7863f8f
Compare
Pep8 checks for import order on my example files are failing. I can make them pass, but the order they require is bizarre (from
As I understand, PEP8 encourages standard/third-party/own (and alphabetical order in each section) import order. |
4c68eef
to
e50bfbd
Compare
@kgriffs Ok, I think I'm done. That's a big chunk of docs there... Hope you like it. But I still have the problem with pep8 mentioned above. Oh, and I've pointed to my own library in the section about functional tests, is that ok? |
@kgriffs Any update? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really, this is an impressive tutorial, and will be a super helpful addition to the docs. Thank you! I added a number of suggestions inline, but most of them are fairly nitpicky. Thanks again!
docs/user/tutorial.rst
Outdated
powered REPL that is good to have in your toolbox when | ||
exploring a new library. | ||
`bpython <http://bpython-interpreter.org/>`_ or | ||
`ptpython <https://github.com/jonathanslenders/ptpython>`_ are another |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: "are another" ==> "are other"
@@ -144,6 +164,8 @@ and add the following to it: | |||
|
|||
def on_get(self, req, resp): | |||
resp.body = '{"message": "Hello world!"}' | |||
# This line can be ommited, because 200 is the default code falcon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
Gunicorn has still limitation that is not working on Windows. If you are Windows user you can use Waitress server instead Gunicorn | ||
|
||
.. code:: bash | ||
|
||
$ pip install waitress | ||
$ waitress-serve --port=8000 app:api | ||
$ waitress-serve --port=8000 look.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I modified this manually to resolve a merge conflict with the latest code in master.
docs/user/tutorial.rst
Outdated
Testing your application | ||
------------------------ | ||
|
||
Up to this point we didn't care about tests, but when creating applications |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could make the second clause in this sentence more compelling. What do you think about something like the following?
Up to this point we didn't care about tests, but fully exercising your code is critical to creating robust applications with a great user experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
docs/user/tutorial.rst
Outdated
Up to this point we didn't care about tests, but when creating applications | ||
that will be used by someone you should have those. So, as an exercise, we'll create | ||
the next piece of code in accordance with `Test Driven Development | ||
<http://www.obeythetestinggoat.com/book/praise.harry.html>`_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this guide is Django-centric, is there a more generic TDD reference that we might use instead? Alternatively, it may make sense to include a note about how the linked guide uses Django for its examples, but the principles and workflow are the same, regardless of what web framework you use.
(Don't get me wrong, Django is a great choice for many use cases. I just want to make sure we are taking the reader's context into consideration.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... this one is the best I know, even though I'm not a fan of Django :) I'll add a note with explanations.
docs/user/tutorial.rst
Outdated
they don't check anything more than ``test_posted_image_gets_saved``. But we can | ||
do that only because we have a very simple application logic. | ||
|
||
Normally, you would check component integration and few more meaningful logic paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and few more meaningful logic paths
===>
and all primary logic paths
docs/user/tutorial.rst
Outdated
do that only because we have a very simple application logic. | ||
|
||
Normally, you would check component integration and few more meaningful logic paths | ||
through the entire application with functional tests, and leave the bulk of testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"through" ===> "throughout"
docs/user/tutorial.rst
Outdated
|
||
Normally, you would check component integration and few more meaningful logic paths | ||
through the entire application with functional tests, and leave the bulk of testing | ||
to unit tests. But the actual ratio of unit/functional tests depend entirely on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"depend" ===> "depends"
"on applications problem domain and will vary." ===> "on each application's problem domain, and will vary."
docs/user/tutorial.rst
Outdated
to unit tests. But the actual ratio of unit/functional tests depend entirely on | ||
applications problem domain and will vary. | ||
|
||
After this section we won't be doing TDD anymore as you should have a good grip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"we won't be doing TDD anymore as you" ==> "we'll omit the TDD instructions, as you..."
docs/user/tutorial.rst
Outdated
applications problem domain and will vary. | ||
|
||
After this section we won't be doing TDD anymore as you should have a good grip | ||
of testing in Falcon by now. Instead, we'll focus on showcasing some more of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"in Falcon" ===> "Falcon applications"
@kgriffs Good that it's finally going somewhere :-) I'm quite busy now, but I'll try to go over your suggestions in a week or two. |
@butla do you think you'll have some time to work on this over the next few days? It would be great to get this in the docs for 1.2 if we can. |
@kgriffs I may be able to work on this on Tuesday, if not, then definitely on Wednesday :) |
@butla cool, sounds good. Thanks! |
@kgriffs That was quite a thorough review you did there :)
After all of those are resolved, I'll try to squash my commits and rebase onto the current master. |
Ok, so I've already did the changes with PNG as the image type everywhere and with sending the images with redirect to http. I'll also try to squash and rebase my changes onto master on a different branch. |
All right, so if my changes are OK, I'll forcibly push my "squash" branch onto my "master", and this will be ready to merge... Once we resolve the issue of the strange import order in the code samples :) Or should I just put the imports in the order the tool wants it? Oh, and one more thing, during squashing I've rephrased two sentences that looked clunky to me. butla@b2:~/development/falcon$ git diff master squash -- docs/user/tutorial.rst
diff --git a/docs/user/tutorial.rst b/docs/user/tutorial.rst
index 8025490..9a0a0f2 100644
--- a/docs/user/tutorial.rst
+++ b/docs/user/tutorial.rst
@@ -109,9 +109,9 @@ let's use something that you would actually deploy in production.
$ pip install gunicorn
$ gunicorn look.app
-
-Gunicorn has still limitation that is not working on Windows.
-If you are Windows user you can use Waitress server instead Gunicorn
+
+If you are a Windows user, then use Waitress instead of Gunicorn, since the latter
+doesn't work under Windows.
.. code:: bash
@@ -1065,7 +1065,10 @@ such as `IPython <http://ipython.org/>`_ or
Also, don't be shy about pulling up Falcon's source code on GitHub or in your
favorite text editor. The team has tried to make the code as straightforward
-and readable as possible; where other documentation may fall short, the code basically
-"can't be wrong."
-
+and readable as possible; where other documentation may fall short, the code
+basically "can't be wrong."
+A number of Falcon add-ons, templates, and complimentary packages are
+available for use in your projects. We've listed several of these on the
+`Falcon wiki <https://github.com/falconry/falcon/wiki>`_ as a starting
+point, but you may also wish to search PyPI for additional resources. |
Those changes LGTM. Thanks! |
When the Falcom framework tests run with
@butla Everything LGTM. Let's go ahead get this squashed. Thanks! |
@kgriffs Ok, that shed some light on the order but I was still left with a strange order (builtin -> local -> external -> falcon) in the test for the sample app. import io
from unittest.mock import call, MagicMock, mock_open
import look.app
import look.images
import msgpack
import pytest
import falcon
from falcon import testing
import falcon.request_helpers Anyway, I made the imports look like that, rebased onto the current master, and put that on my master, so it should be ready to merge. |
OK, I think this is ready to merge! I can play around with the pep8 tox env to see if I can fix the import issue. I'll probably need to create some additional tox env(s) just for testing the example. |
This aims to solve #253.
It's currently a work in progress.
@kgriffs Do you think I'm going in the right way with incorporating TDD into the tutorial?
Doesn't it break the flow or tone too much?
Also, do you have some deadline for the tutorial? Because I probably won't be able to work on it for a week now.