Skip renaming file on GCS when testing.
This allows running this test while the internet is gone.
This commit is contained in:
@@ -8,6 +8,7 @@ from flask import abort
|
|||||||
from flask import request
|
from flask import request
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from application import utils
|
from application import utils
|
||||||
|
from application.utils import skip_when_testing
|
||||||
from application.utils.gcs import GoogleCloudStorageBucket
|
from application.utils.gcs import GoogleCloudStorageBucket
|
||||||
|
|
||||||
encoding = Blueprint('encoding', __name__)
|
encoding = Blueprint('encoding', __name__)
|
||||||
@@ -41,6 +42,13 @@ def size_descriptor(width, height):
|
|||||||
return '%ip' % height
|
return '%ip' % height
|
||||||
|
|
||||||
|
|
||||||
|
@skip_when_testing
|
||||||
|
def rename_on_gcs(bucket_name, from_path, to_path):
|
||||||
|
gcs = GoogleCloudStorageBucket(str(bucket_name))
|
||||||
|
blob = gcs.bucket.blob(from_path)
|
||||||
|
gcs.bucket.rename_blob(blob, to_path)
|
||||||
|
|
||||||
|
|
||||||
@encoding.route('/zencoder/notifications', methods=['POST'])
|
@encoding.route('/zencoder/notifications', methods=['POST'])
|
||||||
def zencoder_notifications():
|
def zencoder_notifications():
|
||||||
"""
|
"""
|
||||||
@@ -137,9 +145,9 @@ def zencoder_notifications():
|
|||||||
|
|
||||||
# Rename on Google Cloud Storage
|
# Rename on Google Cloud Storage
|
||||||
try:
|
try:
|
||||||
gcs = GoogleCloudStorageBucket(str(file_doc['project']))
|
rename_on_gcs(file_doc['project'],
|
||||||
blob = gcs.bucket.blob('_/' + variation['file_path'])
|
'_/' + variation['file_path'],
|
||||||
gcs.bucket.rename_blob(blob, '_/' + new_fname)
|
'_/' + new_fname)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.warning('Unable to rename GCS blob %r to %r. Keeping old name.',
|
log.warning('Unable to rename GCS blob %r to %r. Keeping old name.',
|
||||||
variation['file_path'], new_fname, exc_info=True)
|
variation['file_path'], new_fname, exc_info=True)
|
||||||
|
Reference in New Issue
Block a user