зеркало из https://github.com/mozilla/bedrock.git
Update tests to pass without l10n files.
This commit is contained in:
Родитель
60357449b6
Коммит
401af18ab1
|
@ -19,7 +19,6 @@ before_script:
|
|||
- python manage.py migrate --noinput
|
||||
- python manage.py collectstatic --noinput -v 0
|
||||
- travis_retry python manage.py update_product_details
|
||||
- travis_retry svn checkout https://svn.mozilla.org/projects/mozilla.com/trunk/locales/ locale
|
||||
- travis_retry npm install
|
||||
- export DISPLAY=:99.0
|
||||
- sh -e /etc/init.d/xvfb start
|
||||
|
|
|
@ -41,7 +41,10 @@ class AcceptedLocalesTest(test_utils.TestCase):
|
|||
cls.PROD_LANGUAGES = settings.PROD_LANGUAGES
|
||||
cls.DEV_LANGUAGES = settings.DEV_LANGUAGES
|
||||
settings.PROD_LANGUAGES = ('en-US',)
|
||||
shutil.move(cls.locale, cls.locale_bkp)
|
||||
if os.path.exists(cls.locale):
|
||||
shutil.move(cls.locale, cls.locale_bkp)
|
||||
else:
|
||||
cls.locale_bkp = None
|
||||
for loc in ('en-US', 'fr', 'templates'):
|
||||
os.makedirs(os.path.join(cls.locale, loc, 'LC_MESSAGES'))
|
||||
open(os.path.join(cls.locale, 'empty_file'), 'w').close()
|
||||
|
@ -54,7 +57,8 @@ class AcceptedLocalesTest(test_utils.TestCase):
|
|||
settings.PROD_LANGUAGES = cls.PROD_LANGUAGES
|
||||
settings.DEV_LANGUAGES = cls.DEV_LANGUAGES
|
||||
shutil.rmtree(cls.locale)
|
||||
shutil.move(cls.locale_bkp, cls.locale)
|
||||
if cls.locale_bkp:
|
||||
shutil.move(cls.locale_bkp, cls.locale)
|
||||
|
||||
def test_build_dev_languages(self):
|
||||
"""Test that the list of dev locales is built properly.
|
||||
|
|
|
@ -6,8 +6,8 @@ from pyquery import PyQuery as pq
|
|||
from bedrock.mozorg.tests import TestCase
|
||||
|
||||
|
||||
@patch('bedrock.newsletter.utils.get_languages_for_newsletters',
|
||||
lambda *x: set(['en', 'fr', 'pt']))
|
||||
@patch('bedrock.newsletter.forms.get_lang_choices',
|
||||
lambda *x: [['en', 'English'], ['fr', 'French'], ['pt', 'Portuguese']])
|
||||
@patch('lib.l10n_utils.template_is_active', lambda *x: True)
|
||||
class TestNewsletterFooter(TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -138,7 +138,7 @@ def get_dev_languages():
|
|||
if lang.is_dir() and lang.name != 'templates']
|
||||
except OSError:
|
||||
# no locale dir
|
||||
return []
|
||||
return list(PROD_LANGUAGES)
|
||||
|
||||
|
||||
DEV_LANGUAGES = get_dev_languages()
|
||||
|
|
|
@ -9,7 +9,7 @@ from StringIO import StringIO
|
|||
from textwrap import dedent
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, override_settings
|
||||
|
||||
from mock import ANY, MagicMock, Mock, patch
|
||||
|
||||
|
@ -28,7 +28,7 @@ ROOT = path.join(path.dirname(path.abspath(__file__)), 'test_files')
|
|||
TEMPLATE_DIRS = (path.join(ROOT, 'templates'),)
|
||||
|
||||
METHODS = [
|
||||
('lib/l10n_utils/tests/test_files/templates/**.html',
|
||||
('templates/**.html',
|
||||
'tower.management.commands.extract.extract_tower_template'),
|
||||
]
|
||||
|
||||
|
@ -38,13 +38,13 @@ TRUE_MOCK = Mock()
|
|||
TRUE_MOCK.return_value = True
|
||||
|
||||
|
||||
@override_settings(ROOT=ROOT)
|
||||
class TestL10nExtract(TestCase):
|
||||
def test_extract_from_files(self):
|
||||
"""
|
||||
Should be able to extract strings from a specific file.
|
||||
"""
|
||||
testfile = ('lib/l10n_utils/tests/test_files/templates/'
|
||||
'even_more_lang_files.html',)
|
||||
testfile = ('templates/even_more_lang_files.html',)
|
||||
with capture_stdio() as out:
|
||||
extracted = next(extract_from_files(testfile, method_map=METHODS))
|
||||
self.assertTupleEqual(extracted,
|
||||
|
@ -56,7 +56,7 @@ class TestL10nExtract(TestCase):
|
|||
"""
|
||||
Should be able to extract strings from specific files.
|
||||
"""
|
||||
basedir = 'lib/l10n_utils/tests/test_files/templates/'
|
||||
basedir = 'templates/'
|
||||
testfiles = (
|
||||
basedir + 'even_more_lang_files.html',
|
||||
basedir + 'some_lang_files.html',
|
||||
|
@ -88,8 +88,7 @@ class TestL10nExtract(TestCase):
|
|||
"""
|
||||
If the file path doesn't exist, it should be skipped.
|
||||
"""
|
||||
testfile = ('lib/l10n_utils/tests/test_files/templates/'
|
||||
'file_does_not_exist.html',)
|
||||
testfile = ('templates/file_does_not_exist.html',)
|
||||
with capture_stdio() as out:
|
||||
extracted = next(extract_from_files(testfile, method_map=METHODS),
|
||||
None)
|
||||
|
@ -99,8 +98,7 @@ class TestL10nExtract(TestCase):
|
|||
@patch('lib.l10n_utils.management.commands.l10n_extract.extract_from_file')
|
||||
def test_extract_from_files_passes_args(self, eff):
|
||||
"""The correct args should be passed through to extract_from_file"""
|
||||
testfile = ('lib/l10n_utils/tests/test_files/templates/'
|
||||
'even_more_lang_files.html',)
|
||||
testfile = ('templates/even_more_lang_files.html',)
|
||||
testfile_full = path.join(settings.ROOT, testfile[0])
|
||||
next(extract_from_files(testfile, method_map=METHODS), None)
|
||||
eff.assert_called_once_with(METHODS[0][1], testfile_full,
|
||||
|
@ -111,14 +109,14 @@ class TestL10nExtract(TestCase):
|
|||
|
||||
def test_extract_from_files_callback_works(self):
|
||||
"""extract_from_files should call our callback"""
|
||||
testfile = ('lib/l10n_utils/tests/test_files/templates/'
|
||||
'even_more_lang_files.html',)
|
||||
testfile = ('templates/even_more_lang_files.html',)
|
||||
callback = Mock()
|
||||
next(extract_from_files(testfile, callback=callback,
|
||||
method_map=METHODS), None)
|
||||
callback.assert_called_once_with(testfile[0], METHODS[0][1], ANY)
|
||||
|
||||
|
||||
@override_settings(ROOT=ROOT)
|
||||
class TestL10nCheck(TestCase):
|
||||
def _get_block(self, blocks, name):
|
||||
"""Out of all blocks, grab the one with the specified name."""
|
||||
|
@ -330,6 +328,7 @@ class TestL10nCheck(TestCase):
|
|||
self.assertEqual(open_buffer.getvalue(), good_value)
|
||||
|
||||
|
||||
@override_settings(ROOT=ROOT)
|
||||
class Testl10nMerge(TestCase):
|
||||
@patch('lib.l10n_utils.gettext.settings.ROOT', ROOT)
|
||||
@patch('lib.l10n_utils.gettext._append_to_lang_file')
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import clear_url_caches
|
||||
from django.test import override_settings
|
||||
|
||||
from jingo import env
|
||||
from jinja2 import FileSystemLoader
|
||||
|
@ -38,11 +37,9 @@ class TestL10nBlocks(TestCase):
|
|||
|
||||
|
||||
@patch.object(env, 'loader', FileSystemLoader(TEMPLATE_DIRS))
|
||||
@patch.object(settings, 'ROOT_URLCONF', 'lib.l10n_utils.tests.test_files.urls')
|
||||
@patch.object(settings, 'ROOT', ROOT)
|
||||
@override_settings(ROOT=ROOT)
|
||||
class TestTransBlocks(TestCase):
|
||||
def setUp(self):
|
||||
clear_url_caches()
|
||||
urls = 'lib.l10n_utils.tests.test_files.urls'
|
||||
|
||||
def test_trans_block_works(self):
|
||||
""" Sanity check to make sure translations work at all. """
|
||||
|
@ -63,11 +60,11 @@ class TestTransBlocks(TestCase):
|
|||
self.test_trans_block_works()
|
||||
|
||||
|
||||
@patch.object(env, 'loader', FileSystemLoader(TEMPLATE_DIRS))
|
||||
@override_settings(ROOT=ROOT)
|
||||
class TestTemplateLangFiles(TestCase):
|
||||
def setUp(self):
|
||||
clear_url_caches()
|
||||
urls = 'lib.l10n_utils.tests.test_files.urls'
|
||||
|
||||
@patch.object(env, 'loader', FileSystemLoader(TEMPLATE_DIRS))
|
||||
def test_added_lang_files(self):
|
||||
"""
|
||||
Lang files specified in the template should be added to the defaults.
|
||||
|
@ -79,7 +76,6 @@ class TestTemplateLangFiles(TestCase):
|
|||
eq_(request.langfiles, ['dude', 'walter',
|
||||
'main', 'download_button'])
|
||||
|
||||
@patch.object(env, 'loader', FileSystemLoader(TEMPLATE_DIRS))
|
||||
def test_added_lang_files_inheritance(self):
|
||||
"""
|
||||
Lang files specified in the template should be added to the defaults
|
||||
|
@ -96,9 +92,6 @@ class TestTemplateLangFiles(TestCase):
|
|||
eq_(request.langfiles, ['donnie', 'smokey', 'jesus', 'dude', 'walter',
|
||||
'main', 'download_button'])
|
||||
|
||||
@patch.object(env, 'loader', FileSystemLoader(TEMPLATE_DIRS))
|
||||
@patch.object(settings, 'ROOT_URLCONF', 'lib.l10n_utils.tests.test_files.urls')
|
||||
@patch.object(settings, 'ROOT', ROOT)
|
||||
@patch('lib.l10n_utils.settings.DEV', True)
|
||||
@patch('lib.l10n_utils.helpers.translate')
|
||||
def test_lang_files_order(self, translate):
|
||||
|
@ -110,9 +103,6 @@ class TestTemplateLangFiles(TestCase):
|
|||
translate.assert_called_with(ANY, ['dude', 'walter', 'some_lang_files',
|
||||
'main', 'download_button'])
|
||||
|
||||
@patch.object(env, 'loader', FileSystemLoader(TEMPLATE_DIRS))
|
||||
@patch.object(settings, 'ROOT_URLCONF', 'lib.l10n_utils.tests.test_files.urls')
|
||||
@patch.object(settings, 'ROOT', ROOT)
|
||||
@patch('lib.l10n_utils.settings.DEV', True)
|
||||
@patch('lib.l10n_utils.helpers.translate')
|
||||
def test_lang_files_default_order(self, translate):
|
||||
|
|
Загрузка…
Ссылка в новой задаче