Auth testing scripts – Now with Python modules :)

I thought yesterday’s post describing my progress was nice. However when I showed it to Dinis, he said ‘Yeah nice’ but you need to make it into modules. And there’s too much code duplication everywhere. (Ouch)*

After the usual initial mental denial of ‘No No my way is best’ it did make sense. Think about it. How would it look if I had just main() and no functions at all? Awful. All the principles of development which I know(not too many ;)) and which I don’t know(many) would most certainly be violated. So we have functions. And I use those a lot.

But what if…you want to reuse just those functions itself? So you have a “connect” function which gets the WSDL of the TeamMentor Webservice. That’s something very generic and you would want to re-use that. As is. No modification. If that’s the case, you’d have to copy the code into your “new” code and call it as a function. That’ll work. What if you have 20 such functions? Copy 20 times. 20 pieces of the same code lying everywhere. All doing the same thing. Works. Yes. Efficient. No. Sorry 🙂

So we use these things called Python Modules. 1 copy of the code only. Any one wants to reuse it ? Import the module. Call the function. So I played around with all my code to make it more modular(HaHa..jargon). And that code is of course on Git. Looks cleaner. I’m storing responses too if needed. And of course XML reports for ‘processing by other tools’…whatever that means.

Yes that’s all. What more did you think I’d say? 🙂

Advertisements
This entry was posted in WebServices. Bookmark the permalink.

One Response to Auth testing scripts – Now with Python modules :)

  1. Dinis Cruz says:

    Yes, much nicer, those modules make a massive difference, since you can now reuse code and create simpler tests

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s