Journey Through Django–Functionally Speaking

Yet Another Mistake

Last week, I was working on the unit tests for the location form. I setup two functions, one for the actual content of the page, one for the behavior of the form. The main thing I’m testing in this case is the latitude & longitude being saved into the session. Now, user session data is a big enough topic to warrant a blog post on its own. The long-and-short of it is, user session data is temporary storage while the site is being used, and gets deleted when they close the browser.

Here’s where I went wrong: the latitude & longitude won’t be saved until the user enters their zip/postal code, so there’s no way of testing this without user involvement. I’m sure that I must be a masochist on some level by simultaneously learning a new framework and a new way to do testing. Sometimes, deciphering which challenge is framework-related, and which one is test-related feels like playing 3-dimensional Boggle using Russian & Chinese letters.

Next Step(s)

I’ve started working on the functional tests for the location. At this point, I’m using one valid & one invalid zip/postal code for my tests. I’m sure there are probably 10^6 edge-cases that could break it, but at this point, I’m going for basic functionality. Also, thinking of what might happen if someone enters a thousand Euro signs or alternate between umlaut’s & backticks would be counter-productive.

Here’s hoping I’ve moved on to the next section of the app by this time next week!

Leave a Reply