Skip to main content

Posts

Showing posts from April, 2013

Testing With Python: The Django Way Part 2

This is the second part of what I started here.
You can read the first post of Testing With Python: The Django Way to understand this one.

Now where were we?
The last time we left at test data. Now we will delve into requests.

GET Requests

The easiest of your views to test are the ones that only handle GET requests. All you have to do is retrieve the correct item from the database and display the information. Let's use the canonical book/author/publisher example. Suppose we're testing a view that displays the details for a particular book. 


def test_book_detail(self):     testbook = Book.objects.all()[0]     url = '/books/id/' + str(testbook.id)     response = self.client.get(url)     self.assertContains(response, testbook.title)
The first thing I want to stress, is that I think it's important that no specific test data is used in the tests. Always try to select objects you're going to use for your tests in a generic way. This way it won't matter how your test da…

Testing With Python: The Django Way Part 1

One thing I really slacked on while developing AWiKi (it's on internal network hence can't show you) was testing. Maybe that's not the right way to put it. It's not like I didn't test. In fact, I did a lot of testing. A lot of painstaking manual testing. For every change. So, in a way it was really the opposite of slacking. It was working a whole lot harder than I really needed to. It was also dumb.
Being conversant in conventional Automation methods I quickly tried my hands on automating a few scenarios using QTP and Selenium. But this soon led me to a more severe problem: I was surrounded with uncountable number of scenarios I needed to automate and soon it was eating more time than I was devoting in the development.
Soon I realized What I did slack on, was figuring out how Django's unit testing framework worked. Well, no more! In fact, it's really easy to set up. Writing tests can also be somewhat painstaking when it comes to ensuring you've covered ev…

Maximum Call Stack size exceeded: My mishap with nodejs and MongoDB

Working with nodejs is always an adventure and mix MongoDB with it, and it becomes very interesting for a nodejs enthusiast like me.

While working on a pet project involving Native MongoDb driver and nodejs I encountered a weird problem.

RangeError:MaximumcallstacksizeexceededAs usual my first thought was to Google out what I was facing and googling it out led me to the following to links.RangeError: Maximum call stack size exceededCalling Model.collection.save() RangeError: Maximum call stack size exceeded Also In some posts in MongoDB’s forum I saw that peoples said saving in `process.nextTick` or wrapping the call function in `parseInt` will also fix the problem, but it most certainly didn't work for me.So I started digging in on my own and soon enough found the reason.

If you’re trying to save a document and saving process somehow exited with an RangeError: Maximum call stack size exceeded exception, it’s related to what you want to save in the database. I had this problem a…

April Fool and Google (2013): Collection of All Google’s April Fools Jokes

Every year, Google goes all out for April Fools’ Day. The company not only pulls together more jokes than all the other tech giants, but the company makes a point to outdo itself too. It honestly gets difficult to keep track of everything Google thinks up, so Like Last Year I'm putting together a roundup.

1. Google Maps Treasure Mode
First up, Google has created a new treasure map mode on Google Maps. Last year, the company showed off an 8-bit version, but this year it wants you to go out and explore 2D hand drawn landmarks, find hidden treasure chests, and “Beaware of pirates!” (yep, that’s a typo).
Google’s announcement talks of the Google Maps Street View team finding a treasure map belonging to the infamous pirate, William “Captain” Kidd, on a recent expedition in the Indian Ocean to expand its underwater Street View collection. The map contains a variety of encrypted symbols which you are tasked with deciphering: Google’s headquarters naturally gets a special flag:
2. YouTube…