Commit dac255c9 by Clinton Blackburn

Removed httpretty

ECOM-3895
parent 4bf140a7
...@@ -4,7 +4,6 @@ from django.core.management import call_command ...@@ -4,7 +4,6 @@ from django.core.management import call_command
from django.test import TestCase from django.test import TestCase
from django.test.utils import override_settings from django.test.utils import override_settings
from edx_rest_api_client.client import EdxRestApiClient from edx_rest_api_client.client import EdxRestApiClient
import httpretty
from mock import patch from mock import patch
from course_discovery.apps.courses.models import Course from course_discovery.apps.courses.models import Course
...@@ -27,7 +26,6 @@ class RefreshAllCoursesCommandTests(TestCase): ...@@ -27,7 +26,6 @@ class RefreshAllCoursesCommandTests(TestCase):
call_command(self.cmd, access_token=access_token) call_command(self.cmd, access_token=access_token)
mock_refresh.assert_called_once_with(access_token=access_token) mock_refresh.assert_called_once_with(access_token=access_token)
@httpretty.activate
def test_call_with_client_credentials(self): def test_call_with_client_credentials(self):
""" Verify the management command calls Course.refresh_all() with client credentials. """ """ Verify the management command calls Course.refresh_all() with client credentials. """
access_token = 'secret' access_token = 'secret'
...@@ -38,7 +36,6 @@ class RefreshAllCoursesCommandTests(TestCase): ...@@ -38,7 +36,6 @@ class RefreshAllCoursesCommandTests(TestCase):
call_command(self.cmd) call_command(self.cmd)
mock_refresh.assert_called_once_with(access_token=access_token) mock_refresh.assert_called_once_with(access_token=access_token)
@httpretty.activate
def test_call_with_client_credentials_error(self): def test_call_with_client_credentials_error(self):
""" Verify the command requires an access token to complete. """ """ Verify the command requires an access token to complete. """
with patch.object(EdxRestApiClient, 'get_oauth_access_token') as mock_access_token: with patch.object(EdxRestApiClient, 'get_oauth_access_token') as mock_access_token:
......
...@@ -12,3 +12,14 @@ Code quality validation can be run independently with: ...@@ -12,3 +12,14 @@ Code quality validation can be run independently with:
.. code-block:: bash .. code-block:: bash
$ make quality $ make quality
httpretty
---------
edX uses `httpretty <http://httpretty.readthedocs.org/en/latest/>`_ a lot to mock HTTP endpoints; however,
`a bug in httpretty <https://github.com/gabrielfalcao/HTTPretty/issues/65>`_ (that is closed, but still a problem)
prevents us from using it in this repository. Were you to use `httpretty`, you would find that, although you might
mock an OAuth2 endpoint, `httpretty` blocks requests to Elasticsearch, leading to test failures.
Given our extensive use of Elasticsearch, and need to mock HTTP endpoints, we use the
`responses <https://github.com/getsentry/responses>`_ library. It's API is practically the same as that of `httpretty.
...@@ -7,7 +7,6 @@ django-dynamic-fixture==1.8.5 ...@@ -7,7 +7,6 @@ django-dynamic-fixture==1.8.5
django-nose==1.4.2 django-nose==1.4.2
edx-lint==0.5.0 edx-lint==0.5.0
factory-boy==2.6.0 factory-boy==2.6.0
httpretty==0.8.14
mock==1.3.0 mock==1.3.0
nose-ignore-docstring==0.2 nose-ignore-docstring==0.2
pep8==1.6.2 pep8==1.6.2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment