def test_handle_request(self): f = Feedbin('*****@*****.**','secret') f._makeRequest = MagicMock(name="_makeRequest") with patch('feedbin.feedbin.urlopen') as mock: mock_response = MagicMock(name="response") mock_response.read.return_value = dumps({'foo': ['bar']}) mock.return_value = mock_response data = f._handleRequest('entries', {'fizz': 'buzz'}) f._makeRequest.assert_called_with('entries', {'fizz': 'buzz'}) self.assertDictEqual({'foo': ['bar']}, data)
def test_requests_with_params(self): f = Feedbin('*****@*****.**','secret') req = f._makeRequest('entries', {'foo': 'bar'}) self.assertEqual( 'http://api.feedbin.me/v2/entries.json?foo=bar', req.get_full_url())
def test_requests_have_auth_header(self): f = Feedbin('*****@*****.**','secret') req = f._makeRequest('entries') self.assertIn('Authorization', req.headers.keys())