def test_get_remote_informations_connection_error(self, mock): from papaye.proxy import PyPiProxy mock.side_effect = ConnectionError url = "http://pypi.python.org/pypi/pyramid/json" proxy = PyPiProxy(self.request, 'pyramid') result = proxy.get_remote_informations(url) self.assertIsNone(result)
def test_get_remote_informations_404(self, mock): from papaye.proxy import PyPiProxy mock.return_value = FakeGRequestResponse(404, b'') url = "http://pypi.python.org/pypi/pyramid/json" proxy = PyPiProxy(self.request, 'pyramid') result = proxy.get_remote_informations(url) self.assertIsNone(result)
def test_get_remote_informations(self, mock): from papaye.proxy import PyPiProxy mock.return_value = self.pypi_response url = "http://pypi.python.org/pypi/pyramid/json" proxy = PyPiProxy(self.request, 'pyramid') result = proxy.get_remote_informations(url) self.assertIsInstance(result, dict) self.assertEqual(result['info']['name'], 'pyramid')
def test_get_remote_informations(self, mock): # Given from papaye.proxy import PyPiProxy mock_proxy_response(mock) url = "http://pypi.python.org/pypi/pyramid/json" proxy = PyPiProxy() # When result = proxy.get_remote_informations(url) # Then self.assertIsInstance(result, dict) self.assertEqual(result['info']['name'], 'pyramid')