Tuesday
Jul102007
Emulating Flickr
Tuesday, July 10, 2007 at 11:40PM
I've been working on FlickrExport 3 for a couple of weeks now and one of the things I started off doing was building tools to make testing easier and more predictable.
Unit testing using Xcode's built-in framework remains a pain in the buttocks. Given the large amount of asynchronous NSURLConnection code used in FlickrExport, all the test cases exit before the results arrive. What I've been working on isn't a replacement for unit testing, but it's a tool that makes repeatable Flickr testing significantly faster and easier.
The trick is basically to replace Flickr :-)
I wrote a small app, using Jon Wight's nifty ToxicHTTP framework, that listens on localhost:8080. It parses calls to the Flickr REST endpoint, then looks for a file in a particular directory with the name of the method and returns the contents of that file. It's extremely useful, because it lets me have several different scenarios of simulated 'Flickr' behaviour and have the fake Flickr server respond identically every time. As you might expect, it's also significantly faster to test uploading to localhost than to Flickr!
The idea for this came from a conversation with David Masters at WWDC. I just wrote it in Cocoa, because that's what I do, but similar ideas could probably be knocked together in PHP in half an hour.
If you're working with a remote service that you don't control, consider taking them out of the loop. Just be sure that your emulator remains faithful to the actual deployed service.
Unit testing using Xcode's built-in framework remains a pain in the buttocks. Given the large amount of asynchronous NSURLConnection code used in FlickrExport, all the test cases exit before the results arrive. What I've been working on isn't a replacement for unit testing, but it's a tool that makes repeatable Flickr testing significantly faster and easier.
The trick is basically to replace Flickr :-)
I wrote a small app, using Jon Wight's nifty ToxicHTTP framework, that listens on localhost:8080. It parses calls to the Flickr REST endpoint, then looks for a file in a particular directory with the name of the method and returns the contents of that file. It's extremely useful, because it lets me have several different scenarios of simulated 'Flickr' behaviour and have the fake Flickr server respond identically every time. As you might expect, it's also significantly faster to test uploading to localhost than to Flickr!
The idea for this came from a conversation with David Masters at WWDC. I just wrote it in Cocoa, because that's what I do, but similar ideas could probably be knocked together in PHP in half an hour.
If you're working with a remote service that you don't control, consider taking them out of the loop. Just be sure that your emulator remains faithful to the actual deployed service.



Reader Comments (9)
Are you planning to release this Fraser? I've thought of building something similar a few times for testing the flickr.rb framework I have recently been augmenting for my own uses.
Relying on actual calls across a network to Flickr for testing is very slow, and not very reliable in my experience. It's also not good practice.
Yeah, I'll probably make more information available about it once it's a bit more complete. Upload emulation is not working properly yet.
It'll never be a proper product in any sense, though.
Could prove to be a very useful tool, even without upload emulation.
Keep us updated on your progress, no hurry.
FYI The code has moved from my privately hosted SVN repository onto google code:
http://code.google.com/p/toxic-public/
ToxicHTTP and ToxicNetwork (which ToxicHTTP depends on) are here: http://toxic-public.googlecode.com/svn/trunk/Frameworks/
Hi webmaster, commenters and everybody else !!! The blog was absolutely fantastic! Lots of great information and inspiration, both of which we all need!b Keep 'em coming... you all do such a great job at such Concepts... can't tell you how much I, for one appreciate all you do!
This is a very good idea! Just want to say thank you for the information, you have to share. Just continue to write such a position. I will be your faithful reader. Thank you again.
I hope you have a nice day! Very good article, well written and very thought out. I am looking forward to reading more of your posts in the future.
good post...oh coo, this information is really useful and definately is comment worthy! hehe. I’ll see if I can try to use some of this information for my own blog. Thanks!
Windows XP has Microsoft Office 2010 also been criticized Microsoft Office 2007 by some customers for Office 2010 security vulnerabilities, tight Office 2007 integration of applications like Internet Explorer 6 Office 2010 Microsoft and Windows Media Microsoft Office Player Let’s think for another MS office 2007 time. You take 200 customers and Microsoft outlook 2010 stop working with our Affiliate Program Office 2007 key, the reason is that you Microsoft outlook do not have enough time. Then you are able to Office 2007 download earn 4000 every year Outlook 2010! Versions with Service Pack 2, Service Pack 3, and download Office 2007 Internet Explorer 8 addressed Microsoft Office 2010 download some of these concerns. The Benefits of our Program Office 2010 download is written below: first, Our affiliate office 2010 trial program is FREE to take part Office 2010 key in .Then, You are able to earn on every purchase office 2010 pro of your customers. At the same time microsoft office 2010 trial, We have payouts office 2010 home – accept download Office 2010 a check monthly for office 2010 professional your sales.