def testHandleURLWorks(self):
     mock_download_queue = mock.Mock(Queue.Queue)
     crawler_thread = CrawlerThread(None, mock_download_queue, None)
     crawler_thread.HandleHtmlResource = mock.Mock()
     with testfixtures.Replacer() as r:
         # HTML resource.
         html_resource = CreateFakeURLResource('text/html')
         r.replace('urllib2.urlopen', mock.Mock(return_value=html_resource))
         crawler_thread.HandleURL('http://www.fake.com/')
         crawler_thread.HandleHtmlResource.assert_called_with(html_resource)
         # Zip resource.
         zip_resource = CreateFakeURLResource('application/zip')
         r.replace('urllib2.urlopen', mock.Mock(return_value=zip_resource))
         crawler_thread.HandleURL('http://www.fake.com/')
         mock_download_queue.put.assert_called_with(zip_resource)
         # Plain text resource.
         text_resource = CreateFakeURLResource('text/plain')
         r.replace('urllib2.urlopen', mock.Mock(return_value=text_resource))
         crawler_thread.HandleURL('http://www.fake.com/')
         mock_download_queue.put.assert_called_with(text_resource)