mirror of
https://github.com/wassname/flask-s3.git
synced 2026-08-11 11:18:38 +08:00
Prevent url_for from building when app.testing is True/existing.
Closes #23.
This commit is contained in:
+5
-1
@@ -1,7 +1,11 @@
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.2"
|
||||
- "3.3"
|
||||
- "3.4"
|
||||
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
|
||||
install: pip install -r docs/requirements.txt --use-mirrors
|
||||
install: pip install -r requirements.txt --use-mirrors
|
||||
# command to run tests, e.g. python setup.py test
|
||||
script: nosetests
|
||||
sudo: false
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
Flask==0.9
|
||||
Jinja2==2.6
|
||||
Werkzeug==0.8.3
|
||||
boto3==1.1.1
|
||||
wsgiref==0.1.2
|
||||
Flask2
|
||||
boto3
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ def url_for(endpoint, **values):
|
||||
of your templates.
|
||||
"""
|
||||
app = current_app
|
||||
if app.config.get('TESTING', False) and not app.config.get('S3_OVERRIDE_TESTING', True):
|
||||
return flask_url_for(endpoint, **values)
|
||||
if 'S3_BUCKET_NAME' not in app.config:
|
||||
raise ValueError("S3_BUCKET_NAME not found in app configuration.")
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Flask
|
||||
boto3
|
||||
six
|
||||
@@ -2,6 +2,7 @@ import unittest
|
||||
import ntpath
|
||||
import tempfile
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
from unittest.mock import Mock, patch, call, mock_open
|
||||
@@ -51,6 +52,7 @@ class UrlTests(unittest.TestCase):
|
||||
self.app.config['S3_USE_HTTPS'] = True
|
||||
self.app.config['S3_BUCKET_DOMAIN'] = 's3.amazonaws.com'
|
||||
self.app.config['S3_CDN_DOMAIN'] = ''
|
||||
self.app.config['S3_OVERRIDE_TESTING'] = True
|
||||
|
||||
@self.app.route('/<url_for_string>')
|
||||
def a(url_for_string):
|
||||
@@ -242,8 +244,10 @@ class S3Tests(unittest.TestCase):
|
||||
actual = flask_s3._path_to_relative_url(in_)
|
||||
self.assertEquals(exp, actual)
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 0),
|
||||
"not supported in this version")
|
||||
@patch('flask_s3.boto3')
|
||||
@patch("{}.open".format("builtins" if six.PY3 else "__builtins__"), mock_open(read_data='test'))
|
||||
@patch("{}.open".format("builtins"), mock_open(read_data='test'))
|
||||
def test__write_files(self, key_mock):
|
||||
""" Tests _write_files """
|
||||
static_url_loc = '/foo/static'
|
||||
|
||||
Reference in New Issue
Block a user