PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tutorial06.rst

https://github.com/hjwp/Test-Driven-Django-Tutorial
ReStructuredText | 267 lines | 157 code | 110 blank | 0 comment | 0 complexity | cf5f2eb2f837aeb6eb2855b36006d39a MD5 | raw file
  1. Part 6 - The Book!
  2. ==================
  3. *[update April 2012] : The book is now coming out on O'Reilly! more info here:*
  4. http://www.tdd-django-tutorial.com/blog/articles/2013/test-driven-development-web-applications-book-exis/
  5. Thanks so much for following on this far! I'm afraid that's all there is for
  6. now, but I am about to start on the next stage -- a proper book on TDD for
  7. web apps.
  8. If you've found the tutorial useful so far, I wonder whether I can solicit
  9. some feeback regarding a book version?
  10. Here's the chapter outline I've got so far. Now, remember, this is a very rough draft,
  11. and it's very much bound to change, but I'd love to hear your thoughts... Especially
  12. about some quite general questions, like:
  13. * Am I broadly covering the right sort of stuff?
  14. * Am I right to spend plenty of time talking about JavaScript, as well as Python?
  15. * What should I choose as my example app? I've written the outline as if it
  16. were a forums app, but I'm starting to see the appeal of one of the other classic
  17. examples, the "to-do list" (very simple at base, can be extended easily, opportunities
  18. for sharing/social bits, plenty of stuff to do on the client-side too...). What
  19. would you choose as an example?
  20. ===============================================
  21. PART 1 - Beginning web app development with TDD
  22. ===============================================
  23. The idea is to dive straight in with a practical example, rather than talking
  24. a lot of theory up-front. I had originally thought to start with a toy example
  25. (cf these 3 abandoned chapters: http://www.tdd-django-tutorial.com/tutorial/6/ ),
  26. but I decided that people prefer real practical stuff to toy examples...
  27. I also want the first few chapters to be very short + bit-sized, so that the
  28. reader feels like they're really making progress quickly... (the inspiration
  29. comes from Kent Beck's TDD by Example, an awesome book)
  30. Essentially part 1 is a re-hash of this online tutorial, using a differnt example
  31. app...
  32. 1: Our first functional test with Selenium
  33. ------------------------------------------
  34. * Briefly discuss difference between functional testing (AKA acceptance
  35. testing, integration testing, whatever) and unit testing
  36. * Write first test - Introduce Selenium, `setUp`, `tearDown`
  37. * Demonstrate we can get it to open a web browser, and navigate to a web page
  38. eg - google.com
  39. 2: Getting Django set-up and running
  40. ------------------------------------
  41. * Change our test to look for the test server
  42. * Switch to Django LiveServerTestCase. Explain
  43. * Get the first test running and failing for a sensible reason
  44. * Create django project `django-admin.py startproject`
  45. * It worked!
  46. 3: A static front page
  47. ----------------------
  48. * Look for "Welcome to the Forums", or similar
  49. * `urls.py`, `direct_to_template` ?
  50. 4: Super-users and the Django admin site
  51. ----------------------------------------
  52. * Extend FT to try and log in
  53. * Explain the admin site
  54. * Database setup, `settings.py`, `syncdb`, `admin.py`
  55. * `runserver` to show login code
  56. * Explain difference between test database and real database
  57. * Fixtures
  58. 5: First unit tests and Database model
  59. --------------------------------------
  60. * Distinction between unit tests and functional tests
  61. * Extend FT to try and create a new topic
  62. * new app
  63. * `models.py`
  64. * test/code cycle
  65. 6: Testing a view
  66. -----------------
  67. * urls.py again
  68. * Test view as a function
  69. * assert on string contents
  70. 7: Django's template system
  71. ----------------------------
  72. * Introduce template syntax
  73. * Keep testing as a function
  74. * The, introduce the Django Test Client
  75. 8: Reflections: what to test, what not to test
  76. -----------------------------------------------
  77. * time for a bit of theory/philosophy
  78. * "Don't test constants"
  79. * Test logic
  80. * Tests for simple stuff should be simple, so not much effort
  81. 9: Simple Forms
  82. ----------------
  83. * Manually coded HTML
  84. * Refactor test classes
  85. 10: User Authentication
  86. -----------------------
  87. * Sign up, login/logout
  88. * Email?
  89. 11: More advanced forms
  90. -----------------------
  91. * Use Django Forms classes
  92. 12: On Refactoring
  93. ------------------
  94. * Martin Fowler
  95. * Tests critical
  96. * Methodical process - explain step by step
  97. 13: Pagination
  98. --------------
  99. * Extend various old unit tests and FTs
  100. ======================================================
  101. PART 2: More advanced testing for a more advanced site
  102. ======================================================
  103. 14: Notifications
  104. ------------------------------
  105. * Django Notifications, for post edits
  106. 15: Adding style with MarkDown
  107. ------------------------------
  108. * Using an external library
  109. 16: Switching to OAuth: Mocking
  110. -------------------------------
  111. * "Don't store passwords"
  112. * Discuss challenges of external dependencies
  113. 17: Getting Dynamic: Testing Javascript part 1
  114. ----------------------------------------------
  115. * Simple input validation
  116. * Choose JS unit testing framework (probably Qunit, or YUI)
  117. 18: Testing Javascript part 2 - Ajax
  118. ------------------------------------
  119. * Dynamic previews of post input
  120. 19: Getting pretty: Bootstrap
  121. -----------------------------
  122. * Bring in nicer UI elements
  123. 20: Getting pretty: Gravatar
  124. ----------------------------
  125. * pictures for users
  126. ==============================
  127. PART 3: Getting seriously sexy
  128. ==============================
  129. 21: Getting serious about the client-side + single-page website?
  130. ----------------------------------------------------------------
  131. * Introduce one of the client-side js frameworks -- backbone.js / ember.js / angular
  132. 22: Switching Databases 1: PostgreSQL
  133. ----------------------------------------------
  134. * show how Django makes this easy
  135. 23: Websockets and Async on the server-side
  136. -------------------------------------------
  137. * we want dynamic notifications of when new posts appear on a thread we're
  138. looking at
  139. * Need to spin up, Tornado/Twisted/Gevent as well as Django LiveServerTestCase
  140. * FT opens multiple browser tabs in parallel
  141. * Big change!
  142. 24: Switching Databases 2: NoSQL and MongoDB
  143. ----------------------------------------------
  144. * obligatory discussion of NoSQL and MongoDB
  145. * descrine installation, particularities of testing
  146. 26: Continuous Integration
  147. --------------------------
  148. * Need to build 3 server types
  149. * Jenkins (or maybe buildbot)
  150. * Need to adapt Fts, maybe rely less on LiveServerTestCase
  151. 27: Caching for screamingly fast performance
  152. --------------------------------------------
  153. * unit testing `memcached`
  154. * Functionally testing performance
  155. * Apache `ab` testing
  156. Well, that's what I have so far. What do you think? Have I missed anything
  157. out? Does anything seem superfluous? Most importantly, would you buy it?