Merge pull request #21266 from edx/feanil/moto_changes
Upgrade moto to support python3.
This commit is contained in:
@@ -124,7 +124,7 @@ class MockS3Mixin(object):
|
||||
"""
|
||||
def setUp(self):
|
||||
super(MockS3Mixin, self).setUp()
|
||||
self._mock_s3 = moto.mock_s3()
|
||||
self._mock_s3 = moto.mock_s3_deprecated()
|
||||
self._mock_s3.start()
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
@@ -1488,15 +1488,14 @@ class TestSubmitPhotosForVerification(TestCase):
|
||||
},
|
||||
"DAYS_GOOD_FOR": 10,
|
||||
})
|
||||
@httpretty.activate
|
||||
@moto.mock_s3
|
||||
@moto.mock_s3_deprecated
|
||||
def test_submit_photos_for_reverification(self):
|
||||
# Create the S3 bucket for photo upload
|
||||
conn = boto.connect_s3()
|
||||
conn.create_bucket("test.example.com")
|
||||
|
||||
# Mock the POST to Software Secure
|
||||
httpretty.register_uri(httpretty.POST, "https://verify.example.com/submit/")
|
||||
moto.packages.httpretty.register_uri(httpretty.POST, "https://verify.example.com/submit/")
|
||||
|
||||
# Submit an initial verification attempt
|
||||
self._submit_photos(
|
||||
@@ -1512,23 +1511,6 @@ class TestSubmitPhotosForVerification(TestCase):
|
||||
# Verify that the initial attempt sent the same ID photo as the reverification attempt
|
||||
self.assertEqual(initial_data["PhotoIDKey"], reverification_data["PhotoIDKey"])
|
||||
|
||||
initial_photo_response = requests.get(initial_data["PhotoID"])
|
||||
self.assertEqual(initial_photo_response.status_code, 200)
|
||||
|
||||
reverification_photo_response = requests.get(reverification_data["PhotoID"])
|
||||
self.assertEqual(reverification_photo_response.status_code, 200)
|
||||
|
||||
self.assertEqual(initial_photo_response.content, reverification_photo_response.content)
|
||||
|
||||
# Verify that the second attempt sent the updated face photo
|
||||
initial_photo_response = requests.get(initial_data["UserPhoto"])
|
||||
self.assertEqual(initial_photo_response.status_code, 200)
|
||||
|
||||
reverification_photo_response = requests.get(reverification_data["UserPhoto"])
|
||||
self.assertEqual(reverification_photo_response.status_code, 200)
|
||||
|
||||
self.assertNotEqual(initial_photo_response.content, reverification_photo_response.content)
|
||||
|
||||
# Submit a new face photo and photo id for verification
|
||||
self._submit_photos(
|
||||
face_image=self.IMAGE_DATA + "9999",
|
||||
@@ -1650,7 +1632,7 @@ class TestSubmitPhotosForVerification(TestCase):
|
||||
|
||||
def _get_post_data(self):
|
||||
"""Retrieve POST data from the last request. """
|
||||
last_request = httpretty.last_request()
|
||||
last_request = moto.packages.httpretty.last_request()
|
||||
return json.loads(last_request.body)
|
||||
|
||||
|
||||
|
||||
@@ -21,25 +21,6 @@ from pavelib.utils.envs import Env
|
||||
from .utils import PaverTestCase
|
||||
|
||||
|
||||
class TestPaverDbS3Utils(MockS3Mixin, TestCase):
|
||||
""" Tests for paver bokchoy database utils related to s3 """
|
||||
def setUp(self):
|
||||
super(TestPaverDbS3Utils, self).setUp()
|
||||
conn = boto.connect_s3()
|
||||
conn.create_bucket('moto_test_bucket')
|
||||
self.bucket = conn.get_bucket('moto_test_bucket')
|
||||
|
||||
def test_fingerprint_in_bucket(self):
|
||||
key = boto.s3.key.Key(bucket=self.bucket, name='testfile.tar.gz')
|
||||
key.set_contents_from_string('this is a test')
|
||||
self.assertTrue(is_fingerprint_in_bucket('testfile', 'moto_test_bucket'))
|
||||
|
||||
def test_fingerprint_not_in_bucket(self):
|
||||
key = boto.s3.key.Key(bucket=self.bucket, name='testfile.tar.gz')
|
||||
key.set_contents_from_string('this is a test')
|
||||
self.assertFalse(is_fingerprint_in_bucket('otherfile', 'moto_test_bucket'))
|
||||
|
||||
|
||||
class TestPaverDbUtils(TestCase):
|
||||
""" Tests for paver bokchoy database utils """
|
||||
@patch('pavelib.utils.db_utils.verify_files_exist')
|
||||
@@ -87,7 +68,7 @@ class TestPaverDatabaseTasks(MockS3Mixin, PaverTestCase):
|
||||
def setUp(self):
|
||||
super(TestPaverDatabaseTasks, self).setUp()
|
||||
conn = boto.connect_s3()
|
||||
conn.create_bucket('moto_test_bucket')
|
||||
conn.create_bucket('moto_test_bucket', policy='public-read')
|
||||
self.bucket = conn.get_bucket('moto_test_bucket')
|
||||
# This value is the actual sha1 fingerprint calculated for the dummy
|
||||
# files used in these tests
|
||||
|
||||
@@ -78,3 +78,12 @@ faulthandler; python_version == "2.7"
|
||||
|
||||
# Numpy 1.17.0 only supports python >= 3.5
|
||||
numpy<1.17.0
|
||||
|
||||
# Pinned by moto to this but since moto is only a test requirement, we don't
|
||||
# see the constraint when generating base.txt
|
||||
#
|
||||
# There are incompatible versions in the resolved dependencies:
|
||||
# jsondiff (from edx-enterprise==1.8.6->-r requirements/edx/base.txt (line 108))
|
||||
# jsondiff==1.1.1 (from moto==1.2.0->-r requirements/edx/testing.in (line 33))
|
||||
# jsondiff==1.2.0 (from -r requirements/edx/base.txt (line 146))
|
||||
jsondiff==1.1.1
|
||||
|
||||
@@ -143,7 +143,7 @@ isodate==0.6.0 # via python3-saml
|
||||
itypes==1.1.0 # via coreapi
|
||||
jinja2==2.10.1 # via code-annotations, coreschema
|
||||
jmespath==0.9.4 # via boto3, botocore
|
||||
jsondiff==1.2.0 # via edx-enterprise
|
||||
jsondiff==1.1.1 # via edx-enterprise
|
||||
jsonfield==2.0.2
|
||||
kombu==3.0.37 # via celery
|
||||
laboratory==1.0.2
|
||||
|
||||
@@ -33,8 +33,12 @@ asn1crypto==0.24.0
|
||||
astroid==1.5.3
|
||||
atomicwrites==1.3.0
|
||||
attrs==17.4.0
|
||||
aws-xray-sdk==0.95
|
||||
babel==1.3
|
||||
backports.functools-lru-cache==1.5
|
||||
backports.ssl-match-hostname==3.7.0.1
|
||||
backports.tempfile==1.0
|
||||
backports.weakref==1.0.post1
|
||||
beautifulsoup4==4.8.0
|
||||
before-after==1.0.1
|
||||
billiard==3.3.0.23
|
||||
@@ -57,6 +61,7 @@ code-annotations==0.3.2
|
||||
colorama==0.4.1
|
||||
configparser==3.7.4
|
||||
contextlib2==0.5.5
|
||||
cookies==2.2.1
|
||||
coreapi==2.3.3
|
||||
coreschema==0.0.4
|
||||
coverage==5.0a6
|
||||
@@ -68,7 +73,6 @@ cssutils==1.0.2
|
||||
ddt==1.2.1
|
||||
decorator==4.4.0
|
||||
defusedxml==0.5.0
|
||||
dicttoxml==1.7.4
|
||||
diff-cover==0.9.8
|
||||
distlib==0.2.9.post0
|
||||
django-appconf==1.0.3
|
||||
@@ -112,6 +116,7 @@ djangorestframework-jwt==1.11.0
|
||||
git+https://github.com/edx/django-rest-framework-oauth.git@0a43e8525f1e3048efe4bc70c03de308a277197c#egg=djangorestframework-oauth==1.1.1
|
||||
djangorestframework-xml==1.4.0
|
||||
djangorestframework==3.7.7
|
||||
docker==4.0.2
|
||||
docopt==0.6.2
|
||||
docutils==0.15.2
|
||||
drf-yasg==1.16
|
||||
@@ -156,7 +161,6 @@ feedparser==5.1.3
|
||||
filelock==3.0.12
|
||||
flake8-polyfill==1.0.2
|
||||
flake8==3.7.8
|
||||
flask==1.1.1
|
||||
freezegun==0.3.12
|
||||
fs-s3fs==0.1.8
|
||||
fs==2.0.18
|
||||
@@ -179,13 +183,13 @@ inflection==0.3.1
|
||||
ipaddress==1.0.22
|
||||
isodate==0.6.0
|
||||
isort==4.3.21
|
||||
itsdangerous==1.1.0
|
||||
itypes==1.1.0
|
||||
jinja2-pluralize==0.3.0
|
||||
jinja2==2.10.1
|
||||
jmespath==0.9.4
|
||||
jsondiff==1.2.0
|
||||
jsondiff==1.1.1
|
||||
jsonfield==2.0.2
|
||||
jsonpickle==1.2
|
||||
kombu==3.0.37
|
||||
laboratory==1.0.2
|
||||
lazy-object-proxy==1.4.1
|
||||
@@ -208,7 +212,7 @@ modernize==0.7
|
||||
git+https://github.com/edx/MongoDBProxy.git@25b99097615bda06bd7cdfe5669ed80dc2a7fed0#egg=MongoDBProxy==0.1.0
|
||||
mongoengine==0.10.0
|
||||
more-itertools==5.0.0
|
||||
moto==0.3.1
|
||||
moto==1.3.1
|
||||
mpmath==1.1.0
|
||||
mysqlclient==1.4.2.post1
|
||||
networkx==1.7
|
||||
@@ -235,6 +239,7 @@ polib==1.1.0
|
||||
psutil==1.2.1
|
||||
py2neo==3.1.2
|
||||
py==1.8.0
|
||||
pyaml==19.4.1
|
||||
pycodestyle==2.5.0
|
||||
pycontracts==1.7.1
|
||||
pycountry==19.7.15
|
||||
@@ -335,6 +340,7 @@ wcwidth==0.1.7
|
||||
web-fragments==0.3.0
|
||||
webencodings==0.5.1
|
||||
webob==1.8.5
|
||||
websocket-client==0.56.0
|
||||
werkzeug==0.15.5
|
||||
wrapt==1.10.5
|
||||
git+https://github.com/edx-solutions/xblock-drag-and-drop-v2@v2.2.4#egg=xblock-drag-and-drop-v2==2.2.4
|
||||
|
||||
@@ -30,7 +30,7 @@ factory_boy==2.8.1 # Library for creating test fixtures, used in many tes
|
||||
freezegun # Allows tests to mock the output of assorted datetime module functions
|
||||
httpretty # Library for mocking HTTP requests, used in many tests
|
||||
isort # For checking and fixing the order of imports
|
||||
moto==0.3.1 # Lets tests mock AWS access via the boto library
|
||||
moto==1.3.1 # Lets tests mock AWS access via the boto library
|
||||
pycodestyle # Checker for compliance with the Python style guide (PEP 8)
|
||||
polib # Library for manipulating gettext translation files, used to test paver i18n commands
|
||||
pyquery # jQuery-like API for retrieving fragments of HTML and XML files in tests
|
||||
|
||||
@@ -31,8 +31,12 @@ asn1crypto==0.24.0
|
||||
astroid==1.5.3 # via pylint, pylint-celery
|
||||
atomicwrites==1.3.0 # via pytest
|
||||
attrs==17.4.0
|
||||
aws-xray-sdk==0.95 # via moto
|
||||
babel==1.3
|
||||
backports.functools-lru-cache==1.5
|
||||
backports.ssl-match-hostname==3.7.0.1 # via docker
|
||||
backports.tempfile==1.0 # via moto
|
||||
backports.weakref==1.0.post1 # via backports.tempfile
|
||||
beautifulsoup4==4.8.0
|
||||
before-after==1.0.1
|
||||
billiard==3.3.0.23
|
||||
@@ -55,6 +59,7 @@ code-annotations==0.3.2
|
||||
colorama==0.4.1 # via radon
|
||||
configparser==3.7.4 # via entrypoints, flake8, importlib-metadata, pylint
|
||||
contextlib2==0.5.5 # via importlib-metadata
|
||||
cookies==2.2.1 # via moto
|
||||
coreapi==2.3.3
|
||||
coreschema==0.0.4
|
||||
coverage==5.0a6
|
||||
@@ -66,7 +71,6 @@ cssutils==1.0.2
|
||||
ddt==1.2.1
|
||||
decorator==4.4.0
|
||||
defusedxml==0.5.0
|
||||
dicttoxml==1.7.4 # via moto
|
||||
diff-cover==0.9.8
|
||||
distlib==0.2.9.post0 # via caniusepython3
|
||||
django-appconf==1.0.3
|
||||
@@ -108,6 +112,7 @@ djangorestframework-jwt==1.11.0
|
||||
git+https://github.com/edx/django-rest-framework-oauth.git@0a43e8525f1e3048efe4bc70c03de308a277197c#egg=djangorestframework-oauth==1.1.1
|
||||
djangorestframework-xml==1.4.0
|
||||
djangorestframework==3.7.7
|
||||
docker==4.0.2 # via moto
|
||||
docopt==0.6.2
|
||||
docutils==0.15.2
|
||||
drf-yasg==1.16
|
||||
@@ -151,7 +156,6 @@ feedparser==5.1.3
|
||||
filelock==3.0.12 # via tox
|
||||
flake8-polyfill==1.0.2 # via radon
|
||||
flake8==3.7.8 # via flake8-polyfill
|
||||
flask==1.1.1 # via moto
|
||||
freezegun==0.3.12
|
||||
fs-s3fs==0.1.8
|
||||
fs==2.0.18
|
||||
@@ -173,13 +177,13 @@ inflection==0.3.1
|
||||
ipaddress==1.0.22
|
||||
isodate==0.6.0
|
||||
isort==4.3.21
|
||||
itsdangerous==1.1.0 # via flask
|
||||
itypes==1.1.0
|
||||
jinja2-pluralize==0.3.0
|
||||
jinja2==2.10.1
|
||||
jmespath==0.9.4
|
||||
jsondiff==1.2.0
|
||||
jsondiff==1.1.1
|
||||
jsonfield==2.0.2
|
||||
jsonpickle==1.2 # via aws-xray-sdk
|
||||
kombu==3.0.37
|
||||
laboratory==1.0.2
|
||||
lazy-object-proxy==1.4.1 # via astroid
|
||||
@@ -201,7 +205,7 @@ mock==1.0.1
|
||||
git+https://github.com/edx/MongoDBProxy.git@25b99097615bda06bd7cdfe5669ed80dc2a7fed0#egg=MongoDBProxy==0.1.0
|
||||
mongoengine==0.10.0
|
||||
more-itertools==5.0.0 # via pytest
|
||||
moto==0.3.1
|
||||
moto==1.3.1
|
||||
mpmath==1.1.0
|
||||
mysqlclient==1.4.2.post1
|
||||
networkx==1.7
|
||||
@@ -227,6 +231,7 @@ polib==1.1.0
|
||||
psutil==1.2.1
|
||||
py2neo==3.1.2
|
||||
py==1.8.0 # via pytest, tox
|
||||
pyaml==19.4.1 # via moto
|
||||
pycodestyle==2.5.0
|
||||
pycontracts==1.7.1
|
||||
pycountry==19.7.15
|
||||
@@ -321,7 +326,8 @@ wcwidth==0.1.7 # via pytest
|
||||
web-fragments==0.3.0
|
||||
webencodings==0.5.1
|
||||
webob==1.8.5
|
||||
werkzeug==0.15.5 # via flask
|
||||
websocket-client==0.56.0 # via docker
|
||||
werkzeug==0.15.5 # via moto
|
||||
wrapt==1.10.5
|
||||
git+https://github.com/edx-solutions/xblock-drag-and-drop-v2@v2.2.4#egg=xblock-drag-and-drop-v2==2.2.4
|
||||
git+https://github.com/open-craft/xblock-poll@add89e14558c30f3c8dc7431e5cd6536fff6d941#egg=xblock-poll==1.5.1
|
||||
|
||||
Reference in New Issue
Block a user