Updated STATIC_URL to end with a slash as requested by Django
This commit is contained in:
Родитель
9d5ede6a20
Коммит
b8a5db0f4b
|
@ -1671,12 +1671,15 @@ class TestFlushURLs(amo.tests.TestCase):
|
|||
'addons/persona']
|
||||
|
||||
def setUp(self):
|
||||
settings.ADDON_ICON_URL = (settings.STATIC_URL +
|
||||
'/img/uploads/addon_icons/%s/%s-%s.png?modified=%s')
|
||||
settings.PREVIEW_THUMBNAIL_URL = (settings.STATIC_URL +
|
||||
'/img/uploads/previews/thumbs/%s/%d.png?modified=%d')
|
||||
settings.PREVIEW_FULL_URL = (settings.STATIC_URL +
|
||||
'/img/uploads/previews/full/%s/%d.%s?modified=%d')
|
||||
settings.ADDON_ICON_URL = (
|
||||
settings.STATIC_URL +
|
||||
'img/uploads/addon_icons/%s/%s-%s.png?modified=%s')
|
||||
settings.PREVIEW_THUMBNAIL_URL = (
|
||||
settings.STATIC_URL +
|
||||
'img/uploads/previews/thumbs/%s/%d.png?modified=%d')
|
||||
settings.PREVIEW_FULL_URL = (
|
||||
settings.STATIC_URL +
|
||||
'img/uploads/previews/full/%s/%d.%s?modified=%d')
|
||||
_connect()
|
||||
|
||||
def tearDown(self):
|
||||
|
|
|
@ -3,6 +3,7 @@ import json as jsonlib
|
|||
import random
|
||||
import re
|
||||
from operator import attrgetter
|
||||
from urlparse import urljoin
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
@ -343,7 +344,7 @@ def absolutify(url, site=None):
|
|||
if url.startswith('http'):
|
||||
return url
|
||||
else:
|
||||
return (site or settings.SITE_URL) + url
|
||||
return urljoin(site or settings.SITE_URL, url)
|
||||
|
||||
|
||||
@register.filter
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import mimetypes
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
from urlparse import urljoin
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
|
@ -483,7 +484,7 @@ def test_jinja_trans_monkeypatch():
|
|||
|
||||
|
||||
def test_absolutify():
|
||||
eq_(helpers.absolutify('/woo'), settings.SITE_URL + '/woo')
|
||||
eq_(helpers.absolutify('/woo'), urljoin(settings.SITE_URL, '/woo'))
|
||||
eq_(helpers.absolutify('https://addons.mozilla.org'),
|
||||
'https://addons.mozilla.org')
|
||||
|
||||
|
|
|
@ -1666,7 +1666,7 @@ class TestSubmitStep4(TestSubmitBase):
|
|||
self.old_addon_icon_url = settings.ADDON_ICON_URL
|
||||
settings.ADDON_ICON_URL = (
|
||||
settings.STATIC_URL +
|
||||
'/img/uploads/addon_icons/%s/%s-%s.png?modified=%s')
|
||||
'img/uploads/addon_icons/%s/%s-%s.png?modified=%s')
|
||||
SubmitStep.objects.create(addon_id=3615, step=4)
|
||||
self.url = reverse('devhub.submit.4', args=['a3615'])
|
||||
self.next_step = reverse('devhub.submit.5', args=['a3615'])
|
||||
|
|
|
@ -406,7 +406,7 @@ class TestFileViewer(FilesBase, amo.tests.TestCase):
|
|||
def test_memcache_goes_bye_bye(self):
|
||||
self.file_viewer.extract()
|
||||
res = self.client.get(self.files_redirect(binary))
|
||||
url = res['Location'][len(settings.STATIC_URL):]
|
||||
url = res['Location'][len(settings.STATIC_URL) - 1:]
|
||||
cache.clear()
|
||||
res = self.client.get(url)
|
||||
eq_(res.status_code, 403)
|
||||
|
|
|
@ -298,7 +298,7 @@ your local settings file based on how you run your dev server. Here is an
|
|||
example::
|
||||
|
||||
SITE_URL = 'http://localhost:8000'
|
||||
STATIC_URL = SITE_URL
|
||||
STATIC_URL = SITE_URL + '/' # STATIC_URL must have a trailing slash.
|
||||
|
||||
Create an Admin User
|
||||
--------------------
|
||||
|
|
|
@ -948,20 +948,20 @@ PREVIEW_FULL_PATH = PREVIEWS_PATH + '/full/%s/%d.%s'
|
|||
|
||||
# URL paths
|
||||
# paths for images, e.g. mozcdn.com/amo or '/static'
|
||||
STATIC_URL = SITE_URL
|
||||
STATIC_URL = SITE_URL + '/'
|
||||
ADDON_ICONS_DEFAULT_URL = MEDIA_URL + '/img/addon-icons'
|
||||
ADDON_ICON_BASE_URL = MEDIA_URL + 'img/icons/'
|
||||
ADDON_ICON_URL = (STATIC_URL +
|
||||
'/img/uploads/addon_icons/%s/%s-%s.png?modified=%s')
|
||||
'img/uploads/addon_icons/%s/%s-%s.png?modified=%s')
|
||||
PREVIEW_THUMBNAIL_URL = (STATIC_URL +
|
||||
'/img/uploads/previews/thumbs/%s/%d.png?modified=%d')
|
||||
'img/uploads/previews/thumbs/%s/%d.png?modified=%d')
|
||||
PREVIEW_FULL_URL = (STATIC_URL +
|
||||
'/img/uploads/previews/full/%s/%d.%s?modified=%d')
|
||||
USERPICS_URL = STATIC_URL + '/img/uploads/userpics/%s/%s/%s.png?modified=%d'
|
||||
'img/uploads/previews/full/%s/%d.%s?modified=%d')
|
||||
USERPICS_URL = STATIC_URL + 'img/uploads/userpics/%s/%s/%s.png?modified=%d'
|
||||
# paths for uploaded extensions
|
||||
COLLECTION_ICON_URL = (STATIC_URL +
|
||||
'/img/uploads/collection_icons/%s/%s.png?m=%s')
|
||||
NEW_PERSONAS_IMAGE_URL = STATIC_URL + '/img/uploads/themes/%(id)d/%(file)s'
|
||||
'img/uploads/collection_icons/%s/%s.png?m=%s')
|
||||
NEW_PERSONAS_IMAGE_URL = STATIC_URL + 'img/uploads/themes/%(id)d/%(file)s'
|
||||
PERSONAS_IMAGE_URL = ('http://getpersonas.cdn.mozilla.net/static/'
|
||||
'%(tens)d/%(units)d/%(id)d/%(file)s')
|
||||
PERSONAS_IMAGE_URL_SSL = ('https://getpersonas.cdn.mozilla.net/static/'
|
||||
|
@ -1215,7 +1215,7 @@ CSP_POLICY_URI = '/services/csp/policy?build=%s' % build_id
|
|||
CSP_REPORT_ONLY = True
|
||||
|
||||
CSP_ALLOW = ("'self'",)
|
||||
CSP_IMG_SRC = ("'self'", STATIC_URL,
|
||||
CSP_IMG_SRC = ("'self'", SITE_URL,
|
||||
"https://www.google.com", # Recaptcha comes from google
|
||||
"https://www.getpersonas.com",
|
||||
"https://s3.amazonaws.com", # getsatisfaction
|
||||
|
@ -1223,7 +1223,7 @@ CSP_IMG_SRC = ("'self'", STATIC_URL,
|
|||
"http://www.google-analytics.com",
|
||||
"data:"
|
||||
)
|
||||
CSP_SCRIPT_SRC = ("'self'", STATIC_URL,
|
||||
CSP_SCRIPT_SRC = ("'self'", SITE_URL,
|
||||
"https://www.google.com", # Recaptcha
|
||||
"https://login.persona.org",
|
||||
"https://firefoxos.persona.org",
|
||||
|
@ -1231,7 +1231,7 @@ CSP_SCRIPT_SRC = ("'self'", STATIC_URL,
|
|||
"https://ssl.google-analytics.com",
|
||||
"http://www.google-analytics.com",
|
||||
)
|
||||
CSP_STYLE_SRC = ("'self'", STATIC_URL,
|
||||
CSP_STYLE_SRC = ("'self'", SITE_URL,
|
||||
"http://raw.github.com",
|
||||
"https://raw.github.com",
|
||||
)
|
||||
|
|
|
@ -29,7 +29,7 @@ def get_absolute_url(url, api_name='apps', absolute=True):
|
|||
url[1]['api_name'] = api_name
|
||||
res = reverse(url[0], kwargs=url[1])
|
||||
if absolute:
|
||||
res = '%s%s' % (settings.SITE_URL, res)
|
||||
res = urlparse.urljoin(settings.SITE_URL, res)
|
||||
if len(url) > 2:
|
||||
res = urlparams(res, **url[2])
|
||||
return res
|
||||
|
@ -257,8 +257,8 @@ class Test3LeggedOAuthFlow(TestCase):
|
|||
|
||||
def test_access_request(self):
|
||||
t = Token.generate_new(REQUEST_TOKEN, self.access)
|
||||
url = settings.SITE_URL + reverse(
|
||||
'mkt.developers.oauth_access_request')
|
||||
url = urlparse.urljoin(settings.SITE_URL,
|
||||
reverse('mkt.developers.oauth_access_request'))
|
||||
url, auth_header = self._oauth_request_info(
|
||||
url, client_key=self.access.key, client_secret=self.access.secret,
|
||||
resource_owner_key=t.key, resource_owner_secret=t.secret,
|
||||
|
@ -279,8 +279,8 @@ class Test3LeggedOAuthFlow(TestCase):
|
|||
|
||||
def test_bad_access_request(self):
|
||||
t = Token.generate_new(REQUEST_TOKEN, self.access)
|
||||
url = settings.SITE_URL + reverse(
|
||||
'mkt.developers.oauth_access_request')
|
||||
url = urlparse.urljoin(settings.SITE_URL,
|
||||
reverse('mkt.developers.oauth_access_request'))
|
||||
url, auth_header = self._oauth_request_info(
|
||||
url, client_key=t.key, client_secret=t.secret,
|
||||
resource_owner_key=generate(), resource_owner_secret=generate(),
|
||||
|
@ -291,8 +291,8 @@ class Test3LeggedOAuthFlow(TestCase):
|
|||
assert not Token.objects.filter(token_type=ACCESS_TOKEN).exists()
|
||||
|
||||
def test_token_request(self):
|
||||
url = settings.SITE_URL + reverse(
|
||||
'mkt.developers.oauth_token_request')
|
||||
url = urlparse.urljoin(settings.SITE_URL,
|
||||
reverse('mkt.developers.oauth_token_request'))
|
||||
url, auth_header = self._oauth_request_info(
|
||||
url, client_key=self.access.key, client_secret=self.access.secret,
|
||||
callback_uri=self.access.redirect_uri)
|
||||
|
@ -307,8 +307,8 @@ class Test3LeggedOAuthFlow(TestCase):
|
|||
creds=self.access).exists()
|
||||
|
||||
def test_bad_token_request(self):
|
||||
url = settings.SITE_URL + reverse(
|
||||
'mkt.developers.oauth_token_request')
|
||||
url = urlparse.urljoin(settings.SITE_URL,
|
||||
reverse('mkt.developers.oauth_token_request'))
|
||||
url, auth_header = self._oauth_request_info(
|
||||
url, client_key=self.access.key, client_secret=generate(),
|
||||
callback_uri=self.access.redirect_uri)
|
||||
|
|
|
@ -112,8 +112,8 @@ class TestCollectionSerializer(CollectionDataMixin, amo.tests.TestCase):
|
|||
eq_(data['image'], None)
|
||||
self.collection.update(has_image=True)
|
||||
data = self.serializer.to_native(self.collection)
|
||||
eq_(data['image'], reverse('collection-image-detail',
|
||||
kwargs={'pk': self.collection.id}))
|
||||
ok_(data['image'].startswith(reverse(
|
||||
'collection-image-detail', kwargs={'pk': self.collection.id})))
|
||||
|
||||
def test_wrong_default_language_serialization(self):
|
||||
# The following is wrong because we only accept the 'en-us' form.
|
||||
|
|
|
@ -476,14 +476,14 @@ class TestFetchIcon(BaseWebAppTest):
|
|||
|
||||
class TestRegionEmail(amo.tests.WebappTestCase):
|
||||
|
||||
@mock.patch.object(settings, 'SITE_URL', 'http://omg.org/yes')
|
||||
@mock.patch.object(settings, 'SITE_URL', 'http://omg.org/')
|
||||
def test_email_for_one_new_region(self):
|
||||
tasks.region_email([self.app.id], [mkt.regions.BR])
|
||||
msg = mail.outbox[0]
|
||||
eq_(msg.subject, '%s: Brazil region added to the Firefox Marketplace'
|
||||
% self.app.name)
|
||||
eq_(msg.to, ['steamcube@mozilla.com'])
|
||||
dev_url = ('http://omg.org/yes/developers/app/something-something/'
|
||||
dev_url = ('http://omg.org/developers/app/something-something/'
|
||||
'edit#details')
|
||||
assert unicode(self.app.name) in msg.body
|
||||
assert dev_url in msg.body
|
||||
|
@ -492,7 +492,7 @@ class TestRegionEmail(amo.tests.WebappTestCase):
|
|||
# TODO: Re-enable this when we bring back Unsubscribe (bug 802379).
|
||||
#assert 'Unsubscribe' in msg.body
|
||||
|
||||
@mock.patch.object(settings, 'SITE_URL', 'http://omg.org/yes')
|
||||
@mock.patch.object(settings, 'SITE_URL', 'http://omg.org/')
|
||||
def test_email_for_two_new_regions(self):
|
||||
tasks.region_email([self.app.id],
|
||||
[mkt.regions.UK, mkt.regions.BR])
|
||||
|
@ -500,7 +500,7 @@ class TestRegionEmail(amo.tests.WebappTestCase):
|
|||
eq_(msg.subject, '%s: New regions added to the Firefox Marketplace'
|
||||
% self.app.name)
|
||||
eq_(msg.to, ['steamcube@mozilla.com'])
|
||||
dev_url = ('http://omg.org/yes/developers/app/something-something/'
|
||||
dev_url = ('http://omg.org/developers/app/something-something/'
|
||||
'edit#details')
|
||||
assert unicode(self.app.name) in msg.body
|
||||
assert dev_url in msg.body
|
||||
|
@ -509,7 +509,7 @@ class TestRegionEmail(amo.tests.WebappTestCase):
|
|||
# TODO: Re-enable this when we bring back Unsubscribe (bug 802379).
|
||||
#assert 'Unsubscribe' in msg.body
|
||||
|
||||
@mock.patch.object(settings, 'SITE_URL', 'http://omg.org/yes')
|
||||
@mock.patch.object(settings, 'SITE_URL', 'http://omg.org/')
|
||||
def test_email_for_several_new_regions(self):
|
||||
tasks.region_email([self.app.id],
|
||||
[mkt.regions.UK, mkt.regions.US, mkt.regions.BR])
|
||||
|
|
|
@ -384,7 +384,7 @@ class TestFileViewer(FilesBase, amo.tests.WebappTestCase):
|
|||
def test_memcache_goes_bye_bye(self):
|
||||
self.file_viewer.extract()
|
||||
res = self.client.get(self.files_redirect(binary))
|
||||
url = res['Location'][len(settings.STATIC_URL):]
|
||||
url = res['Location'][len(settings.STATIC_URL) - 1:]
|
||||
cache.clear()
|
||||
res = self.client.get(url)
|
||||
eq_(res.status_code, 403)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
from urlparse import urljoin
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
|
@ -289,5 +290,5 @@ class TestOpensearch(amo.tests.TestCase):
|
|||
e = doc.find('{http://a9.com/-/spec/opensearch/1.1/}ShortName')
|
||||
eq_(e.text, 'Firefox Marketplace')
|
||||
e = doc.find('{http://a9.com/-/spec/opensearch/1.1/}Url')
|
||||
wanted = '%s%s?q={searchTerms}' % (settings.SITE_URL, '/search')
|
||||
wanted = '%s?q={searchTerms}' % urljoin(settings.SITE_URL, '/search')
|
||||
eq_(e.attrib['template'], wanted)
|
||||
|
|
|
@ -55,19 +55,20 @@ VALIDATE_ADDONS = True
|
|||
|
||||
PAYPAL_PERMISSIONS_URL = ''
|
||||
|
||||
SITE_URL = STATIC_URL = 'http://testserver'
|
||||
SITE_URL = 'http://testserver'
|
||||
STATIC_URL = SITE_URL + '/'
|
||||
MOBILE_SITE_URL = ''
|
||||
MEDIA_URL = '/media/'
|
||||
# Reset these URLs to the defaults so your settings_local doesn't clobber them:
|
||||
ADDON_ICONS_DEFAULT_URL = MEDIA_URL + '/img/addon-icons'
|
||||
ADDON_ICON_BASE_URL = MEDIA_URL + 'img/icons/'
|
||||
ADDON_ICON_URL = (
|
||||
STATIC_URL + '/img/uploads/addon_icons/%s/%s-%s.png?modified=%s')
|
||||
PREVIEW_THUMBNAIL_URL = (
|
||||
STATIC_URL + '/img/uploads/previews/thumbs/%s/%d.png?modified=%d')
|
||||
PREVIEW_FULL_URL = (
|
||||
STATIC_URL + '/img/uploads/previews/full/%s/%d.%s?modified=%d')
|
||||
USERPICS_URL = STATIC_URL + '/img/uploads/userpics/%s/%s/%s.png?modified=%d'
|
||||
ADDON_ICON_URL = (STATIC_URL +
|
||||
'img/uploads/addon_icons/%s/%s-%s.png?modified=%s')
|
||||
PREVIEW_THUMBNAIL_URL = (STATIC_URL +
|
||||
'img/uploads/previews/thumbs/%s/%d.png?modified=%d')
|
||||
PREVIEW_FULL_URL = (STATIC_URL +
|
||||
'img/uploads/previews/full/%s/%d.%s?modified=%d')
|
||||
USERPICS_URL = STATIC_URL + 'img/uploads/userpics/%s/%s/%s.png?modified=%d'
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
|
|
Загрузка…
Ссылка в новой задаче