Test-Driven Development with Python: Obey the Testing Goat Using Django

This book is my endeavor to impart to the world the excursion I’ve taken from “hacking” to “computer programming”. Test-Driven Development with Python: Obey the Testing Goat Using Django It’s predominantly about testing, yet there’s something else entirely to it, as you’ll before long see.

Test-Driven Development with Python: Obey the Testing Goat  Using Django

I need to thank you for understanding it.

On the off chance that you purchased a duplicate, I’m extremely appreciative. Assuming you’re perusing the free web-based form, then, at that point, I’m as yet appreciative that you’ve chosen it merits investing a portion of your energy in. Who knows, maybe once you get as far as possible, you’ll choose it’s adequate to purchase a genuine duplicate for yourself or for a companion.

Assuming that you have any remarks, questions, or ideas, I’d very much want to hear from you. You can contact me straightforwardly by means of [email protected], or on Twitter @hjwp. You can likewise look at the site and my blog, and there’s a mailing list. I trust you’ll appreciate perusing this book however much I delighted recorded as a hard copy it.

Also Read:- 500 Most Important Data Science Interview Questions and Answers PDF

Why I Wrote a Book About Test-Driven Development

“Who are you, for what reason are you composing this book, and for what reason would it be a good idea for me I read it?” I hear you inquire. I’m still very from the get-go in my programming profession. They say that in any discipline, you go from disciple to apprentice, and in the long run, now and then, on to dominate. I’d say that I’m, best-case scenario, an understudy software engineer.

In any case, I was sufficiently fortunate, almost immediately in my profession, to fall in with a lot of TDD enthusiasts, and it had such a major effect on my programming that I’m consuming to impart it to everybody. You could say I have the energy of a new proselyte, and the growth opportunity is as yet a new memory for me, so I trust I can in any case identify with fledglings.

Whenever I originally scholarly Python (from Mark Pilgrim’s great Dive Into Python), I came across the idea of TDD and thought “Yes. I can see the sense in that”. Maybe you had a comparative response when you originally caught wind of TDD? It seems like a

truly reasonable methodology, a truly beneficial routine to get into-like consistently flossing your teeth or something like that.

Then, at that point, came my first enormous undertaking, and you can think about what happened there was a client, there were cutoff times, there were parts to do, and any well-meaning goals about TDD went straight out of the window.

Also read:-Flask Web Development: Developing Web Applications with Python

Furthermore, really, it was fine. I was fine.

From the start.

At first, I realized I didn’t actually require TDD in light of the fact that it was a little site, and I could undoubtedly test whether things worked by physically looking at it. Click this connection here, pick that drop-down thing there, and this ought to occur. Simple. The subject of composing tests
seemed like it would have taken ages, furthermore, I liked myself, from the full tallness of my three weeks of grown-up coding experience, similar to a very decent software engineer. I could deal with it. Simple.

Then, at that point, came the unfortunate goddess Complexity. She before long showed me the restrictions of my
experience.

The task developed. Portions of the framework began to rely upon different parts. I gave my all to follow great standards like DRY (Don’t Repeat Yourself), however that just prompted some lovely perilous region. Before long I was playing with different legacy. Class orders 8 levels profound. eval articulations.

I became frightened of making changes to my code. I was presently not certain what relied upon what, and what could occur assuming I changed this code here, goodness gosh, I feel that piece around there acquires from it-no, it doesn’t, it’s overriden. Gracious, yet it relies upon that class variable. Right, indeed, as long as I abrogate the supersede it should be fine.

I’ll simply check -however, checking was getting a lot harder. There were bunches of areas to the site now, furthermore navigating them all physically was beginning to get unrealistic. Better to leave alright alone, forget refactoring, simply manage.

Also Read:- Web Scraping with Python: Collection from the Modern Web PDF Download

Aims of This Book

My fundamental point is to grant a system an approach to doing web improvement, which I think makes for better web applications and more joyful designers. There’s very little point in a book that simply covers material you could find by researching, so this book isn’t a manual for Python language structure, or an instructional exercise on web advancement in essence. All things considered, I desire to instruct you step by step instructions to utilize TDD to get all the more dependably to our common, sacred objective: clean code that works.

All things considered: I will continually allude to a genuinely pragmatic model, by building a web application without any preparation utilizing apparatuses like Django, Selenium, jQuery, and Mock. I’m not accepting any earlier information on any of these, so you should emerge from the opposite finish of this book with a good prologue to those devices, as well as the discipline of TDD.

Also read:- A step-by-step guide on building Django websites, 2nd Edition PDF

In Extreme Programming we generally pair-program, so I’ve envisioned composing this book as though I was blending with my past self, clarifying how the instruments work and reply inquiries concerning why we code in this specific manner. In this way, on the off chance that I at any point take somewhat of a belittling tone, this is on the grounds that I’m not too savvy, and I must be exceptionally quiet with myself.

What’s more, assuming I at any point strong cautious, this is on the grounds that I’m the sort of irritating individual that methodically contradicts whatever any other person says, so at times it takes a ton of advocating to persuade myself regarding anything

Part I. The Basics of TDD and Django

  1. Getting Django Set Up Using a Functional Test. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
  2. Extending Our Functional Test Using the unittest Module. . . . . . . . . . . . . . . . . . . . . . . . 13
  3. Testing a Simple Home Page with Unit Tests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
  4. What Are We Doing with All These Tests?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
  5. Saving User Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
  6. Getting to the Minimum Viable Site. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Part II. Web Development Sine Qua Nons

  1. Prettification: Layout and Styling, and What to Test About It. . . . . . . . . . . . . . . . . . . . 115
  2. Testing Deployment Using a Staging Site. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
  3. Automating Deployment with Fabric. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
  4. Input Validation and Test Organisation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
  5. A Simple Form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
  6. More Advanced Forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
  7. Dipping Our Toes, Very Tentatively, into JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
  8. Deploying Our New Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

Part III. More Advanced Topics

  1. User Authentication, Integrating Third-Party Plugins, and Mocking with JavaScript. 241
  2. Server-Side Authentication and Mocking in Python. . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
  3. Test Fixtures, Logging, and Server-Side Debugging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
  4. Finishing “My Lists”: Outside-In TDD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
  5. Test Isolation, and “Listening to Your Tests”. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
  6. Continuous Integration (CI). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
  7. The Token Social Bit, the Page Pattern, and an Exercise for the Reader. . . . . . . . . . . . 387
  8. Fast Tests, Slow Tests, and Hot Lava. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
    Obey the Testing Goat!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
    A. PythonAnywhere. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
    B. Django Class-Based Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
    C. Provisioning with Ansible. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
    D. Testing Database Migrations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
    E. What to Do Next. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
    F. Cheat Sheet. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
    G. Bibliography. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
    Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

Test-Driven Development with Python: Obey the Testing Goat Using Django PDF Download

Leave a Comment