Commits

Konstantine Rybnikov committed 88978db

add example.rst and start another-django-tutorial thing

Comments (0)

Files changed (4)

 build
 .DS_Store
 .emacs-project
-
+*.pyc

source/en_posts/2011-03-09-testing-python.rst

 I decided to split article into parts so that it would be easier to
 read.
 
+--------------------------
+ How to read this article
+--------------------------
+
+It is very hard to write a complete article and say everything you
+want to say without being verbose, so as a general, if you are already
+experienced programmer and know what is functional testing and mock
+library, you can skip first paragraphs straight to the
+:doc:`testing_python/going-deeper` doc.
+
 .. toctree::
-   :maxdepth: 1
-   .. :glob:
 
    testing_python/introduction
+   testing_python/example
    testing_python/functional
    testing_python/unit-testing
    testing_python/going-deeper

source/en_posts/testing_python/example.rst

+=================
+ Example program
+=================
+
+.. note::
+
+    This page is a part of :doc:`../2011-03-09-testing-python`
+    post.
+
+Let us write an example program and improve it during the whole
+article. I will sometimes have to add extra-requirements to it just to
+make it more complex, but at most I will do my best to keep it as real
+as possible.
+
+--------------
+ Requirements
+--------------
+
+Let's write a web GTD application. User will be able to
+add/remove/edit tasks he needs to do in future, sync with he's phone
+after offline work and maybe something more that we need (in terms of
+this article).
+
+We will call our application Todo.
+
+-----------------------------
+ Basic todo application code
+-----------------------------
+
+We will create a simple django ``todo`` project and ``tasks`` app.
+
+.. code-block:: bash
+
+    playground ➤ mkvirtualenv todo
+    ...
+    (todo)playground ➤ pip install django
+    ...
+    (todo)playground ➤ django-admin.py startproject todo
+    (todo)todo ➤ python manage.py startapp tasks
+    (todo)playground ➤ cd todo
+    (todo)todo ➤ tree
+    .
+    ├── manage.py
+    ├── tasks
+    │   ├── __init__.py
+    │   ├── models.py
+    │   ├── tests.py
+    │   └── views.py
+    └── todo
+        ├── __init__.py
+        ├── __init__.pyc
+        ├── settings.py
+        ├── settings.pyc
+        ├── urls.py
+        └── wsgi.py
+
+    2 directories, 11 files
+
+As a modern app, let's create a RESTful application. By that we will
+get rid of all the templatings and implement only API that will return
+json, skipping actual JavaScript (or mobile phone) code that will call
+our API.
+
+Here's some basic setup for our urls in ``todo/urls.py``:
+
+.. code-block:: python
+
+    from django.conf.urls import patterns, include, url
+
+    urlpatterns = patterns(
+        '',
+        url(r'^$', 'todo.views.home'),
+        url(r'^tasks/', include('tasks.urls')),
+        url(r'^api/tasks/', include('tasks.api_urls')),
+    )
+
+Since it's not a django tutorial I will not enter all the boring
+details here, the end app will be available in hg repository of this
+blog here 

source/en_posts/testing_python/introduction.rst

 That's why about 4 month ago, when I changed my job, I wanted to do
 things in a test-driven way and see will it really work.
 
-Head over to :doc:`functional` to see how it went.
+Head over to :doc:`example` to see how it went.