def test_convenience_find_feeds(self): from scavenger import find_feeds with mock.patch('scavenger.Scavenger') as mocked_scavenger_class: mocked_scavenger_class.return_value.find_feeds.return_value = 'some feeds' result = find_feeds('some url', max_depth='a max depth') mocked_scavenger_class.assert_called_once_with(max_depth='a max depth') mocked_scavenger_class.return_value.find_feeds.assert_called_once_with('some url') self.assertEqual(result, 'some feeds')
def test_convenience_find_xmlrpc(self): from scavenger import find_xmlrpc with mock.patch('scavenger.Scavenger') as mocked_scavenger_class: mocked_scavenger_class.return_value.find_xmlrpc.return_value = 'an xmlrpc endpoint' result = find_xmlrpc('some url') mocked_scavenger_class.assert_called_once_with() mocked_scavenger_class.return_value.find_xmlrpc.assert_called_once_with('some url') self.assertEqual(result, 'an xmlrpc endpoint')
def test_requests_get(self): with mock.patch('scavenger.requests.get', return_value='some good stuff') as requests_get: scavenger = Scavenger(max_depth=1) result = scavenger._requests_get('a url') self.assertEqual(result, 'some good stuff') requests_get.assert_called_once_with( 'a url', headers={'User-Agent': scavenger._user_agent}, timeout=scavenger._request_timeout )