Update gitignore, updates to mock/patch import paths, minor fixes along the way.
This commit is contained in:
Родитель
45a1fa120e
Коммит
580ccf7710
|
@ -11,11 +11,11 @@ shellng_local.py
|
|||
pip-log.txt
|
||||
docs/_gh-pages
|
||||
docs/api/_build
|
||||
olympia/lib/product_json/.gitignore
|
||||
olympia/lib/product_json/*.json
|
||||
olympia/lib/product_json/.last_update
|
||||
olympia/lib/product_json/regions/*.json
|
||||
olympia/lib/product_json/regions/.last_update
|
||||
src/olympia/lib/product_json/.gitignore
|
||||
src/olympia/lib/product_json/*.json
|
||||
src/olympia/lib/product_json/.last_update
|
||||
src/olympia/lib/product_json/regions/*.json
|
||||
src/olympia/lib/product_json/regions/.last_update
|
||||
build*.py
|
||||
web/media/build_id.txt
|
||||
web/media/manifest.appcache
|
||||
|
|
|
@ -7,8 +7,8 @@ from time import time
|
|||
from wsgiref.handlers import format_date_time
|
||||
|
||||
from olympia.constants import base
|
||||
from olympia.utils import log_configure, log_exception, mypool
|
||||
|
||||
from services.utils import log_configure, log_exception, mypool
|
||||
from services.utils import settings, user_media_path, user_media_url
|
||||
|
||||
# Configure the log.
|
||||
|
|
|
@ -109,8 +109,8 @@ DEBUG_TOOLBAR_CONFIG = {
|
|||
}
|
||||
|
||||
AES_KEYS = {
|
||||
'api_key:secret': os.path.join(ROOT, 'apps', 'api', 'tests', 'assets',
|
||||
'test-api-key.txt'),
|
||||
'api_key:secret': os.path.join(
|
||||
ROOT, 'src', 'olympia', 'api', 'tests', 'assets', 'test-api-key.txt'),
|
||||
}
|
||||
|
||||
# FxA config for local development only.
|
||||
|
|
|
@ -84,7 +84,7 @@ CACHES = {
|
|||
# Overrides whatever storage you might have put in local settings.
|
||||
DEFAULT_FILE_STORAGE = 'olympia.amo.utils.LocalFileStorage'
|
||||
|
||||
VIDEO_LIBRARIES = ['lib.video.dummy']
|
||||
VIDEO_LIBRARIES = ['olympia.lib.video.dummy']
|
||||
|
||||
ALLOW_SELF_REVIEWS = True
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.core import mail
|
|||
from nose.tools import eq_
|
||||
|
||||
from olympia.amo.tests import TestCase
|
||||
from olympia.olympia.abuse.models import AbuseReport
|
||||
from olympia.abuse.models import AbuseReport
|
||||
|
||||
|
||||
class TestAbuse(TestCase):
|
||||
|
|
|
@ -9,7 +9,7 @@ from olympia.accounts import verify
|
|||
class TestProfile(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
patcher = mock.patch('apps.accounts.verify.requests.get')
|
||||
patcher = mock.patch('olympia.accounts.verify.requests.get')
|
||||
self.get = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
@ -53,7 +53,7 @@ class TestProfile(TestCase):
|
|||
class TestToken(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
patcher = mock.patch('apps.accounts.verify.requests.post')
|
||||
patcher = mock.patch('olympia.accounts.verify.requests.post')
|
||||
self.post = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
@ -111,10 +111,10 @@ class TestIdentify(TestCase):
|
|||
CONFIG = {'foo': 'bar'}
|
||||
|
||||
def setUp(self):
|
||||
patcher = mock.patch('apps.accounts.verify.get_fxa_token')
|
||||
patcher = mock.patch('olympia.accounts.verify.get_fxa_token')
|
||||
self.get_token = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
patcher = mock.patch('apps.accounts.verify.get_fxa_profile')
|
||||
patcher = mock.patch('olympia.accounts.verify.get_fxa_profile')
|
||||
self.get_profile = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class TestLoginUser(TestCase):
|
|||
self.request = RequestFactory().get('/login')
|
||||
self.user = UserProfile.objects.create(email='real@yeahoo.com')
|
||||
self.identity = {'email': 'real@yeahoo.com', 'uid': '9001'}
|
||||
patcher = mock.patch('accounts.views.login')
|
||||
patcher = mock.patch('olympia.accounts.views.login')
|
||||
self.login = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
@ -112,10 +112,10 @@ class TestFindUser(TestCase):
|
|||
class TestWithUser(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
patcher = mock.patch('accounts.views.verify.fxa_identify')
|
||||
patcher = mock.patch('olympia.accounts.views.verify.fxa_identify')
|
||||
self.fxa_identify = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
patcher = mock.patch('accounts.views.find_user')
|
||||
patcher = mock.patch('olympia.accounts.views.find_user')
|
||||
self.find_user = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
self.request = mock.MagicMock()
|
||||
|
@ -245,7 +245,7 @@ class TestWithUser(TestCase):
|
|||
'next_path': None,
|
||||
}
|
||||
|
||||
@mock.patch('accounts.views.Response')
|
||||
@mock.patch('olympia.accounts.views.Response')
|
||||
def test_profile_does_not_exist(self, Response):
|
||||
self.fxa_identify.side_effect = verify.IdentificationError
|
||||
self.request.DATA = {'code': 'foo', 'state': 'some-blob'}
|
||||
|
@ -254,7 +254,7 @@ class TestWithUser(TestCase):
|
|||
{'error': 'Profile not found.'}, status=401)
|
||||
assert not self.find_user.called
|
||||
|
||||
@mock.patch('accounts.views.Response')
|
||||
@mock.patch('olympia.accounts.views.Response')
|
||||
def test_code_not_provided(self, Response):
|
||||
self.request.DATA = {'hey': 'hi', 'state': 'some-blob'}
|
||||
self.fn(self.request)
|
||||
|
@ -291,7 +291,7 @@ class TestWithUser(TestCase):
|
|||
'next_path': None,
|
||||
}
|
||||
|
||||
@mock.patch('accounts.views.Response')
|
||||
@mock.patch('olympia.accounts.views.Response')
|
||||
def test_logged_in_does_not_match_identity_migrated(self, Response):
|
||||
identity = {'uid': '1234', 'email': 'hey@yo.it'}
|
||||
self.fxa_identify.return_value = identity
|
||||
|
@ -303,7 +303,7 @@ class TestWithUser(TestCase):
|
|||
Response.assert_called_with(
|
||||
{'error': 'User already migrated.'}, status=422)
|
||||
|
||||
@mock.patch('accounts.views.Response')
|
||||
@mock.patch('olympia.accounts.views.Response')
|
||||
def test_logged_in_does_not_match_conflict(self, Response):
|
||||
identity = {'uid': '1234', 'email': 'hey@yo.it'}
|
||||
self.fxa_identify.return_value = identity
|
||||
|
@ -329,7 +329,7 @@ class TestRegisterUser(TestCase):
|
|||
def setUp(self):
|
||||
self.request = RequestFactory().get('/register')
|
||||
self.identity = {'email': 'me@yeahoo.com', 'uid': '9005'}
|
||||
patcher = mock.patch('accounts.views.login')
|
||||
patcher = mock.patch('olympia.accounts.views.login')
|
||||
self.login = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
@ -364,7 +364,7 @@ class BaseAuthenticationView(APITestCase, InitializeSessionMixin):
|
|||
def setUp(self):
|
||||
self.url = reverse(self.view_name)
|
||||
create_switch('fxa-auth', active=True)
|
||||
self.fxa_identify = self.patch('accounts.views.verify.fxa_identify')
|
||||
self.fxa_identify = self.patch('olympia.accounts.views.verify.fxa_identify')
|
||||
|
||||
def patch(self, thing):
|
||||
patcher = mock.patch(thing)
|
||||
|
@ -378,7 +378,7 @@ class TestLoginView(BaseAuthenticationView):
|
|||
def setUp(self):
|
||||
super(TestLoginView, self).setUp()
|
||||
self.initialize_session({'fxa_state': 'some-blob'})
|
||||
self.login_user = self.patch('accounts.views.login_user')
|
||||
self.login_user = self.patch('olympia.accounts.views.login_user')
|
||||
|
||||
def test_no_code_provided(self):
|
||||
response = self.client.post(self.url)
|
||||
|
@ -439,7 +439,7 @@ class TestRegisterView(BaseAuthenticationView):
|
|||
def setUp(self):
|
||||
super(TestRegisterView, self).setUp()
|
||||
self.initialize_session({'fxa_state': 'some-blob'})
|
||||
self.register_user = self.patch('accounts.views.register_user')
|
||||
self.register_user = self.patch('olympia.accounts.views.register_user')
|
||||
|
||||
def test_no_code_provided(self):
|
||||
response = self.client.post(self.url)
|
||||
|
@ -481,8 +481,8 @@ class TestAuthorizeView(BaseAuthenticationView):
|
|||
def setUp(self):
|
||||
super(TestAuthorizeView, self).setUp()
|
||||
self.initialize_session({'fxa_state': 'the-right-blob'})
|
||||
self.login_user = self.patch('accounts.views.login_user')
|
||||
self.register_user = self.patch('accounts.views.register_user')
|
||||
self.login_user = self.patch('olympia.accounts.views.login_user')
|
||||
self.register_user = self.patch('olympia.accounts.views.register_user')
|
||||
|
||||
def test_no_code_provided(self):
|
||||
response = self.client.get(self.url)
|
||||
|
|
|
@ -73,7 +73,7 @@ class ButtonTest(TestCase):
|
|||
'request': self.request,
|
||||
}
|
||||
|
||||
@patch('addons.buttons.jingo.env.get_template')
|
||||
@patch('olympia.addons.buttons.jingo.env.get_template')
|
||||
def get_button(self, t_mock, **kwargs):
|
||||
"""Proxy for calling install_button."""
|
||||
template_mock = Mock()
|
||||
|
@ -486,8 +486,8 @@ class TestButtonHtml(ButtonTest):
|
|||
doc = self.render()
|
||||
eq_(doc('.contrib .os').text(), '')
|
||||
|
||||
@patch('addons.buttons.install_button')
|
||||
@patch('addons.helpers.statusflags')
|
||||
@patch('olympia.addons.buttons.install_button')
|
||||
@patch('olympia.addons.helpers.statusflags')
|
||||
def test_big_install_button_xss(self, flags_mock, button_mock):
|
||||
# Make sure there's no xss in statusflags.
|
||||
button_mock.return_value = jinja2.Markup('<b>button</b>')
|
||||
|
|
|
@ -12,7 +12,7 @@ from olympia.editors.models import ReviewerScore
|
|||
|
||||
|
||||
# Where to monkeypatch "lib.crypto.tasks.sign_addons" so it's correctly mocked.
|
||||
SIGN_ADDONS = 'addons.management.commands.sign_addons.sign_addons'
|
||||
SIGN_ADDONS = 'olympia.addons.management.commands.sign_addons.sign_addons'
|
||||
|
||||
|
||||
# Test the "sign_addons" command.
|
||||
|
@ -224,7 +224,7 @@ def test_fix_let_scope_bustage_no_addon_id():
|
|||
assert 'Please provide at least one add-on id to fix.' in exc_info.value
|
||||
|
||||
|
||||
@mock.patch('addons.management.commands.fix_let_scope_bustage.'
|
||||
@mock.patch('olympia.addons.management.commands.fix_let_scope_bustage.'
|
||||
'fix_let_scope_bustage_in_addons.delay')
|
||||
def test_fix_let_scope_bustage(mock_fixer):
|
||||
"""The command should call the task with the list of add-on id provided."""
|
||||
|
|
|
@ -7,13 +7,13 @@ from django.core.management.base import CommandError
|
|||
from django.test.utils import override_settings
|
||||
|
||||
from nose.tools import eq_
|
||||
from django.core.management.base import CommandError
|
||||
import mock
|
||||
|
||||
from olympia import amo
|
||||
from olympia.amo.tests import TestCase
|
||||
from olympia.addons import cron
|
||||
from olympia.addons.models import Addon, AppSupport
|
||||
from olympia.django.core.management.base import CommandError
|
||||
from olympia.files.models import File
|
||||
from olympia.lib.es.utils import flag_reindexing_amo, unflag_reindexing_amo
|
||||
from olympia.stats.models import UpdateCount
|
||||
|
@ -130,7 +130,7 @@ class TestHideDisabledFiles(TestCase):
|
|||
self.f2 = File.objects.create(version=self.version, filename='f2',
|
||||
platform=p)
|
||||
|
||||
@mock.patch('files.models.os')
|
||||
@mock.patch('olympia.files.models.os')
|
||||
def test_leave_nondisabled_files(self, os_mock):
|
||||
# All these addon/file status pairs should stay.
|
||||
stati = [(amo.STATUS_PUBLIC, amo.STATUS_PUBLIC),
|
||||
|
@ -146,8 +146,8 @@ class TestHideDisabledFiles(TestCase):
|
|||
cron.hide_disabled_files()
|
||||
assert not os_mock.path.exists.called, (addon_status, file_status)
|
||||
|
||||
@mock.patch('files.models.File.mv')
|
||||
@mock.patch('files.models.storage')
|
||||
@mock.patch('olympia.files.models.File.mv')
|
||||
@mock.patch('olympia.files.models.storage')
|
||||
def test_move_user_disabled_addon(self, m_storage, mv_mock):
|
||||
# Use Addon.objects.update so the signal handler isn't called.
|
||||
Addon.objects.filter(id=self.addon.id).update(
|
||||
|
@ -170,8 +170,8 @@ class TestHideDisabledFiles(TestCase):
|
|||
eq_(mv_mock.call_count, 2)
|
||||
eq_(m_storage.delete.call_count, 2)
|
||||
|
||||
@mock.patch('files.models.File.mv')
|
||||
@mock.patch('files.models.storage')
|
||||
@mock.patch('olympia.files.models.File.mv')
|
||||
@mock.patch('olympia.files.models.storage')
|
||||
def test_move_admin_disabled_addon(self, m_storage, mv_mock):
|
||||
Addon.objects.filter(id=self.addon.id).update(
|
||||
status=amo.STATUS_DISABLED)
|
||||
|
@ -193,8 +193,8 @@ class TestHideDisabledFiles(TestCase):
|
|||
eq_(mv_mock.call_count, 2)
|
||||
eq_(m_storage.delete.call_count, 2)
|
||||
|
||||
@mock.patch('files.models.File.mv')
|
||||
@mock.patch('files.models.storage')
|
||||
@mock.patch('olympia.files.models.File.mv')
|
||||
@mock.patch('olympia.files.models.storage')
|
||||
def test_move_disabled_file(self, m_storage, mv_mock):
|
||||
Addon.objects.filter(id=self.addon.id).update(status=amo.STATUS_LITE)
|
||||
File.objects.filter(id=self.f1.id).update(status=amo.STATUS_DISABLED)
|
||||
|
@ -299,15 +299,15 @@ class AvgDailyUserCountTestCase(TestCase):
|
|||
|
||||
class TestCleanupImageFiles(TestCase):
|
||||
|
||||
@mock.patch('addons.cron.os')
|
||||
@mock.patch('olympia.addons.cron.os')
|
||||
def test_cleanup_image_files_exists(self, os_mock):
|
||||
cron.cleanup_image_files()
|
||||
assert os_mock.path.exists.called
|
||||
|
||||
@mock.patch('addons.cron.os.unlink')
|
||||
@mock.patch('addons.cron.os.stat')
|
||||
@mock.patch('addons.cron.os.listdir')
|
||||
@mock.patch('addons.cron.os.path')
|
||||
@mock.patch('olympia.addons.cron.os.unlink')
|
||||
@mock.patch('olympia.addons.cron.os.stat')
|
||||
@mock.patch('olympia.addons.cron.os.listdir')
|
||||
@mock.patch('olympia.addons.cron.os.path')
|
||||
def test_cleanup_image_files_age(self, os_path_mock, os_listdir_mock,
|
||||
os_stat_mock, os_unlink_mock):
|
||||
os_path_mock.exists.return_value = True
|
||||
|
|
|
@ -104,8 +104,8 @@ class TestAddonViewWithUnlisted(TestAddonView):
|
|||
self.view = dec.addon_view_factory(
|
||||
qs=Addon.with_unlisted.all)(self.func)
|
||||
|
||||
@mock.patch('access.acl.check_unlisted_addons_reviewer', lambda r: False)
|
||||
@mock.patch('access.acl.check_addon_ownership',
|
||||
@mock.patch('olympia.access.acl.check_unlisted_addons_reviewer', lambda r: False)
|
||||
@mock.patch('olympia.access.acl.check_addon_ownership',
|
||||
lambda *args, **kwargs: False)
|
||||
def test_unlisted_addon(self):
|
||||
"""Return a 404 for non authorized access."""
|
||||
|
@ -113,8 +113,8 @@ class TestAddonViewWithUnlisted(TestAddonView):
|
|||
with self.assertRaises(http.Http404):
|
||||
self.view(self.request, self.addon.slug)
|
||||
|
||||
@mock.patch('access.acl.check_unlisted_addons_reviewer', lambda r: False)
|
||||
@mock.patch('access.acl.check_addon_ownership',
|
||||
@mock.patch('olympia.access.acl.check_unlisted_addons_reviewer', lambda r: False)
|
||||
@mock.patch('olympia.access.acl.check_addon_ownership',
|
||||
lambda *args, **kwargs: True)
|
||||
def test_unlisted_addon_owner(self):
|
||||
"""Addon owners have access."""
|
||||
|
@ -123,8 +123,8 @@ class TestAddonViewWithUnlisted(TestAddonView):
|
|||
request, addon = self.func.call_args[0]
|
||||
assert addon == self.addon
|
||||
|
||||
@mock.patch('access.acl.check_unlisted_addons_reviewer', lambda r: True)
|
||||
@mock.patch('access.acl.check_addon_ownership',
|
||||
@mock.patch('olympia.access.acl.check_unlisted_addons_reviewer', lambda r: True)
|
||||
@mock.patch('olympia.access.acl.check_addon_ownership',
|
||||
lambda *args, **kwargs: False)
|
||||
def test_unlisted_addon_unlisted_admin(self):
|
||||
"""Unlisted addon reviewers have access."""
|
||||
|
|
|
@ -195,7 +195,7 @@ class TestTagsForm(TestCase):
|
|||
eq_(form.errors['tags'][0],
|
||||
'"restartless", "sdk" are reserved tags and cannot be used.')
|
||||
|
||||
@patch('access.acl.action_allowed')
|
||||
@patch('olympia.access.acl.action_allowed')
|
||||
def test_tags_admin_restricted(self, action_allowed):
|
||||
action_allowed.return_value = True
|
||||
self.add_restricted('restartless')
|
||||
|
@ -207,7 +207,7 @@ class TestTagsForm(TestCase):
|
|||
instance=self.addon)
|
||||
eq_(form.fields['tags'].initial, 'bar, foo, restartless')
|
||||
|
||||
@patch('access.acl.action_allowed')
|
||||
@patch('olympia.access.acl.action_allowed')
|
||||
def test_tags_admin_restricted_count(self, action_allowed):
|
||||
action_allowed.return_value = True
|
||||
self.add_restricted()
|
||||
|
@ -261,7 +261,7 @@ class TestIconForm(TestCase):
|
|||
path = os.path.join(self.addon.get_icon_dir(), str(self.addon.id))
|
||||
return ['%s-%s.png' % (path, size) for size in amo.ADDON_ICON_SIZES]
|
||||
|
||||
@patch('apps.addons.models.Addon.get_icon_dir')
|
||||
@patch('olympia.addons.models.Addon.get_icon_dir')
|
||||
def testIconUpload(self, get_icon_dir):
|
||||
# TODO(gkoberger): clarify this please.
|
||||
# We no longer use AddonFormMedia to upload icons, so
|
||||
|
@ -284,7 +284,7 @@ class TestIconForm(TestCase):
|
|||
for path in self.get_icon_paths():
|
||||
assert os.path.exists(path)
|
||||
|
||||
@patch('amo.models.ModelBase.update')
|
||||
@patch('olympia.amo.models.ModelBase.update')
|
||||
def test_icon_modified(self, update_mock):
|
||||
name = 'transparent.png'
|
||||
form = forms.AddonFormMedia({'icon_upload_hash': name},
|
||||
|
@ -312,7 +312,7 @@ class TestCategoryForm(TestCase):
|
|||
|
||||
class TestThemeForm(TestCase):
|
||||
|
||||
@patch('addons.forms.save_theme') # Don't save image, we use a fake one.
|
||||
@patch('olympia.addons.forms.save_theme') # Don't save image, we use a fake one.
|
||||
def test_long_author_or_display_username(self, mock_save_theme):
|
||||
# Bug 1181751.
|
||||
user = UserProfile.objects.create(email='foo@bar.com',
|
||||
|
|
|
@ -973,7 +973,7 @@ class TestAddonModels(TestCase):
|
|||
|
||||
eq_(self.newlines_helper(before), after)
|
||||
|
||||
@patch('amo.helpers.urlresolvers.get_outgoing_url')
|
||||
@patch('olympia.amo.helpers.urlresolvers.get_outgoing_url')
|
||||
def test_newlines_attribute_link_doublequote(self, mock_get_outgoing_url):
|
||||
mock_get_outgoing_url.return_value = 'http://google.com'
|
||||
before = '<a href="http://google.com">test</a>'
|
||||
|
@ -1166,7 +1166,7 @@ class TestAddonModels(TestCase):
|
|||
a = Addon(status=amo.STATUS_PUBLIC)
|
||||
assert not a.show_beta
|
||||
|
||||
@patch('addons.models.Addon.current_beta_version')
|
||||
@patch('olympia.addons.models.Addon.current_beta_version')
|
||||
def test_show_beta_with_beta_version(self, beta_mock):
|
||||
beta_mock.return_value = object()
|
||||
# Fake current_beta_version to return something truthy.
|
||||
|
@ -1340,7 +1340,7 @@ class TestAddonModels(TestCase):
|
|||
a = Addon.objects.create(type=1)
|
||||
assert a.view_source
|
||||
|
||||
@patch('files.models.File.hide_disabled_file')
|
||||
@patch('olympia.files.models.File.hide_disabled_file')
|
||||
def test_admin_disabled_file_hidden(self, hide_mock):
|
||||
a = Addon.objects.get(id=3615)
|
||||
a.status = amo.STATUS_PUBLIC
|
||||
|
@ -1351,7 +1351,7 @@ class TestAddonModels(TestCase):
|
|||
a.save()
|
||||
assert hide_mock.called
|
||||
|
||||
@patch('files.models.File.hide_disabled_file')
|
||||
@patch('olympia.files.models.File.hide_disabled_file')
|
||||
def test_user_disabled_file_hidden(self, hide_mock):
|
||||
a = Addon.objects.get(id=3615)
|
||||
a.disabled_by_user = False
|
||||
|
@ -1995,7 +1995,7 @@ class TestFlushURLs(TestCase):
|
|||
def is_url_hashed(self, url):
|
||||
return urlparse(url).query.find('modified') > -1
|
||||
|
||||
@patch('amo.tasks.flush_front_end_cache_urls.apply_async')
|
||||
@patch('olympia.amo.tasks.flush_front_end_cache_urls.apply_async')
|
||||
def test_addon_flush(self, flush):
|
||||
addon = Addon.objects.get(pk=159)
|
||||
addon.icon_type = "image/png"
|
||||
|
@ -2005,7 +2005,7 @@ class TestFlushURLs(TestCase):
|
|||
assert url in flush.call_args[1]['args'][0]
|
||||
assert self.is_url_hashed(url), url
|
||||
|
||||
@patch('amo.tasks.flush_front_end_cache_urls.apply_async')
|
||||
@patch('olympia.amo.tasks.flush_front_end_cache_urls.apply_async')
|
||||
def test_preview_flush(self, flush):
|
||||
addon = Addon.objects.get(pk=4664)
|
||||
preview = addon.previews.all()[0]
|
||||
|
@ -2028,8 +2028,9 @@ class TestAddonFromUpload(UploadTest):
|
|||
self.addCleanup(translation.deactivate)
|
||||
|
||||
def manifest(self, basename):
|
||||
return os.path.join(settings.ROOT, 'apps', 'devhub', 'tests',
|
||||
'addons', basename)
|
||||
return os.path.join(
|
||||
settings.ROOT, 'src', 'olympia', 'devhub', 'tests', 'addons',
|
||||
basename)
|
||||
|
||||
def test_blacklisted_guid(self):
|
||||
BlacklistedGuid.objects.create(guid='guid@xpi')
|
||||
|
@ -2279,7 +2280,7 @@ class TestAddonWatchDisabled(TestCase):
|
|||
status=amo.STATUS_PUBLIC)
|
||||
self.addon.save()
|
||||
|
||||
@patch('addons.models.File.objects.filter')
|
||||
@patch('olympia.addons.models.File.objects.filter')
|
||||
def test_no_disabled_change(self, file_mock):
|
||||
mock = Mock()
|
||||
file_mock.return_value = [mock]
|
||||
|
@ -2287,7 +2288,7 @@ class TestAddonWatchDisabled(TestCase):
|
|||
assert not mock.unhide_disabled_file.called
|
||||
assert not mock.hide_disabled_file.called
|
||||
|
||||
@patch('addons.models.File.objects.filter')
|
||||
@patch('olympia.addons.models.File.objects.filter')
|
||||
def test_disable_addon(self, file_mock):
|
||||
mock = Mock()
|
||||
file_mock.return_value = [mock]
|
||||
|
@ -2295,7 +2296,7 @@ class TestAddonWatchDisabled(TestCase):
|
|||
assert not mock.unhide_disabled_file.called
|
||||
assert mock.hide_disabled_file.called
|
||||
|
||||
@patch('addons.models.File.objects.filter')
|
||||
@patch('olympia.addons.models.File.objects.filter')
|
||||
def test_admin_disable_addon(self, file_mock):
|
||||
mock = Mock()
|
||||
file_mock.return_value = [mock]
|
||||
|
@ -2303,7 +2304,7 @@ class TestAddonWatchDisabled(TestCase):
|
|||
assert not mock.unhide_disabled_file.called
|
||||
assert mock.hide_disabled_file.called
|
||||
|
||||
@patch('addons.models.File.objects.filter')
|
||||
@patch('olympia.addons.models.File.objects.filter')
|
||||
def test_enable_addon(self, file_mock):
|
||||
mock = Mock()
|
||||
file_mock.return_value = [mock]
|
||||
|
@ -2411,13 +2412,13 @@ class TestTrackAddonStatusChange(TestCase):
|
|||
return addon
|
||||
|
||||
def test_increment_new_status(self):
|
||||
with patch('addons.models.track_addon_status_change') as mock_:
|
||||
with patch('olympia.addons.models.track_addon_status_change') as mock_:
|
||||
addon = self.create_addon()
|
||||
mock_.assert_called_with(addon)
|
||||
|
||||
def test_increment_updated_status(self):
|
||||
addon = self.create_addon()
|
||||
with patch('addons.models.track_addon_status_change') as mock_:
|
||||
with patch('olympia.addons.models.track_addon_status_change') as mock_:
|
||||
addon.update(status=amo.STATUS_PUBLIC)
|
||||
|
||||
addon.reload()
|
||||
|
@ -2425,7 +2426,7 @@ class TestTrackAddonStatusChange(TestCase):
|
|||
|
||||
def test_ignore_non_status_changes(self):
|
||||
addon = self.create_addon()
|
||||
with patch('addons.models.track_addon_status_change') as mock_:
|
||||
with patch('olympia.addons.models.track_addon_status_change') as mock_:
|
||||
addon.update(type=amo.ADDON_THEME)
|
||||
assert not mock_.called, (
|
||||
'Unexpected call: {}'.format(self.mock_incr.call_args)
|
||||
|
@ -2433,7 +2434,7 @@ class TestTrackAddonStatusChange(TestCase):
|
|||
|
||||
def test_increment_all_addon_statuses(self):
|
||||
addon = self.create_addon(status=amo.STATUS_PUBLIC)
|
||||
with patch('addons.models.statsd.incr') as mock_incr:
|
||||
with patch('olympia.addons.models.statsd.incr') as mock_incr:
|
||||
track_addon_status_change(addon)
|
||||
mock_incr.assert_any_call(
|
||||
'addon_status_change.all.status_{}'.format(amo.STATUS_PUBLIC)
|
||||
|
@ -2441,7 +2442,7 @@ class TestTrackAddonStatusChange(TestCase):
|
|||
|
||||
def test_increment_listed_addon_statuses(self):
|
||||
addon = self.create_addon(is_listed=True)
|
||||
with patch('addons.models.statsd.incr') as mock_incr:
|
||||
with patch('olympia.addons.models.statsd.incr') as mock_incr:
|
||||
track_addon_status_change(addon)
|
||||
mock_incr.assert_any_call(
|
||||
'addon_status_change.listed.status_{}'.format(addon.status)
|
||||
|
@ -2449,7 +2450,7 @@ class TestTrackAddonStatusChange(TestCase):
|
|||
|
||||
def test_increment_unlisted_addon_statuses(self):
|
||||
addon = self.create_addon(is_listed=False)
|
||||
with patch('addons.models.statsd.incr') as mock_incr:
|
||||
with patch('olympia.addons.models.statsd.incr') as mock_incr:
|
||||
track_addon_status_change(addon)
|
||||
mock_incr.assert_any_call(
|
||||
'addon_status_change.unlisted.status_{}'.format(addon.status)
|
||||
|
|
|
@ -12,7 +12,8 @@ from olympia.amo.tests import TestCase
|
|||
from olympia.addons.models import Addon
|
||||
from olympia.amo.helpers import user_media_path, user_media_url
|
||||
from olympia.versions.models import Version
|
||||
from olympia.services import theme_update
|
||||
|
||||
from services import theme_update
|
||||
|
||||
|
||||
class TestWSGIApplication(TestCase):
|
||||
|
|
|
@ -12,9 +12,10 @@ from olympia.addons.models import (
|
|||
Addon, CompatOverride, CompatOverrideRange, IncompatibleVersions)
|
||||
from olympia.applications.models import AppVersion
|
||||
from olympia.files.models import File
|
||||
from olympia.services import update
|
||||
from olympia.versions.models import ApplicationsVersions, Version
|
||||
|
||||
from services import update
|
||||
|
||||
|
||||
class VersionCheckMixin(object):
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ class TestContributeEmbedded(TestCase):
|
|||
self.addon = Addon.objects.get(pk=592)
|
||||
self.detail_url = self.addon.get_url_path()
|
||||
|
||||
@patch('paypal.get_paykey')
|
||||
@patch('olympia.paypal.get_paykey')
|
||||
def client_post(self, get_paykey, **kwargs):
|
||||
get_paykey.return_value = ['abc', '']
|
||||
url = reverse('addons.contribute', args=kwargs.pop('rev'))
|
||||
|
@ -220,7 +220,7 @@ class TestContributeEmbedded(TestCase):
|
|||
response = self.client_post(rev=[1])
|
||||
eq_(response.status_code, 404)
|
||||
|
||||
@fudge.patch('paypal.get_paykey')
|
||||
@fudge.patch('olympia.paypal.get_paykey')
|
||||
def test_charity_name(self, get_paykey):
|
||||
(get_paykey.expects_call()
|
||||
.with_matching_args(memo=u'Contribution for foë: foë')
|
||||
|
@ -317,13 +317,13 @@ class TestContributeEmbedded(TestCase):
|
|||
doc = pq(res.content)
|
||||
eq_(len(doc('#contribute-box input[type=radio]')), 1)
|
||||
|
||||
@fudge.patch('paypal.get_paykey')
|
||||
@fudge.patch('olympia.paypal.get_paykey')
|
||||
def test_paypal_error_json(self, get_paykey, **kwargs):
|
||||
get_paykey.expects_call().returns((None, None))
|
||||
res = self.contribute()
|
||||
assert not json.loads(res.content)['paykey']
|
||||
|
||||
@patch('paypal.requests.post')
|
||||
@patch('olympia.paypal.requests.post')
|
||||
def test_paypal_other_error_json(self, post, **kwargs):
|
||||
post.return_value.text = other_error
|
||||
res = self.contribute()
|
||||
|
@ -338,7 +338,7 @@ class TestContributeEmbedded(TestCase):
|
|||
def test_addons_result_page(self):
|
||||
self._test_result_page()
|
||||
|
||||
@fudge.patch('paypal.get_paykey')
|
||||
@fudge.patch('olympia.paypal.get_paykey')
|
||||
def test_not_split(self, get_paykey):
|
||||
def check_call(*args, **kw):
|
||||
assert 'chains' not in kw
|
||||
|
|
|
@ -882,7 +882,7 @@ def copy_file_to_temp(source):
|
|||
|
||||
|
||||
# This sets up a module that we can patch dynamically with URLs.
|
||||
@override_settings(ROOT_URLCONF='amo.tests.dynamic_urls')
|
||||
@override_settings(ROOT_URLCONF='olympia.amo.tests.dynamic_urls')
|
||||
class WithDynamicEndpoints(TestCase):
|
||||
"""
|
||||
Mixin to allow registration of ad-hoc views.
|
||||
|
|
|
@ -63,8 +63,9 @@ def test_resize_image():
|
|||
|
||||
|
||||
def test_resize_transparency():
|
||||
src = os.path.join(settings.ROOT, 'apps', 'amo', 'tests',
|
||||
'images', 'transparent.png')
|
||||
src = os.path.join(
|
||||
settings.ROOT, 'src', 'olympia', 'amo', 'tests',
|
||||
'images', 'transparent.png')
|
||||
dest = tempfile.mkstemp(dir=settings.TMP_PATH)[1]
|
||||
expected = src.replace('.png', '-expected.png')
|
||||
try:
|
||||
|
@ -82,8 +83,9 @@ def test_resize_transparency_for_P_mode_bug_1181221():
|
|||
# https://github.com/jbalogh/zamboni/commit/10340af6d1a64a16f4b9cade9faa69976b5b6da5 # noqa
|
||||
# which caused the issue in bug 1181221. Since then we upgraded Pillow, and
|
||||
# we don't need it anymore. We thus don't have this issue anymore.
|
||||
src = os.path.join(settings.ROOT, 'apps', 'amo', 'tests',
|
||||
'images', 'icon64.png')
|
||||
src = os.path.join(
|
||||
settings.ROOT, 'src', 'olympia', 'amo', 'tests',
|
||||
'images', 'icon64.png')
|
||||
dest = tempfile.mkstemp(dir=settings.TMP_PATH)[1]
|
||||
expected = src.replace('.png', '-expected.png')
|
||||
try:
|
||||
|
@ -240,18 +242,18 @@ class TestCacheNamespaces(BaseTestCase):
|
|||
cache.clear()
|
||||
self.namespace = 'redis-is-dead'
|
||||
|
||||
@mock.patch('amo.utils.epoch')
|
||||
@mock.patch('olympia.amo.utils.epoch')
|
||||
def test_no_preexisting_key(self, epoch_mock):
|
||||
epoch_mock.return_value = 123456
|
||||
eq_(cache_ns_key(self.namespace), '123456:ns:%s' % self.namespace)
|
||||
|
||||
@mock.patch('amo.utils.epoch')
|
||||
@mock.patch('olympia.amo.utils.epoch')
|
||||
def test_no_preexisting_key_incr(self, epoch_mock):
|
||||
epoch_mock.return_value = 123456
|
||||
eq_(cache_ns_key(self.namespace, increment=True),
|
||||
'123456:ns:%s' % self.namespace)
|
||||
|
||||
@mock.patch('amo.utils.epoch')
|
||||
@mock.patch('olympia.amo.utils.epoch')
|
||||
def test_key_incr(self, epoch_mock):
|
||||
epoch_mock.return_value = 123456
|
||||
cache_ns_key(self.namespace) # Sets ns to 123456
|
||||
|
@ -284,7 +286,7 @@ def test_escape_all():
|
|||
yield check, val, expected
|
||||
|
||||
|
||||
@mock.patch('amo.helpers.urlresolvers.get_outgoing_url')
|
||||
@mock.patch('olympia.amo.helpers.urlresolvers.get_outgoing_url')
|
||||
@mock.patch('bleach.callbacks.nofollow', lambda attrs, new: attrs)
|
||||
def test_escape_all_linkify_only_full(mock_get_outgoing_url):
|
||||
mock_get_outgoing_url.return_value = 'http://outgoing.firefox.com'
|
||||
|
|
|
@ -163,21 +163,21 @@ class TestPermissionRequired(TestCase):
|
|||
self.f.__name__ = 'function'
|
||||
self.request = mock.Mock()
|
||||
|
||||
@mock.patch('access.acl.action_allowed')
|
||||
@mock.patch('olympia.access.acl.action_allowed')
|
||||
def test_permission_not_allowed(self, action_allowed):
|
||||
action_allowed.return_value = False
|
||||
func = decorators.permission_required('', '')(self.f)
|
||||
with self.assertRaises(PermissionDenied):
|
||||
func(self.request)
|
||||
|
||||
@mock.patch('access.acl.action_allowed')
|
||||
@mock.patch('olympia.access.acl.action_allowed')
|
||||
def test_permission_allowed(self, action_allowed):
|
||||
action_allowed.return_value = True
|
||||
func = decorators.permission_required('', '')(self.f)
|
||||
func(self.request)
|
||||
assert self.f.called
|
||||
|
||||
@mock.patch('access.acl.action_allowed')
|
||||
@mock.patch('olympia.access.acl.action_allowed')
|
||||
def test_permission_allowed_correctly(self, action_allowed):
|
||||
func = decorators.permission_required('Admin', '%')(self.f)
|
||||
func(self.request)
|
||||
|
|
|
@ -162,7 +162,7 @@ class TestBreadcrumbs(amo.tests.BaseTestCase):
|
|||
assert '<script>' not in s
|
||||
|
||||
|
||||
@patch('amo.helpers.urlresolvers.reverse')
|
||||
@patch('olympia.amo.helpers.urlresolvers.reverse')
|
||||
def test_url(mock_reverse):
|
||||
render('{{ url("viewname", 1, z=2) }}')
|
||||
mock_reverse.assert_called_with('viewname', args=(1,), kwargs={'z': 2},
|
||||
|
@ -263,7 +263,7 @@ def test_external_url():
|
|||
settings.REDIRECT_SECRET_KEY = secretkey
|
||||
|
||||
|
||||
@patch('amo.helpers.urlresolvers.get_outgoing_url')
|
||||
@patch('olympia.amo.helpers.urlresolvers.get_outgoing_url')
|
||||
def test_linkify_bounce_url_callback(mock_get_outgoing_url):
|
||||
mock_get_outgoing_url.return_value = 'bar'
|
||||
|
||||
|
@ -274,7 +274,7 @@ def test_linkify_bounce_url_callback(mock_get_outgoing_url):
|
|||
mock_get_outgoing_url.assert_called_with('foo')
|
||||
|
||||
|
||||
@patch('amo.helpers.urlresolvers.linkify_bounce_url_callback')
|
||||
@patch('olympia.amo.helpers.urlresolvers.linkify_bounce_url_callback')
|
||||
def test_linkify_with_outgoing_text_links(mock_linkify_bounce_url_callback):
|
||||
def side_effect(attrs, new=False):
|
||||
attrs['href'] = 'bar'
|
||||
|
@ -298,7 +298,7 @@ def test_linkify_with_outgoing_text_links(mock_linkify_bounce_url_callback):
|
|||
assert doc('a[href="bar"][rel="nofollow"]')[0].text == 'http://example.com'
|
||||
|
||||
|
||||
@patch('amo.helpers.urlresolvers.linkify_bounce_url_callback')
|
||||
@patch('olympia.amo.helpers.urlresolvers.linkify_bounce_url_callback')
|
||||
def test_linkify_with_outgoing_markup_links(mock_linkify_bounce_url_callback):
|
||||
def side_effect(attrs, new=False):
|
||||
attrs['href'] = 'bar'
|
||||
|
@ -407,7 +407,8 @@ class TestLicenseLink(TestCase):
|
|||
|
||||
|
||||
def get_image_path(name):
|
||||
return os.path.join(settings.ROOT, 'apps', 'amo', 'tests', 'images', name)
|
||||
return os.path.join(
|
||||
settings.ROOT, 'src', 'olympia', 'amo', 'tests', 'images', name)
|
||||
|
||||
|
||||
def get_uploaded_file(name):
|
||||
|
|
|
@ -97,7 +97,7 @@ def test_hide_password_middleware():
|
|||
|
||||
class TestNoAddonsMiddleware(TestCase):
|
||||
|
||||
@patch('amo.middleware.ViewMiddleware.get_name')
|
||||
@patch('olympia.amo.middleware.ViewMiddleware.get_name')
|
||||
def process(self, name, get_name):
|
||||
get_name.return_value = name
|
||||
request = RequestFactory().get('/')
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from pyquery import PyQuery as pq
|
||||
|
||||
from olympia.amo.tests import TestCase
|
||||
from olympia.services.pfs import get_output
|
||||
|
||||
from services.pfs import get_output
|
||||
|
||||
|
||||
class TestPfs(TestCase):
|
||||
|
|
|
@ -25,7 +25,7 @@ def quickcopy(val):
|
|||
|
||||
|
||||
class ReadOnlyModeTest(TestCase):
|
||||
extra = ('amo.middleware.ReadOnlyMiddleware',)
|
||||
extra = ('olympia.amo.middleware.ReadOnlyMiddleware',)
|
||||
|
||||
def setUp(self):
|
||||
super(ReadOnlyModeTest, self).setUp()
|
||||
|
|
|
@ -174,7 +174,7 @@ class TestSendMail(BaseTestCase):
|
|||
eq_(mail.outbox[0].to, ['nobody@mozilla.org'])
|
||||
eq_(FakeEmail.objects.count(), 1)
|
||||
|
||||
@mock.patch('amo.utils.Context')
|
||||
@mock.patch('olympia.amo.utils.Context')
|
||||
def test_dont_localize(self, fake_Context):
|
||||
perm_setting = []
|
||||
|
||||
|
@ -261,7 +261,7 @@ class TestSendMail(BaseTestCase):
|
|||
return backend
|
||||
return make_backend
|
||||
|
||||
@mock.patch('amo.tasks.EmailMessage')
|
||||
@mock.patch('olympia.amo.tasks.EmailMessage')
|
||||
def test_async_will_retry(self, backend):
|
||||
backend.side_effect = self.make_backend_class([True, True, False])
|
||||
with self.assertRaises(RuntimeError):
|
||||
|
@ -273,7 +273,7 @@ class TestSendMail(BaseTestCase):
|
|||
async=True,
|
||||
recipient_list=['somebody@mozilla.org'])
|
||||
|
||||
@mock.patch('amo.tasks.EmailMessage')
|
||||
@mock.patch('olympia.amo.tasks.EmailMessage')
|
||||
def test_async_will_stop_retrying(self, backend):
|
||||
backend.side_effect = self.make_backend_class([True, True])
|
||||
with self.assertRaises(RuntimeError):
|
||||
|
|
|
@ -5,7 +5,7 @@ import pytest
|
|||
from nose.tools import eq_, ok_
|
||||
|
||||
from olympia import amo
|
||||
from olympia.tests import TestCase, addon_factory
|
||||
from olympia.amo.tests import TestCase, addon_factory
|
||||
from olympia.amo.utils import (
|
||||
attach_trans_dict, translations_for_field, walkfiles)
|
||||
from olympia.addons.models import Addon
|
||||
|
|
|
@ -357,7 +357,7 @@ class TestOtherStuff(TestCase):
|
|||
'chromeLocale=en-US&appRelease=10.0.2'))
|
||||
|
||||
|
||||
@mock.patch('amo.views.log_cef')
|
||||
@mock.patch('olympia.amo.views.log_cef')
|
||||
class TestCSP(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -39,7 +39,7 @@ class TestAPIKey(TestCase):
|
|||
max = 3
|
||||
|
||||
# Make APIKey.objects.filter().exists() always return True.
|
||||
patch = mock.patch('apps.api.models.APIKey.objects.filter')
|
||||
patch = mock.patch('olympia.api.models.APIKey.objects.filter')
|
||||
mock_filter = patch.start()
|
||||
self.addCleanup(patch.stop)
|
||||
mock_filter.return_value.exists.return_value = True
|
||||
|
|
|
@ -468,7 +468,7 @@ class TestAddon(BaseOAuth):
|
|||
"'%s' didn't match: got '%s' instead of '%s'"
|
||||
% (field, getattr(a, field), expected))
|
||||
|
||||
@patch('api.handlers.AddonForm.is_valid')
|
||||
@patch('olympia.api.handlers.AddonForm.is_valid')
|
||||
def test_update_fail(self, is_valid):
|
||||
data = self.create_addon()
|
||||
id = data['id']
|
||||
|
@ -482,7 +482,7 @@ class TestAddon(BaseOAuth):
|
|||
data={})
|
||||
eq_(r.status_code, 410, r.content)
|
||||
|
||||
@patch('api.handlers.XPIForm.clean_xpi')
|
||||
@patch('olympia.api.handlers.XPIForm.clean_xpi')
|
||||
def test_xpi_failure(self, f):
|
||||
f.side_effect = forms.ValidationError('F')
|
||||
r = self.make_create_request(self.create_data)
|
||||
|
@ -506,7 +506,7 @@ class TestAddon(BaseOAuth):
|
|||
r = self.make_create_request(self.create_data)
|
||||
eq_(r.status_code, 400, r.content)
|
||||
|
||||
@patch('versions.models.AppVersion.objects.get')
|
||||
@patch('olympia.versions.models.AppVersion.objects.get')
|
||||
def test_bad_appversion(self, get):
|
||||
get.side_effect = AppVersion.DoesNotExist()
|
||||
data = self.create_addon()
|
||||
|
@ -667,10 +667,10 @@ class TestAddon(BaseOAuth):
|
|||
eq_(json.loads(r.content)['statuses'],
|
||||
[[File.objects.all()[0].pk, 1]])
|
||||
|
||||
@patch('api.authorization.AllowRelatedAppOwner.has_object_permission')
|
||||
@patch('api.authorization.AllowAppOwner.has_object_permission')
|
||||
@patch('access.acl.action_allowed')
|
||||
@patch('access.acl.check_addon_ownership')
|
||||
@patch('olympia.api.authorization.AllowRelatedAppOwner.has_object_permission')
|
||||
@patch('olympia.api.authorization.AllowAppOwner.has_object_permission')
|
||||
@patch('olympia.access.acl.action_allowed')
|
||||
@patch('olympia.access.acl.check_addon_ownership')
|
||||
def test_not_my_addon(self, addon_ownership, action_allowed,
|
||||
app_owner, related_app_owner):
|
||||
data = self.create_addon()
|
||||
|
|
|
@ -1315,13 +1315,13 @@ class LanguagePacksTest(UploadTest):
|
|||
self.setup_localepicker(amo.PLATFORM_MAC.id)
|
||||
eq_(self.addon.get_localepicker(), '')
|
||||
|
||||
@patch('apps.files.models.File.get_localepicker')
|
||||
@patch('olympia.files.models.File.get_localepicker')
|
||||
def test_search_right_platform(self, get_localepicker):
|
||||
get_localepicker.return_value = 'some data'
|
||||
self.setup_localepicker(amo.PLATFORM_ANDROID.id)
|
||||
eq_(self.addon.get_localepicker(), 'some data')
|
||||
|
||||
@patch('apps.addons.models.Addon.get_localepicker')
|
||||
@patch('olympia.addons.models.Addon.get_localepicker')
|
||||
def test_localepicker(self, get_localepicker):
|
||||
get_localepicker.return_value = unicode('title=اختر لغة', 'utf8')
|
||||
self.addon.update(type=amo.ADDON_LPAPP, status=amo.STATUS_PUBLIC)
|
||||
|
|
|
@ -254,7 +254,7 @@ class TestRecommendations(TestCase):
|
|||
def test_build_recs(self):
|
||||
eq_(RecommendedCollection.build_recs(self.ids), self.expected_recs())
|
||||
|
||||
@mock.patch('bandwagon.models.AddonRecommendation.scores')
|
||||
@mock.patch('olympia.bandwagon.models.AddonRecommendation.scores')
|
||||
def test_no_dups(self, scores):
|
||||
# The inner dict is the recommended addons for addon 7.
|
||||
scores.return_value = {7: {1: 5, 2: 3, 3: 4}}
|
||||
|
|
|
@ -387,7 +387,7 @@ class TestCRUD(TestCase):
|
|||
eq_(r.status_code, 200)
|
||||
return r
|
||||
|
||||
@patch('bandwagon.views.statsd.incr')
|
||||
@patch('olympia.bandwagon.views.statsd.incr')
|
||||
def test_create_collection_statsd(self, mock_incr):
|
||||
self.client.post(self.add_url, self.data, follow=True)
|
||||
mock_incr.assert_any_call('collections.created')
|
||||
|
@ -756,7 +756,7 @@ class TestCRUD(TestCase):
|
|||
]
|
||||
amo.tests.check_links(expected, links)
|
||||
|
||||
@patch('access.acl.action_allowed')
|
||||
@patch('olympia.access.acl.action_allowed')
|
||||
def test_admin(self, f):
|
||||
self.create_collection()
|
||||
url = reverse('collections.edit',
|
||||
|
@ -1232,7 +1232,7 @@ class TestMobileCollections(TestMobile):
|
|||
class TestCollectionForm(TestCase):
|
||||
fixtures = ['base/collection_57181', 'users/test_backends']
|
||||
|
||||
@patch('amo.models.ModelBase.update')
|
||||
@patch('olympia.amo.models.ModelBase.update')
|
||||
def test_icon(self, update_mock):
|
||||
collection = Collection.objects.get(pk=57181)
|
||||
# TODO(andym): altering this form is too complicated, can we simplify?
|
||||
|
@ -1309,7 +1309,7 @@ class TestCollectionForm(TestCase):
|
|||
assert not form.is_valid()
|
||||
assert 'spam' in form.errors['__all__'][0]
|
||||
|
||||
@patch('bandwagon.forms.statsd.incr')
|
||||
@patch('olympia.bandwagon.forms.statsd.incr')
|
||||
def test_honeypot_statsd_incr(self, mock_incr):
|
||||
author = UserProfile.objects.get(pk=9945)
|
||||
|
||||
|
|
|
@ -136,13 +136,13 @@ class TestReporter(TestCase):
|
|||
self.assert3xx(
|
||||
self.client.get(self.url.format(self.addon.guid[:5])), expected)
|
||||
|
||||
@mock.patch('compat.views.owner_or_unlisted_reviewer', lambda r, a: True)
|
||||
@mock.patch('olympia.compat.views.owner_or_unlisted_reviewer', lambda r, a: True)
|
||||
def test_unlisted_addon_redirect_for_authorized(self):
|
||||
"""Can display the reports for an unlisted addon if authorized."""
|
||||
self.addon.update(is_listed=False)
|
||||
self.test_redirect()
|
||||
|
||||
@mock.patch('compat.views.owner_or_unlisted_reviewer',
|
||||
@mock.patch('olympia.compat.views.owner_or_unlisted_reviewer',
|
||||
lambda r, a: False)
|
||||
def test_unlisted_addon_no_redirect_for_unauthorized(self):
|
||||
"""If the user isn't authorized, don't redirect to unlisted addon."""
|
||||
|
@ -294,7 +294,7 @@ class TestReporterDetail(TestCase):
|
|||
msg = 'Unknown (%s)' % app_guid
|
||||
assert msg in r.content, 'Expected %s in body' % msg
|
||||
|
||||
@mock.patch('compat.views.owner_or_unlisted_reviewer',
|
||||
@mock.patch('olympia.compat.views.owner_or_unlisted_reviewer',
|
||||
lambda r, a: True)
|
||||
def test_unlisted_addon_details_for_authorized(self):
|
||||
"""If the user is authorized, display the reports."""
|
||||
|
@ -304,7 +304,7 @@ class TestReporterDetail(TestCase):
|
|||
good=3, bad=7, appver='',
|
||||
report_pks=[idx for idx, val in enumerate(self.reports)])
|
||||
|
||||
@mock.patch('compat.views.owner_or_unlisted_reviewer',
|
||||
@mock.patch('olympia.compat.views.owner_or_unlisted_reviewer',
|
||||
lambda r, a: False)
|
||||
def test_unlisted_addon_no_details_for_unauthorized(self):
|
||||
"""If the user isn't authorized, don't display the reports."""
|
||||
|
|
|
@ -46,11 +46,11 @@ class TestNewAddonForm(TestCase):
|
|||
|
||||
# Those three patches are so files.utils.parse_addon doesn't fail on a
|
||||
# non-existent file even before having a chance to call check_xpi_info.
|
||||
@mock.patch('files.utils.Extractor.parse')
|
||||
@mock.patch('files.utils.extract_xpi', lambda xpi, path: None)
|
||||
@mock.patch('files.utils.get_file', lambda xpi: None)
|
||||
@mock.patch('olympia.files.utils.Extractor.parse')
|
||||
@mock.patch('olympia.files.utils.extract_xpi', lambda xpi, path: None)
|
||||
@mock.patch('olympia.files.utils.get_file', lambda xpi: None)
|
||||
# This is the one we want to test.
|
||||
@mock.patch('files.utils.check_xpi_info')
|
||||
@mock.patch('olympia.files.utils.check_xpi_info')
|
||||
def test_check_xpi_called(self, mock_check_xpi_info, mock_parse):
|
||||
"""Make sure the check_xpi_info helper is called.
|
||||
|
||||
|
@ -72,11 +72,11 @@ class TestNewVersionForm(TestCase):
|
|||
|
||||
# Those three patches are so files.utils.parse_addon doesn't fail on a
|
||||
# non-existent file even before having a chance to call check_xpi_info.
|
||||
@mock.patch('files.utils.Extractor.parse')
|
||||
@mock.patch('files.utils.extract_xpi', lambda xpi, path: None)
|
||||
@mock.patch('files.utils.get_file', lambda xpi: None)
|
||||
@mock.patch('olympia.files.utils.Extractor.parse')
|
||||
@mock.patch('olympia.files.utils.extract_xpi', lambda xpi, path: None)
|
||||
@mock.patch('olympia.files.utils.get_file', lambda xpi: None)
|
||||
# This is the one we want to test.
|
||||
@mock.patch('files.utils.check_xpi_info')
|
||||
@mock.patch('olympia.files.utils.check_xpi_info')
|
||||
def test_check_xpi_called(self, mock_check_xpi_info, mock_parse):
|
||||
"""Make sure the check_xpi_info helper is called.
|
||||
|
||||
|
@ -101,11 +101,11 @@ class TestNewFileForm(TestCase):
|
|||
|
||||
# Those three patches are so files.utils.parse_addon doesn't fail on a
|
||||
# non-existent file even before having a chance to call check_xpi_info.
|
||||
@mock.patch('files.utils.Extractor.parse')
|
||||
@mock.patch('files.utils.extract_xpi', lambda xpi, path: None)
|
||||
@mock.patch('files.utils.get_file', lambda xpi: None)
|
||||
@mock.patch('olympia.files.utils.Extractor.parse')
|
||||
@mock.patch('olympia.files.utils.extract_xpi', lambda xpi, path: None)
|
||||
@mock.patch('olympia.files.utils.get_file', lambda xpi: None)
|
||||
# This is the one we want to test.
|
||||
@mock.patch('files.utils.check_xpi_info')
|
||||
@mock.patch('olympia.files.utils.check_xpi_info')
|
||||
def test_check_xpi_called(self, mock_check_xpi_info, mock_parse):
|
||||
"""Make sure the check_xpi_info helper is called.
|
||||
|
||||
|
@ -197,7 +197,7 @@ class TestPreviewForm(TestCase):
|
|||
if not os.path.exists(self.dest):
|
||||
os.makedirs(self.dest)
|
||||
|
||||
@mock.patch('amo.models.ModelBase.update')
|
||||
@mock.patch('olympia.amo.models.ModelBase.update')
|
||||
def test_preview_modified(self, update_mock):
|
||||
addon = Addon.objects.get(pk=3615)
|
||||
name = 'transparent.png'
|
||||
|
@ -370,9 +370,9 @@ class TestThemeForm(TestCase):
|
|||
{'data-allowed-types': 'image/jpeg|image/png',
|
||||
'data-upload-url': footer_url})
|
||||
|
||||
@mock.patch('addons.tasks.make_checksum')
|
||||
@mock.patch('addons.tasks.create_persona_preview_images')
|
||||
@mock.patch('addons.tasks.save_persona_image')
|
||||
@mock.patch('olympia.addons.tasks.make_checksum')
|
||||
@mock.patch('olympia.addons.tasks.create_persona_preview_images')
|
||||
@mock.patch('olympia.addons.tasks.save_persona_image')
|
||||
def test_success(self, save_persona_image_mock,
|
||||
create_persona_preview_images_mock, make_checksum_mock):
|
||||
if not hasattr(Image.core, 'jpeg_encoder'):
|
||||
|
@ -441,9 +441,9 @@ class TestThemeForm(TestCase):
|
|||
os.path.join(dst, 'icon.png')],
|
||||
set_modified_on=[addon])
|
||||
|
||||
@mock.patch('addons.tasks.create_persona_preview_images')
|
||||
@mock.patch('addons.tasks.save_persona_image')
|
||||
@mock.patch('addons.tasks.make_checksum')
|
||||
@mock.patch('olympia.addons.tasks.create_persona_preview_images')
|
||||
@mock.patch('olympia.addons.tasks.save_persona_image')
|
||||
@mock.patch('olympia.addons.tasks.make_checksum')
|
||||
def test_dupe_persona(self, make_checksum_mock, mock1, mock2):
|
||||
"""
|
||||
Submitting persona with checksum already in db should be marked
|
||||
|
@ -585,9 +585,9 @@ class TestEditThemeForm(TestCase):
|
|||
eq_(self.form.is_valid(), True, self.form.errors)
|
||||
self.form.save()
|
||||
|
||||
@mock.patch('addons.tasks.make_checksum')
|
||||
@mock.patch('addons.tasks.create_persona_preview_images')
|
||||
@mock.patch('addons.tasks.save_persona_image')
|
||||
@mock.patch('olympia.addons.tasks.make_checksum')
|
||||
@mock.patch('olympia.addons.tasks.create_persona_preview_images')
|
||||
@mock.patch('olympia.addons.tasks.save_persona_image')
|
||||
def test_reupload(self, save_persona_image_mock,
|
||||
create_persona_preview_images_mock,
|
||||
make_checksum_mock):
|
||||
|
@ -616,9 +616,9 @@ class TestEditThemeForm(TestCase):
|
|||
eq_(rqt[0].footer, 'pending_footer.png')
|
||||
assert not rqt[0].dupe_persona
|
||||
|
||||
@mock.patch('addons.tasks.create_persona_preview_images', new=mock.Mock)
|
||||
@mock.patch('addons.tasks.save_persona_image', new=mock.Mock)
|
||||
@mock.patch('addons.tasks.make_checksum')
|
||||
@mock.patch('olympia.addons.tasks.create_persona_preview_images', new=mock.Mock)
|
||||
@mock.patch('olympia.addons.tasks.save_persona_image', new=mock.Mock)
|
||||
@mock.patch('olympia.addons.tasks.make_checksum')
|
||||
def test_reupload_duplicate(self, make_checksum_mock):
|
||||
make_checksum_mock.return_value = 'checksumbeforeyouwrecksome'
|
||||
|
||||
|
@ -635,9 +635,9 @@ class TestEditThemeForm(TestCase):
|
|||
rqt = RereviewQueueTheme.objects.get(theme=self.instance.persona)
|
||||
eq_(rqt.dupe_persona, theme.persona)
|
||||
|
||||
@mock.patch('addons.tasks.make_checksum', new=mock.Mock)
|
||||
@mock.patch('addons.tasks.create_persona_preview_images', new=mock.Mock)
|
||||
@mock.patch('addons.tasks.save_persona_image', new=mock.Mock)
|
||||
@mock.patch('olympia.addons.tasks.make_checksum', new=mock.Mock)
|
||||
@mock.patch('olympia.addons.tasks.create_persona_preview_images', new=mock.Mock)
|
||||
@mock.patch('olympia.addons.tasks.save_persona_image', new=mock.Mock)
|
||||
def test_reupload_legacy_header_only(self):
|
||||
"""
|
||||
STR the bug this test fixes:
|
||||
|
@ -663,9 +663,9 @@ class TestEditThemeForm(TestCase):
|
|||
eq_(rqt.header, 'pending_header.png')
|
||||
eq_(rqt.footer, 'Legacy-footer3H-Copy.jpg')
|
||||
|
||||
@mock.patch('addons.tasks.make_checksum')
|
||||
@mock.patch('addons.tasks.create_persona_preview_images')
|
||||
@mock.patch('addons.tasks.save_persona_image')
|
||||
@mock.patch('olympia.addons.tasks.make_checksum')
|
||||
@mock.patch('olympia.addons.tasks.create_persona_preview_images')
|
||||
@mock.patch('olympia.addons.tasks.save_persona_image')
|
||||
def test_reupload_no_footer(self, save_persona_image_mock,
|
||||
create_persona_preview_images_mock,
|
||||
make_checksum_mock):
|
||||
|
|
|
@ -132,13 +132,13 @@ class TestValidator(TestCase):
|
|||
def get_upload(self):
|
||||
return FileUpload.objects.get(pk=self.upload.pk)
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_pass_validation(self, _mock):
|
||||
_mock.return_value = '{"errors": 0}'
|
||||
tasks.validate(self.upload)
|
||||
assert self.get_upload().valid
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_fail_validation(self, _mock):
|
||||
_mock.return_value = '{"errors": 2}'
|
||||
tasks.validate(self.upload)
|
||||
|
@ -164,8 +164,8 @@ class TestValidator(TestCase):
|
|||
assert not self.upload.valid
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=False)
|
||||
@mock.patch('devhub.tasks.annotate_validation_results')
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.annotate_validation_results')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_annotation_error(self, run_validator, annotate):
|
||||
"""Test that an error that occurs during annotation is saved as an
|
||||
error result."""
|
||||
|
@ -186,7 +186,7 @@ class TestValidator(TestCase):
|
|||
|
||||
@override_settings(SIGNING_SERVER='http://full',
|
||||
PRELIMINARY_SIGNING_SERVER='http://prelim')
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_validation_signing_warning(self, _mock):
|
||||
"""If we sign addons, warn on signed addon submission."""
|
||||
_mock.return_value = self.mock_sign_addon_warning
|
||||
|
@ -196,7 +196,7 @@ class TestValidator(TestCase):
|
|||
assert len(validation['messages']) == 1
|
||||
|
||||
@override_settings(SIGNING_SERVER='', PRELIMINARY_SIGNING_SERVER='')
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_validation_no_signing_warning(self, _mock):
|
||||
"""If we're not signing addon don't warn on signed addon submission."""
|
||||
_mock.return_value = self.mock_sign_addon_warning
|
||||
|
@ -205,7 +205,7 @@ class TestValidator(TestCase):
|
|||
assert validation['warnings'] == 0
|
||||
assert len(validation['messages']) == 0
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_annotate_passed_auto_validation(self, _mock):
|
||||
"""Set passed_auto_validation on reception of the results."""
|
||||
result = {'signing_summary': {'trivial': 1, 'low': 0, 'medium': 0,
|
||||
|
@ -217,7 +217,7 @@ class TestValidator(TestCase):
|
|||
validation = json.loads(self.get_upload().validation)
|
||||
assert validation['passed_auto_validation']
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_annotate_failed_auto_validation(self, _mock):
|
||||
"""Set passed_auto_validation on reception of the results."""
|
||||
result = {'signing_summary': {'trivial': 0, 'low': 1, 'medium': 0,
|
||||
|
@ -229,7 +229,7 @@ class TestValidator(TestCase):
|
|||
validation = json.loads(self.get_upload().validation)
|
||||
assert not validation['passed_auto_validation']
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_annotate_passed_auto_validation_bogus_result(self, _mock):
|
||||
"""Don't set passed_auto_validation, don't fail if results is bogus."""
|
||||
_mock.return_value = '{"errors": 0}'
|
||||
|
@ -240,7 +240,7 @@ class TestValidator(TestCase):
|
|||
"low": 0, "trivial": 0}})
|
||||
|
||||
@mock.patch('validator.validate.validate')
|
||||
@mock.patch('devhub.tasks.track_validation_stats')
|
||||
@mock.patch('olympia.devhub.tasks.track_validation_stats')
|
||||
def test_track_validation_stats(self, mock_track, mock_validate):
|
||||
mock_validate.return_value = '{"errors": 0}'
|
||||
tasks.validate(self.upload)
|
||||
|
@ -251,7 +251,7 @@ class TestTrackValidatorStats(TestCase):
|
|||
|
||||
def setUp(self):
|
||||
super(TestTrackValidatorStats, self).setUp()
|
||||
patch = mock.patch('devhub.tasks.statsd.incr')
|
||||
patch = mock.patch('olympia.devhub.tasks.statsd.incr')
|
||||
self.mock_incr = patch.start()
|
||||
self.addCleanup(patch.stop)
|
||||
|
||||
|
@ -370,7 +370,7 @@ class TestFlagBinary(TestCase):
|
|||
super(TestFlagBinary, self).setUp()
|
||||
self.addon = Addon.objects.get(pk=3615)
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_flag_binary(self, _mock):
|
||||
_mock.return_value = ('{"metadata":{"contains_binary_extension": 1, '
|
||||
'"contains_binary_content": 0}}')
|
||||
|
@ -381,21 +381,21 @@ class TestFlagBinary(TestCase):
|
|||
tasks.flag_binary([self.addon.pk])
|
||||
eq_(Addon.objects.get(pk=self.addon.pk).binary, True)
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_flag_not_binary(self, _mock):
|
||||
_mock.return_value = ('{"metadata":{"contains_binary_extension": 0, '
|
||||
'"contains_binary_content": 0}}')
|
||||
tasks.flag_binary([self.addon.pk])
|
||||
eq_(Addon.objects.get(pk=self.addon.pk).binary, False)
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_flag_error(self, _mock):
|
||||
_mock.side_effect = RuntimeError()
|
||||
tasks.flag_binary([self.addon.pk])
|
||||
eq_(Addon.objects.get(pk=self.addon.pk).binary, False)
|
||||
|
||||
|
||||
@mock.patch('devhub.tasks.send_html_mail_jinja')
|
||||
@mock.patch('olympia.devhub.tasks.send_html_mail_jinja')
|
||||
def test_send_welcome_email(send_html_mail_jinja_mock):
|
||||
tasks.send_welcome_email(3615, ['del@icio.us'], {'omg': 'yes'})
|
||||
send_html_mail_jinja_mock.assert_called_with(
|
||||
|
@ -416,7 +416,7 @@ class TestSubmitFile(TestCase):
|
|||
def setUp(self):
|
||||
super(TestSubmitFile, self).setUp()
|
||||
self.addon = Addon.objects.get(pk=3615)
|
||||
patcher = mock.patch('devhub.tasks.create_version_for_upload')
|
||||
patcher = mock.patch('olympia.devhub.tasks.create_version_for_upload')
|
||||
self.create_version_for_upload = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
@ -425,13 +425,13 @@ class TestSubmitFile(TestCase):
|
|||
addon=self.addon, version=version, validation='{"errors":0}',
|
||||
automated_signing=self.addon.automated_signing)
|
||||
|
||||
@mock.patch('apps.devhub.tasks.FileUpload.passed_all_validations', True)
|
||||
@mock.patch('olympia.devhub.tasks.FileUpload.passed_all_validations', True)
|
||||
def test_file_passed_all_validations(self):
|
||||
upload = self.create_upload()
|
||||
tasks.submit_file(self.addon.pk, upload.pk)
|
||||
self.create_version_for_upload.assert_called_with(self.addon, upload)
|
||||
|
||||
@mock.patch('apps.devhub.tasks.FileUpload.passed_all_validations', False)
|
||||
@mock.patch('olympia.devhub.tasks.FileUpload.passed_all_validations', False)
|
||||
def test_file_not_passed_all_validations(self):
|
||||
upload = self.create_upload()
|
||||
tasks.submit_file(self.addon.pk, upload.pk)
|
||||
|
@ -446,7 +446,7 @@ class TestCreateVersionForUpload(TestCase):
|
|||
self.addon = Addon.objects.get(pk=3615)
|
||||
self.create_version_for_upload = (
|
||||
tasks.create_version_for_upload.non_atomic)
|
||||
patcher = mock.patch('devhub.tasks.Version.from_upload')
|
||||
patcher = mock.patch('olympia.devhub.tasks.Version.from_upload')
|
||||
self.version__from_upload = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
|
|
|
@ -644,7 +644,7 @@ class TestValidationAnnotatorListed(TestValidationAnnotatorBase):
|
|||
self.file.update(status=status)
|
||||
self.check_file(self.file_1_1, None)
|
||||
|
||||
@mock.patch('devhub.utils.chain')
|
||||
@mock.patch('olympia.devhub.utils.chain')
|
||||
def test_run_once_per_file(self, chain):
|
||||
"""Tests that only a single validation task is run for a given file."""
|
||||
task = mock.Mock()
|
||||
|
@ -660,7 +660,7 @@ class TestValidationAnnotatorListed(TestValidationAnnotatorBase):
|
|||
assert isinstance(tasks.validate(self.file_1_1), mock.Mock)
|
||||
assert task.delay.call_count == 2
|
||||
|
||||
@mock.patch('devhub.utils.chain')
|
||||
@mock.patch('olympia.devhub.utils.chain')
|
||||
def test_run_once_file_upload(self, chain):
|
||||
"""Tests that only a single validation task is run for a given file
|
||||
upload."""
|
||||
|
@ -685,7 +685,7 @@ class TestValidationAnnotatorListed(TestValidationAnnotatorBase):
|
|||
'validation-task:files.FileUpload:{0}:False'.format(
|
||||
self.file_upload.pk))
|
||||
|
||||
@mock.patch('devhub.utils.parse_addon')
|
||||
@mock.patch('olympia.devhub.utils.parse_addon')
|
||||
def test_search_plugin(self, parse_addon):
|
||||
"""Test that search plugins are handled correctly."""
|
||||
|
||||
|
@ -710,7 +710,7 @@ class TestValidationAnnotatorBeta(TestValidationAnnotatorBase):
|
|||
|
||||
self.xpi_version = '1.1b1'
|
||||
|
||||
parse_addon = self.patch('devhub.utils.parse_addon')
|
||||
parse_addon = self.patch('olympia.devhub.utils.parse_addon')
|
||||
parse_addon.return_value = {'version': self.xpi_version,
|
||||
'guid': self.addon.guid}
|
||||
|
||||
|
|
|
@ -1130,7 +1130,7 @@ class TestAPIAgreement(TestSubmitBase):
|
|||
self.create_switch('signing-api', db=True)
|
||||
|
||||
def test_agreement_first(self):
|
||||
with mock.patch('devhub.views.render_agreement') as mock_submit:
|
||||
with mock.patch('olympia.devhub.views.render_agreement') as mock_submit:
|
||||
mock_submit.return_value = http.HttpResponse("Okay")
|
||||
self.client.get(reverse('devhub.api_key_agreement'))
|
||||
assert mock_submit.called
|
||||
|
@ -1182,7 +1182,7 @@ class TestAPIKeyPage(TestCase):
|
|||
assert key_input == 'some-jwt-key'
|
||||
|
||||
def test_create_new_credentials(self):
|
||||
patch = mock.patch('devhub.views.APIKey.new_jwt_credentials')
|
||||
patch = mock.patch('olympia.devhub.views.APIKey.new_jwt_credentials')
|
||||
with patch as mock_creator:
|
||||
response = self.client.post(self.url)
|
||||
mock_creator.assert_called_with(self.user)
|
||||
|
@ -1750,7 +1750,7 @@ class TestSubmitStep7(TestSubmitBase):
|
|||
self.url = reverse('devhub.submit.7', args=[self.addon.slug])
|
||||
|
||||
@mock.patch.object(settings, 'SITE_URL', 'http://b.ro')
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay')
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay')
|
||||
def test_welcome_email_for_newbies(self, send_welcome_email_mock):
|
||||
self.client.get(self.url)
|
||||
context = {
|
||||
|
@ -1763,7 +1763,7 @@ class TestSubmitStep7(TestSubmitBase):
|
|||
send_welcome_email_mock.assert_called_with(
|
||||
self.addon.id, ['del@icio.us'], context)
|
||||
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay')
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay')
|
||||
def test_no_welcome_email(self, send_welcome_email_mock):
|
||||
"""You already submitted an add-on? We won't spam again."""
|
||||
new_addon = Addon.objects.create(type=amo.ADDON_EXTENSION,
|
||||
|
@ -1772,7 +1772,7 @@ class TestSubmitStep7(TestSubmitBase):
|
|||
self.client.get(self.url)
|
||||
assert not send_welcome_email_mock.called
|
||||
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
def test_finish_submitting_addon(self):
|
||||
eq_(self.addon.current_version.supported_platforms, [amo.PLATFORM_ALL])
|
||||
|
||||
|
@ -1793,7 +1793,7 @@ class TestSubmitStep7(TestSubmitBase):
|
|||
# edit your developer profile...
|
||||
eq_(next_steps.eq(1).attr('href'), self.addon.get_dev_url('profile'))
|
||||
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
def test_finish_submitting_unlisted_addon(self):
|
||||
self.addon.update(is_listed=False, status=amo.STATUS_UNREVIEWED)
|
||||
|
||||
|
@ -1807,7 +1807,7 @@ class TestSubmitStep7(TestSubmitBase):
|
|||
assert len(content('a')) == 2
|
||||
assert content('a').eq(0).attr('href') == self.addon.get_dev_url()
|
||||
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
def test_finish_submitting_unlisted_addon_signed(self):
|
||||
self.addon.update(is_listed=False, status=amo.STATUS_PUBLIC)
|
||||
|
||||
|
@ -1825,7 +1825,7 @@ class TestSubmitStep7(TestSubmitBase):
|
|||
args=[self.addon.slug, self.addon.current_version.id])
|
||||
assert links[1].attrib['href'] == self.addon.get_dev_url()
|
||||
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
def test_finish_submitting_platform_specific_addon(self):
|
||||
# mac-only Add-on:
|
||||
addon = Addon.objects.get(name__localized_string='Cooliris')
|
||||
|
@ -1843,7 +1843,7 @@ class TestSubmitStep7(TestSubmitBase):
|
|||
# edit listing of freshly submitted add-on...
|
||||
eq_(next_steps.eq(1).attr('href'), addon.get_dev_url())
|
||||
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
def test_finish_addon_for_prelim_review(self):
|
||||
self.addon.update(status=amo.STATUS_UNREVIEWED)
|
||||
|
||||
|
@ -1853,7 +1853,7 @@ class TestSubmitStep7(TestSubmitBase):
|
|||
intro = doc('.addon-submission-process p').text().strip()
|
||||
assert 'Preliminary Review' in intro, ('Unexpected intro: %s' % intro)
|
||||
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
def test_finish_addon_for_full_review(self):
|
||||
self.addon.update(status=amo.STATUS_NOMINATED)
|
||||
|
||||
|
@ -1863,21 +1863,21 @@ class TestSubmitStep7(TestSubmitBase):
|
|||
intro = doc('.addon-submission-process p').text().strip()
|
||||
assert 'Full Review' in intro, ('Unexpected intro: %s' % intro)
|
||||
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
def test_incomplete_addon_no_versions(self):
|
||||
self.addon.update(status=amo.STATUS_NULL)
|
||||
self.addon.versions.all().delete()
|
||||
r = self.client.get(self.url, follow=True)
|
||||
self.assert3xx(r, self.addon.get_dev_url('versions'), 302)
|
||||
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
def test_link_to_activityfeed(self):
|
||||
r = self.client.get(self.url, follow=True)
|
||||
doc = pq(r.content)
|
||||
eq_(doc('.done-next-steps a').eq(2).attr('href'),
|
||||
reverse('devhub.feed', args=[self.addon.slug]))
|
||||
|
||||
@mock.patch('devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
@mock.patch('olympia.devhub.tasks.send_welcome_email.delay', new=mock.Mock)
|
||||
def test_display_non_ascii_url(self):
|
||||
u = 'フォクすけといっしょ'
|
||||
self.addon.update(slug=u)
|
||||
|
@ -2172,7 +2172,7 @@ class TestUploadDetail(BaseUploadTest):
|
|||
eq_(suite.attr('data-validateurl'),
|
||||
reverse('devhub.standalone_upload_detail', args=[upload.uuid]))
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def check_excluded_platforms(self, xpi, platforms, v):
|
||||
v.return_value = json.dumps(self.validation_ok())
|
||||
self.upload_file(xpi)
|
||||
|
@ -2203,7 +2203,7 @@ class TestUploadDetail(BaseUploadTest):
|
|||
self.check_excluded_platforms('desktop.xpi', [
|
||||
str(p) for p in amo.MOBILE_PLATFORMS])
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
@mock.patch.object(waffle, 'flag_is_active')
|
||||
def test_unparsable_xpi(self, flag_is_active, v):
|
||||
flag_is_active.return_value = True
|
||||
|
@ -2217,7 +2217,7 @@ class TestUploadDetail(BaseUploadTest):
|
|||
for m in data['validation']['messages']],
|
||||
[(u'Could not parse install.rdf.', True)])
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_experiment_xpi_allowed(self, mock_validator):
|
||||
user = UserProfile.objects.get(email='regular@mozilla.com')
|
||||
self.grant_permission(user, 'Experiments:submit')
|
||||
|
@ -2229,7 +2229,7 @@ class TestUploadDetail(BaseUploadTest):
|
|||
data = json.loads(response.content)
|
||||
assert data['validation']['messages'] == []
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_experiment_xpi_not_allowed(self, mock_validator):
|
||||
mock_validator.return_value = json.dumps(self.validation_ok())
|
||||
self.upload_file('../../../files/fixtures/files/experiment.xpi')
|
||||
|
@ -2473,7 +2473,7 @@ class TestVersionAddFile(UploadTest):
|
|||
'There was an error with your upload. Please try '
|
||||
'again.')
|
||||
|
||||
@mock.patch('versions.models.Version.is_allowed_upload')
|
||||
@mock.patch('olympia.versions.models.Version.is_allowed_upload')
|
||||
def test_cant_upload(self, allowed):
|
||||
"""Test that if is_allowed_upload fails, the upload will fail."""
|
||||
allowed.return_value = False
|
||||
|
@ -2560,7 +2560,7 @@ class TestVersionAddFile(UploadTest):
|
|||
eq_(response.status_code, 400)
|
||||
assert 'source' in json.loads(response.content)
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_unlisted_addon_sideload_fail_validation(self, mock_sign_file):
|
||||
"""Sideloadable unlisted addons are also auto signed/reviewed."""
|
||||
assert self.addon.status == amo.STATUS_PUBLIC # Fully reviewed.
|
||||
|
@ -2584,7 +2584,7 @@ class TestVersionAddFile(UploadTest):
|
|||
expected = amo.LOG.UNLISTED_SIDELOAD_SIGNED_VALIDATION_FAILED.id
|
||||
assert log.action == expected
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_unlisted_addon_sideload_pass_validation(self, mock_sign_file):
|
||||
"""Sideloadable unlisted addons are also auto signed/reviewed."""
|
||||
assert self.addon.status == amo.STATUS_PUBLIC # Fully reviewed.
|
||||
|
@ -2608,7 +2608,7 @@ class TestVersionAddFile(UploadTest):
|
|||
expected = amo.LOG.UNLISTED_SIDELOAD_SIGNED_VALIDATION_PASSED.id
|
||||
assert log.action == expected
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_unlisted_addon_fail_validation(self, mock_sign_file):
|
||||
"""Files that fail validation are also auto signed/reviewed."""
|
||||
self.addon.update(
|
||||
|
@ -2632,7 +2632,7 @@ class TestVersionAddFile(UploadTest):
|
|||
log = ActivityLog.objects.order_by('pk').last()
|
||||
assert log.action == amo.LOG.UNLISTED_SIGNED_VALIDATION_FAILED.id
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_unlisted_addon_pass_validation(self, mock_sign_file):
|
||||
"""Files that pass validation are automatically signed/reviewed."""
|
||||
self.addon.update(
|
||||
|
@ -2656,7 +2656,7 @@ class TestVersionAddFile(UploadTest):
|
|||
log = ActivityLog.objects.order_by('pk').last()
|
||||
assert log.action == amo.LOG.UNLISTED_SIGNED_VALIDATION_PASSED.id
|
||||
|
||||
@mock.patch('devhub.views.sign_file')
|
||||
@mock.patch('olympia.devhub.views.sign_file')
|
||||
def test_beta_addon_pass_validation(self, mock_sign_file):
|
||||
"""Beta files that pass validation are automatically
|
||||
signed/reviewed."""
|
||||
|
@ -2695,8 +2695,8 @@ class TestUploadErrors(UploadTest):
|
|||
'rb')
|
||||
|
||||
@mock.patch.object(waffle, 'flag_is_active', return_value=True)
|
||||
@mock.patch('devhub.tasks.validate')
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.validate')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_version_upload(self, run_validator, validate_, flag_is_active):
|
||||
# Load the versions page:
|
||||
res = self.client.get(self.addon.get_dev_url('versions'))
|
||||
|
@ -2730,8 +2730,8 @@ class TestUploadErrors(UploadTest):
|
|||
'Unexpected validation errors: %s' % data['validation']['messages']
|
||||
|
||||
@mock.patch.object(waffle, 'flag_is_active', return_value=True)
|
||||
@mock.patch('devhub.tasks.validate')
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.validate')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_dupe_xpi(self, run_validator, validate_, flag_is_active):
|
||||
# Submit a new addon:
|
||||
self.client.post(reverse('devhub.submit.1')) # set cookie
|
||||
|
@ -2840,7 +2840,7 @@ class TestAddVersion(AddVersionTest):
|
|||
version = self.addon.versions.get(version='0.1')
|
||||
eq_(len(version.all_files), 2)
|
||||
|
||||
@mock.patch('devhub.views.auto_sign_file')
|
||||
@mock.patch('olympia.devhub.views.auto_sign_file')
|
||||
def test_multiple_platforms_unlisted_addon(self, mock_auto_sign_file):
|
||||
self.addon.update(is_listed=False)
|
||||
r = self.post(supported_platforms=[amo.PLATFORM_MAC,
|
||||
|
@ -2881,7 +2881,7 @@ class TestAddVersion(AddVersionTest):
|
|||
f = File.objects.latest()
|
||||
assert f.status != amo.STATUS_BETA
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_unlisted_addon_sideload_fail_validation(self, mock_sign_file):
|
||||
"""Sideloadable unlisted addons also get auto signed/reviewed."""
|
||||
assert self.addon.status == amo.STATUS_PUBLIC # Fully reviewed.
|
||||
|
@ -2906,7 +2906,7 @@ class TestAddVersion(AddVersionTest):
|
|||
expected = amo.LOG.UNLISTED_SIDELOAD_SIGNED_VALIDATION_FAILED.id
|
||||
assert log.action == expected
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_unlisted_addon_sideload_pass_validation(self, mock_sign_file):
|
||||
"""Sideloadable unlisted addons also get auto signed/reviewed."""
|
||||
assert self.addon.status == amo.STATUS_PUBLIC # Fully reviewed.
|
||||
|
@ -2931,7 +2931,7 @@ class TestAddVersion(AddVersionTest):
|
|||
expected = amo.LOG.UNLISTED_SIDELOAD_SIGNED_VALIDATION_PASSED.id
|
||||
assert log.action == expected
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_unlisted_addon_fail_validation(self, mock_sign_file):
|
||||
"""Files that fail validation are also auto signed/reviewed."""
|
||||
self.addon.update(
|
||||
|
@ -2956,7 +2956,7 @@ class TestAddVersion(AddVersionTest):
|
|||
log = ActivityLog.objects.order_by('pk').last()
|
||||
assert log.action == amo.LOG.UNLISTED_SIGNED_VALIDATION_FAILED.id
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_unlisted_addon_pass_validation(self, mock_sign_file):
|
||||
"""Files that pass validation are automatically signed/reviewed."""
|
||||
self.addon.update(
|
||||
|
@ -2981,7 +2981,7 @@ class TestAddVersion(AddVersionTest):
|
|||
log = ActivityLog.objects.order_by('pk').last()
|
||||
assert log.action == amo.LOG.UNLISTED_SIGNED_VALIDATION_PASSED.id
|
||||
|
||||
@mock.patch('devhub.views.sign_file')
|
||||
@mock.patch('olympia.devhub.views.sign_file')
|
||||
def test_experiments_are_auto_signed(self, mock_sign_file):
|
||||
"""Experiment extensions (bug 1220097) are auto-signed."""
|
||||
# We're going to sign even if it has signing related errors/warnings.
|
||||
|
@ -3045,7 +3045,7 @@ class TestAddBetaVersion(AddVersionTest):
|
|||
f = File.objects.latest()
|
||||
assert f.status == amo.STATUS_PUBLIC
|
||||
|
||||
@mock.patch('devhub.views.sign_file')
|
||||
@mock.patch('olympia.devhub.views.sign_file')
|
||||
def test_listed_beta_pass_validation(self, mock_sign_file):
|
||||
"""Beta files that pass validation are signed with prelim cert."""
|
||||
self.addon.update(
|
||||
|
@ -3067,7 +3067,7 @@ class TestAddBetaVersion(AddVersionTest):
|
|||
log = ActivityLog.objects.beta_signed_events().get()
|
||||
assert log.action == amo.LOG.BETA_SIGNED_VALIDATION_PASSED.id
|
||||
|
||||
@mock.patch('devhub.views.sign_file')
|
||||
@mock.patch('olympia.devhub.views.sign_file')
|
||||
def test_listed_beta_do_not_pass_validation(self, mock_sign_file):
|
||||
"""Beta files that don't pass validation should be logged."""
|
||||
self.addon.update(is_listed=True, status=amo.STATUS_PUBLIC)
|
||||
|
@ -3233,7 +3233,7 @@ class TestCreateAddon(BaseUploadTest, UploadAddon, TestCase):
|
|||
assert log_items.filter(action=amo.LOG.CREATE_ADDON.id), (
|
||||
'New add-on creation never logged.')
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_success_unlisted(self, mock_sign_file):
|
||||
"""Sign automatically."""
|
||||
assert Addon.with_unlisted.count() == 0
|
||||
|
@ -3253,7 +3253,7 @@ class TestCreateAddon(BaseUploadTest, UploadAddon, TestCase):
|
|||
assert addon.status == amo.STATUS_LITE # Automatic signing.
|
||||
assert mock_sign_file.called
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_success_unlisted_fail_validation(self, mock_sign_file):
|
||||
assert Addon.with_unlisted.count() == 0
|
||||
self.upload = self.get_upload(
|
||||
|
@ -3271,7 +3271,7 @@ class TestCreateAddon(BaseUploadTest, UploadAddon, TestCase):
|
|||
assert addon.status == amo.STATUS_LITE # Prelim review.
|
||||
assert mock_sign_file.called
|
||||
|
||||
@mock.patch('editors.helpers.sign_file')
|
||||
@mock.patch('olympia.editors.helpers.sign_file')
|
||||
def test_success_unlisted_sideload(self, mock_sign_file):
|
||||
assert Addon.with_unlisted.count() == 0
|
||||
self.post(is_listed=False, is_sideload=True)
|
||||
|
@ -3299,7 +3299,7 @@ class TestCreateAddon(BaseUploadTest, UploadAddon, TestCase):
|
|||
eq_(sorted([f.filename for f in addon.current_version.all_files]),
|
||||
[u'xpi_name-0.1-linux.xpi', u'xpi_name-0.1-mac.xpi'])
|
||||
|
||||
@mock.patch('devhub.views.auto_sign_file')
|
||||
@mock.patch('olympia.devhub.views.auto_sign_file')
|
||||
def test_one_xpi_for_multiple_platforms_unlisted_addon(
|
||||
self, mock_auto_sign_file):
|
||||
eq_(Addon.objects.count(), 0)
|
||||
|
|
|
@ -1274,7 +1274,7 @@ class TestThemeEdit(TestCase):
|
|||
self.user = UserProfile.objects.get()
|
||||
self.addon.addonuser_set.create(user=self.user)
|
||||
|
||||
@mock.patch('amo.messages.error')
|
||||
@mock.patch('olympia.amo.messages.error')
|
||||
def test_desc_too_long_error(self, message_mock):
|
||||
data = {'description': 'a' * 501}
|
||||
req = req_factory_factory(
|
||||
|
|
|
@ -179,7 +179,7 @@ class TestFileValidation(TestCase):
|
|||
eq_(msg['context'],
|
||||
[u'<em:description>...', u'<foo/>'])
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_json_results_post_not_cached(self, validate):
|
||||
validate.return_value = json.dumps(amo.VALIDATOR_SKELETON_RESULTS)
|
||||
|
||||
|
@ -191,7 +191,7 @@ class TestFileValidation(TestCase):
|
|||
assert self.client.post(self.json_url).status_code == 200
|
||||
assert validate.called
|
||||
|
||||
@mock.patch('devhub.tasks.validate')
|
||||
@mock.patch('olympia.devhub.tasks.validate')
|
||||
def test_json_results_post_cached(self, validate):
|
||||
assert self.file.has_been_validated
|
||||
|
||||
|
@ -381,10 +381,10 @@ class TestUploadURLs(TestCase):
|
|||
status=amo.STATUS_PUBLIC)
|
||||
AddonUser.objects.create(addon=self.addon, user=user)
|
||||
|
||||
self.run_validator = self.patch('devhub.tasks.run_validator')
|
||||
self.run_validator = self.patch('olympia.devhub.tasks.run_validator')
|
||||
self.run_validator.return_value = json.dumps(
|
||||
amo.VALIDATOR_SKELETON_RESULTS)
|
||||
self.parse_addon = self.patch('devhub.utils.parse_addon')
|
||||
self.parse_addon = self.patch('olympia.devhub.utils.parse_addon')
|
||||
self.parse_addon.return_value = {'guid': self.addon.guid,
|
||||
'version': '1.0'}
|
||||
|
||||
|
@ -491,7 +491,7 @@ class TestValidateFile(BaseUploadTest):
|
|||
doc = pq(r.content)
|
||||
assert doc('time').text()
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_validator_sets_binary_flag_for_extensions(self, v):
|
||||
v.return_value = json.dumps({
|
||||
"errors": 0,
|
||||
|
@ -517,7 +517,7 @@ class TestValidateFile(BaseUploadTest):
|
|||
addon = Addon.objects.get(pk=self.addon.id)
|
||||
assert addon.binary
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_ending_tier_is_preserved(self, v):
|
||||
v.return_value = json.dumps({
|
||||
"errors": 0,
|
||||
|
@ -542,7 +542,7 @@ class TestValidateFile(BaseUploadTest):
|
|||
assert not data['validation']['errors']
|
||||
assert data['validation']['ending_tier'] == 5
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_validator_sets_binary_flag_for_content(self, v):
|
||||
v.return_value = json.dumps({
|
||||
"errors": 0,
|
||||
|
@ -568,7 +568,7 @@ class TestValidateFile(BaseUploadTest):
|
|||
addon = Addon.objects.get(pk=self.addon.id)
|
||||
assert addon.binary
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_linkify_validation_messages(self, v):
|
||||
v.return_value = json.dumps({
|
||||
"errors": 0,
|
||||
|
@ -600,7 +600,7 @@ class TestValidateFile(BaseUploadTest):
|
|||
eq_(doc('a').text(), 'https://bugzilla.mozilla.org/')
|
||||
|
||||
@mock.patch.object(waffle, 'flag_is_active')
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_rdf_parse_errors_are_ignored(self, run_validator,
|
||||
flag_is_active):
|
||||
run_validator.return_value = json.dumps({
|
||||
|
@ -637,7 +637,7 @@ class TestValidateFile(BaseUploadTest):
|
|||
# Again, make sure we don't see a dupe UUID error:
|
||||
eq_(data['validation']['messages'], [])
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_compatibility_check(self, run_validator):
|
||||
run_validator.return_value = json.dumps({
|
||||
'errors': 0,
|
||||
|
@ -786,7 +786,7 @@ class TestUploadCompatCheck(BaseUploadTest):
|
|||
eq_(doc('#upload-addon').attr('data-upload-url'), self.upload_url)
|
||||
# TODO(Kumar) actually check the form here after bug 671587
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_js_upload_validates_compatibility(self, run_validator):
|
||||
run_validator.return_value = '' # Empty to simulate unfinished task.
|
||||
data = self.upload()
|
||||
|
@ -797,7 +797,7 @@ class TestUploadCompatCheck(BaseUploadTest):
|
|||
'targetapp_maxVersion': {self.app.guid: self.appver.version}})
|
||||
eq_(data['url'], self.poll_upload_status_url(data['upload']))
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_js_poll_upload_status(self, run_validator):
|
||||
run_validator.return_value = self.compatibility_result
|
||||
data = self.upload()
|
||||
|
@ -808,7 +808,7 @@ class TestUploadCompatCheck(BaseUploadTest):
|
|||
raise AssertionError('Unexpected validation errors: %s'
|
||||
% data['validation']['messages'])
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_compat_result_report(self, run_validator):
|
||||
run_validator.return_value = self.compatibility_result
|
||||
data = self.upload()
|
||||
|
@ -841,7 +841,7 @@ class TestUploadCompatCheck(BaseUploadTest):
|
|||
assert not empty, "Unexpected: %r" % data
|
||||
|
||||
@mock.patch.object(waffle, 'flag_is_active')
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_rdf_parse_errors_are_ignored(self, run_validator,
|
||||
flag_is_active):
|
||||
run_validator.return_value = self.compatibility_result
|
||||
|
@ -855,7 +855,7 @@ class TestUploadCompatCheck(BaseUploadTest):
|
|||
# Make sure we don't see a dupe UUID error:
|
||||
eq_(data['validation']['messages'], [])
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_compat_summary_overrides(self, run_validator):
|
||||
run_validator.return_value = json.dumps({
|
||||
"success": True,
|
||||
|
@ -879,7 +879,7 @@ class TestUploadCompatCheck(BaseUploadTest):
|
|||
eq_(data['validation']['errors'], 2)
|
||||
eq_(data['validation']['warnings'], 3)
|
||||
|
||||
@mock.patch('devhub.tasks.run_validator')
|
||||
@mock.patch('olympia.devhub.tasks.run_validator')
|
||||
def test_compat_error_type_override(self, run_validator):
|
||||
run_validator.return_value = json.dumps({
|
||||
"success": True,
|
||||
|
|
|
@ -166,7 +166,7 @@ class TestVersion(TestCase):
|
|||
eq_(self.addon.versions.count(), 1)
|
||||
eq_(Addon.objects.get(id=3615).status, amo.STATUS_UNREVIEWED)
|
||||
|
||||
@mock.patch('files.models.File.hide_disabled_file')
|
||||
@mock.patch('olympia.files.models.File.hide_disabled_file')
|
||||
def test_user_can_disable_addon(self, hide_mock):
|
||||
self.addon.update(status=amo.STATUS_PUBLIC,
|
||||
disabled_by_user=False)
|
||||
|
@ -182,7 +182,7 @@ class TestVersion(TestCase):
|
|||
msg = entry.to_string()
|
||||
assert self.addon.name.__unicode__() in msg, ("Unexpected: %r" % msg)
|
||||
|
||||
@mock.patch('devhub.views.unindex_addons')
|
||||
@mock.patch('olympia.devhub.views.unindex_addons')
|
||||
def test_user_can_unlist_addon(self, unindex):
|
||||
self.addon.update(status=amo.STATUS_PUBLIC, disabled_by_user=False,
|
||||
is_listed=True)
|
||||
|
@ -200,7 +200,7 @@ class TestVersion(TestCase):
|
|||
msg = entry.to_string()
|
||||
assert self.addon.name.__unicode__() in msg
|
||||
|
||||
@mock.patch('devhub.views.unindex_addons')
|
||||
@mock.patch('olympia.devhub.views.unindex_addons')
|
||||
def test_user_can_unlist_hidden_addon(self, unindex):
|
||||
self.addon.update(status=amo.STATUS_PUBLIC, disabled_by_user=True,
|
||||
is_listed=True)
|
||||
|
@ -612,7 +612,7 @@ class TestVersionEditSearchEngine(TestVersionEditMixin,
|
|||
doc = pq(r.content)
|
||||
assert not doc('a.add-file')
|
||||
|
||||
@mock.patch('versions.models.Version.is_allowed_upload')
|
||||
@mock.patch('olympia.versions.models.Version.is_allowed_upload')
|
||||
def test_can_upload(self, allowed):
|
||||
allowed.return_value = True
|
||||
res = self.client.get(self.url)
|
||||
|
|
|
@ -66,7 +66,7 @@ class TestReviewActions(TestCase):
|
|||
# so the length of the actions is one shorter
|
||||
eq_(len(self.set_status(amo.STATUS_UNREVIEWED)), 5)
|
||||
|
||||
@mock.patch('access.acl.action_allowed')
|
||||
@mock.patch('olympia.access.acl.action_allowed')
|
||||
def test_admin_flagged_addon_actions(self, action_allowed_mock):
|
||||
self.addon.update(admin_review=True)
|
||||
# Test with an admin editor.
|
||||
|
|
|
@ -419,7 +419,7 @@ class TestReviewHelper(TestCase):
|
|||
|
||||
self._check_score(amo.REVIEWED_ADDON_FULL)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_nomination_to_public(self, sign_mock):
|
||||
for status in helpers.NOMINATED_STATUSES:
|
||||
sign_mock.reset()
|
||||
|
@ -444,7 +444,7 @@ class TestReviewHelper(TestCase):
|
|||
|
||||
self._check_score(amo.REVIEWED_ADDON_FULL)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_nomination_to_public_unlisted(self, sign_mock):
|
||||
for status in helpers.NOMINATED_STATUSES:
|
||||
sign_mock.reset()
|
||||
|
@ -469,7 +469,7 @@ class TestReviewHelper(TestCase):
|
|||
|
||||
self._check_score(amo.REVIEWED_ADDON_FULL)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_nomination_to_public_failed_signing(self, sign_mock):
|
||||
sign_mock.side_effect = Exception
|
||||
for status in helpers.NOMINATED_STATUSES:
|
||||
|
@ -486,7 +486,7 @@ class TestReviewHelper(TestCase):
|
|||
assert len(mail.outbox) == 0
|
||||
assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 0
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_nomination_to_preliminary(self, sign_mock):
|
||||
for status in helpers.NOMINATED_STATUSES:
|
||||
sign_mock.reset()
|
||||
|
@ -512,7 +512,7 @@ class TestReviewHelper(TestCase):
|
|||
|
||||
self._check_score(amo.REVIEWED_ADDON_FULL)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_nomination_to_preliminary_unlisted(self, sign_mock):
|
||||
for status in helpers.NOMINATED_STATUSES:
|
||||
sign_mock.reset()
|
||||
|
@ -538,7 +538,7 @@ class TestReviewHelper(TestCase):
|
|||
|
||||
self._check_score(amo.REVIEWED_ADDON_FULL)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_nomination_to_preliminary_unlisted_auto(self, sign_mock):
|
||||
for status in helpers.NOMINATED_STATUSES:
|
||||
sign_mock.reset()
|
||||
|
@ -564,7 +564,7 @@ class TestReviewHelper(TestCase):
|
|||
|
||||
assert not ReviewerScore.objects.all()
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_nomination_to_preliminary_failed_signing(self, sign_mock):
|
||||
sign_mock.side_effect = Exception
|
||||
for status in helpers.NOMINATED_STATUSES:
|
||||
|
@ -580,7 +580,7 @@ class TestReviewHelper(TestCase):
|
|||
assert len(mail.outbox) == 0
|
||||
assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 0
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_nomination_to_sandbox(self, sign_mock):
|
||||
for status in helpers.NOMINATED_STATUSES:
|
||||
self.setup_data(status)
|
||||
|
@ -599,7 +599,7 @@ class TestReviewHelper(TestCase):
|
|||
assert not storage.exists(self.file.mirror_file_path)
|
||||
assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 1
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_nomination_to_sandbox_unlisted(self, sign_mock):
|
||||
for status in helpers.NOMINATED_STATUSES:
|
||||
self.setup_data(status, is_listed=False)
|
||||
|
@ -657,7 +657,7 @@ class TestReviewHelper(TestCase):
|
|||
self.assertRaises(AssertionError,
|
||||
self.helper.handler.process_public)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_preliminary_to_preliminary(self, sign_mock):
|
||||
for status in helpers.PRELIMINARY_STATUSES:
|
||||
self.setup_data(status)
|
||||
|
@ -677,7 +677,7 @@ class TestReviewHelper(TestCase):
|
|||
|
||||
self._check_score(amo.REVIEWED_ADDON_PRELIM)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_preliminary_to_preliminary_unlisted(self, sign_mock):
|
||||
for status in helpers.PRELIMINARY_STATUSES:
|
||||
self.setup_data(status, is_listed=False)
|
||||
|
@ -697,7 +697,7 @@ class TestReviewHelper(TestCase):
|
|||
|
||||
self._check_score(amo.REVIEWED_ADDON_PRELIM)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_preliminary_to_preliminary_unlisted_auto(self, sign_mock):
|
||||
for status in helpers.PRELIMINARY_STATUSES:
|
||||
self.setup_data(status, is_listed=False)
|
||||
|
@ -717,7 +717,7 @@ class TestReviewHelper(TestCase):
|
|||
|
||||
assert not ReviewerScore.objects.all()
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_preliminary_to_sandbox(self, sign_mock):
|
||||
for status in [amo.STATUS_UNREVIEWED, amo.STATUS_LITE_AND_NOMINATED]:
|
||||
self.setup_data(status)
|
||||
|
@ -734,7 +734,7 @@ class TestReviewHelper(TestCase):
|
|||
assert not storage.exists(self.file.mirror_file_path)
|
||||
assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 1
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_preliminary_to_sandbox_unlisted(self, sign_mock):
|
||||
for status in [amo.STATUS_UNREVIEWED, amo.STATUS_LITE_AND_NOMINATED]:
|
||||
self.setup_data(status, is_listed=False)
|
||||
|
@ -804,7 +804,7 @@ class TestReviewHelper(TestCase):
|
|||
|
||||
eq_(self.check_log_count(amo.LOG.REQUEST_SUPER_REVIEW.id), 1)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_pending_to_public(self, sign_mock):
|
||||
for status in [amo.STATUS_NOMINATED, amo.STATUS_LITE_AND_NOMINATED]:
|
||||
self.setup_data(status)
|
||||
|
@ -826,7 +826,7 @@ class TestReviewHelper(TestCase):
|
|||
if status == amo.STATUS_PUBLIC:
|
||||
self._check_score(amo.REVIEWED_ADDON_UPDATE)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_pending_to_public_unlisted(self, sign_mock):
|
||||
for status in [amo.STATUS_NOMINATED, amo.STATUS_LITE_AND_NOMINATED]:
|
||||
self.setup_data(status, is_listed=False)
|
||||
|
@ -848,7 +848,7 @@ class TestReviewHelper(TestCase):
|
|||
if status == amo.STATUS_PUBLIC:
|
||||
self._check_score(amo.REVIEWED_ADDON_UPDATE)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_pending_to_sandbox(self, sign_mock):
|
||||
for status in amo.UNDER_REVIEW_STATUSES:
|
||||
self.setup_data(status)
|
||||
|
@ -865,7 +865,7 @@ class TestReviewHelper(TestCase):
|
|||
assert not storage.exists(self.file.mirror_file_path)
|
||||
assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 1
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_pending_to_sandbox_unlisted(self, sign_mock):
|
||||
for status in amo.UNDER_REVIEW_STATUSES:
|
||||
self.setup_data(status, is_listed=False)
|
||||
|
|
|
@ -349,7 +349,7 @@ class TestReviewLog(EditorTest):
|
|||
def test_breadcrumbs(self):
|
||||
self._test_breadcrumbs([('Add-on Review Log', None)])
|
||||
|
||||
@patch('devhub.models.ActivityLog.arguments', new=Mock)
|
||||
@patch('olympoia.devhub.models.ActivityLog.arguments', new=Mock)
|
||||
def test_addon_missing(self):
|
||||
self.make_approvals()
|
||||
r = self.client.get(self.url)
|
||||
|
@ -2047,7 +2047,7 @@ class TestReview(ReviewBase):
|
|||
self.client.post(self.url, data)
|
||||
v.delete()
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_item_history_deleted(self, mock_sign):
|
||||
self.generate_deleted_versions()
|
||||
|
||||
|
@ -2313,7 +2313,7 @@ class TestReview(ReviewBase):
|
|||
eq_(ths.length, 2)
|
||||
assert '0.1' in ths.text()
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def review_version(self, version, url, mock_sign):
|
||||
version.files.all()[0].update(status=amo.STATUS_UNREVIEWED)
|
||||
data = dict(action='prelim', operating_systems='win',
|
||||
|
@ -2468,7 +2468,7 @@ class TestReview(ReviewBase):
|
|||
response = self.client.get(url, follow=True)
|
||||
assert 'The developer has provided source code.' in response.content
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_admin_flagged_addon_actions_as_admin(self, mock_sign_file):
|
||||
self.addon.update(admin_review=True, status=amo.STATUS_NOMINATED)
|
||||
self.login_as_admin()
|
||||
|
@ -2524,7 +2524,7 @@ class TestReview(ReviewBase):
|
|||
assert '(Owner) removed from ' in user_changes[2].text
|
||||
|
||||
@override_settings(CELERY_ALWAYS_EAGER=True)
|
||||
@mock.patch('devhub.tasks.validate')
|
||||
@mock.patch('olympia.devhub.tasks.validate')
|
||||
def test_validation_not_run_eagerly(self, validate):
|
||||
"""Tests that validation is not run in eager mode."""
|
||||
assert not self.file.has_been_validated
|
||||
|
@ -2534,7 +2534,7 @@ class TestReview(ReviewBase):
|
|||
assert not validate.called
|
||||
|
||||
@override_settings(CELERY_ALWAYS_EAGER=False)
|
||||
@mock.patch('devhub.tasks.validate')
|
||||
@mock.patch('olympia.devhub.tasks.validate')
|
||||
def test_validation_run(self, validate):
|
||||
"""Tests that validation is run if necessary."""
|
||||
assert not self.file.has_been_validated
|
||||
|
@ -2544,7 +2544,7 @@ class TestReview(ReviewBase):
|
|||
validate.assert_called_once_with(self.file)
|
||||
|
||||
@override_settings(CELERY_ALWAYS_EAGER=False)
|
||||
@mock.patch('devhub.tasks.validate')
|
||||
@mock.patch('olympia.devhub.tasks.validate')
|
||||
def test_validation_not_run_again(self, validate):
|
||||
"""Tests that validation is not run for files which have cached
|
||||
results."""
|
||||
|
@ -2567,7 +2567,7 @@ class TestReviewPreliminary(ReviewBase):
|
|||
eq_(response.context['form'].errors['comments'][0],
|
||||
'This field is required.')
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_prelim_from_lite(self, mock_sign):
|
||||
self.addon.update(status=amo.STATUS_LITE)
|
||||
self.version.files.all()[0].update(status=amo.STATUS_UNREVIEWED)
|
||||
|
@ -2588,7 +2588,7 @@ class TestReviewPreliminary(ReviewBase):
|
|||
self.client.post(self.url, self.prelim_dict())
|
||||
eq_(self.get_addon().status, amo.STATUS_LITE)
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_prelim_from_unreviewed(self, mock_sign):
|
||||
self.addon.update(status=amo.STATUS_UNREVIEWED)
|
||||
response = self.client.post(self.url, self.prelim_dict())
|
||||
|
@ -2620,7 +2620,7 @@ class TestReviewPending(ReviewBase):
|
|||
def pending_dict(self):
|
||||
return self.get_dict(action='public')
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_pending_to_public(self, mock_sign):
|
||||
statuses = (self.version.files.values_list('status', flat=True)
|
||||
.order_by('status'))
|
||||
|
@ -2636,7 +2636,7 @@ class TestReviewPending(ReviewBase):
|
|||
|
||||
assert mock_sign.called
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_pending_to_public_unlisted_addon(self, mock_sign):
|
||||
self.addon.update(is_listed=False)
|
||||
statuses = (self.version.files.values_list('status', flat=True)
|
||||
|
@ -2674,7 +2674,7 @@ class TestReviewPending(ReviewBase):
|
|||
assert unreviewed.filename in response.content
|
||||
assert self.file.filename in response.content
|
||||
|
||||
@patch('editors.helpers.sign_file')
|
||||
@patch('olympia.editors.helpers.sign_file')
|
||||
def test_review_unreviewed_files(self, mock_sign):
|
||||
"""Review all the unreviewed files when submitting a review."""
|
||||
reviewed = File.objects.create(version=self.version,
|
||||
|
@ -2801,7 +2801,7 @@ class TestWhiteboard(ReviewBase):
|
|||
assert response.status_code == 302
|
||||
assert self.get_addon().whiteboard == whiteboard_info
|
||||
|
||||
@patch('addons.decorators.owner_or_unlisted_reviewer', lambda r, a: True)
|
||||
@patch('olympia.addons.decorators.owner_or_unlisted_reviewer', lambda r, a: True)
|
||||
def test_whiteboard_addition_unlisted_addon(self):
|
||||
self.addon.update(is_listed=False)
|
||||
whiteboard_info = u'Whiteboard info.'
|
||||
|
|
|
@ -95,13 +95,13 @@ class ThemeReviewTestMixin(object):
|
|||
eq_(ThemeLock.objects.filter(reviewer=reviewer).count(),
|
||||
len(expected))
|
||||
|
||||
@mock.patch('amo.messages.success')
|
||||
@mock.patch('editors.tasks.reject_rereview')
|
||||
@mock.patch('editors.tasks.approve_rereview')
|
||||
@mock.patch('addons.tasks.version_changed')
|
||||
@mock.patch('editors.tasks.send_mail_jinja')
|
||||
@mock.patch('editors.tasks.create_persona_preview_images')
|
||||
@mock.patch('amo.storage_utils.copy_stored_file')
|
||||
@mock.patch('olympia.amo.messages.success')
|
||||
@mock.patch('olympia.editors.tasks.reject_rereview')
|
||||
@mock.patch('olympia.editors.tasks.approve_rereview')
|
||||
@mock.patch('olympia.addons.tasks.version_changed')
|
||||
@mock.patch('olympia.editors.tasks.send_mail_jinja')
|
||||
@mock.patch('olympia.editors.tasks.create_persona_preview_images')
|
||||
@mock.patch('olympia.amo.storage_utils.copy_stored_file')
|
||||
def test_commit(self, copy_mock, create_preview_mock,
|
||||
send_mail_jinja_mock, version_changed_mock,
|
||||
approve_rereview_mock, reject_rereview_mock,
|
||||
|
@ -539,10 +539,10 @@ class TestThemeQueueRereview(ThemeReviewTestMixin, TestCase):
|
|||
eq_(r.status_code, 200)
|
||||
eq_(pq(r.content)('.theme').length, 0)
|
||||
|
||||
@mock.patch('editors.tasks.send_mail_jinja')
|
||||
@mock.patch('editors.tasks.copy_stored_file')
|
||||
@mock.patch('editors.tasks.create_persona_preview_images')
|
||||
@mock.patch('amo.storage_utils.copy_stored_file')
|
||||
@mock.patch('olympia.editors.tasks.send_mail_jinja')
|
||||
@mock.patch('olympia.editors.tasks.copy_stored_file')
|
||||
@mock.patch('olympia.editors.tasks.create_persona_preview_images')
|
||||
@mock.patch('olympia.amo.storage_utils.copy_stored_file')
|
||||
def test_update_legacy_theme(self, copy_mock, prev_mock, copy_mock2,
|
||||
noop3):
|
||||
"""
|
||||
|
@ -627,7 +627,7 @@ class TestThemeQueueRereview(ThemeReviewTestMixin, TestCase):
|
|||
args=[addon.slug]))
|
||||
eq_(res.status_code, 200)
|
||||
|
||||
@mock.patch('amo.utils.LocalFileStorage.delete')
|
||||
@mock.patch('olympia.amo.utils.LocalFileStorage.delete')
|
||||
def test_reject_theme_without_footer_bug_1142449(self, delete_mock):
|
||||
"""Don't fail on trying to deleted a non existent footer image."""
|
||||
user = UserProfile.objects.get(email='persona_reviewer@mozilla.com')
|
||||
|
|
|
@ -223,7 +223,7 @@ class TestFileHelper(TestCase):
|
|||
eq_(res, '')
|
||||
assert self.viewer.selected['msg'].startswith('That file no')
|
||||
|
||||
@patch('files.helpers.get_md5')
|
||||
@patch('olympia.files.helpers.get_md5')
|
||||
def test_delete_mid_tree(self, get_md5):
|
||||
get_md5.side_effect = IOError('ow')
|
||||
self.viewer.extract()
|
||||
|
@ -279,7 +279,7 @@ class TestDiffSearchEngine(TestCase):
|
|||
self.helper.cleanup()
|
||||
super(TestDiffSearchEngine, self).tearDown()
|
||||
|
||||
@patch('files.helpers.FileViewer.is_search_engine')
|
||||
@patch('olympia.files.helpers.FileViewer.is_search_engine')
|
||||
def test_diff_search(self, is_search_engine):
|
||||
is_search_engine.return_value = True
|
||||
self.helper.extract()
|
||||
|
|
|
@ -118,7 +118,7 @@ class TestFile(TestCase, amo.tests.AMOPaths):
|
|||
file.update(filename='')
|
||||
file.delete()
|
||||
|
||||
@mock.patch('files.models.File.hide_disabled_file')
|
||||
@mock.patch('olympia.files.models.File.hide_disabled_file')
|
||||
def test_disable_signal(self, hide_mock):
|
||||
f = File.objects.get(pk=67442)
|
||||
f.status = amo.STATUS_PUBLIC
|
||||
|
@ -129,7 +129,7 @@ class TestFile(TestCase, amo.tests.AMOPaths):
|
|||
f.save()
|
||||
assert hide_mock.called
|
||||
|
||||
@mock.patch('files.models.File.unhide_disabled_file')
|
||||
@mock.patch('olympia.files.models.File.unhide_disabled_file')
|
||||
def test_unhide_on_enable(self, unhide_mock):
|
||||
f = File.objects.get(pk=67442)
|
||||
f.status = amo.STATUS_PUBLIC
|
||||
|
@ -176,7 +176,7 @@ class TestFile(TestCase, amo.tests.AMOPaths):
|
|||
assert storage.exists(fo.mirror_file_path), (
|
||||
'file not copied back to mirror')
|
||||
|
||||
@mock.patch('files.models.File.copy_to_mirror')
|
||||
@mock.patch('olympia.files.models.File.copy_to_mirror')
|
||||
def test_copy_to_mirror_on_status_change(self, copy_mock):
|
||||
|
||||
assert amo.STATUS_UNREVIEWED not in amo.MIRROR_STATUSES
|
||||
|
@ -304,13 +304,13 @@ class TestTrackFileStatusChange(TestCase):
|
|||
return f
|
||||
|
||||
def test_track_stats_on_new_file(self):
|
||||
with patch('files.models.track_file_status_change') as mock_:
|
||||
with patch('olympia.files.models.track_file_status_change') as mock_:
|
||||
f = self.create_file()
|
||||
mock_.assert_called_with(f)
|
||||
|
||||
def test_track_stats_on_updated_file(self):
|
||||
f = self.create_file()
|
||||
with patch('files.models.track_file_status_change') as mock_:
|
||||
with patch('olympia.files.models.track_file_status_change') as mock_:
|
||||
f.update(status=amo.STATUS_PUBLIC)
|
||||
|
||||
f.reload()
|
||||
|
@ -318,7 +318,7 @@ class TestTrackFileStatusChange(TestCase):
|
|||
|
||||
def test_ignore_non_status_changes(self):
|
||||
f = self.create_file()
|
||||
with patch('files.models.track_file_status_change') as mock_:
|
||||
with patch('olympia.files.models.track_file_status_change') as mock_:
|
||||
f.update(size=1024)
|
||||
assert not mock_.called, (
|
||||
'Unexpected call: {}'.format(self.mock_.call_args)
|
||||
|
@ -326,7 +326,7 @@ class TestTrackFileStatusChange(TestCase):
|
|||
|
||||
def test_increment_file_status(self):
|
||||
f = self.create_file(status=amo.STATUS_PUBLIC)
|
||||
with patch('files.models.statsd.incr') as mock_incr:
|
||||
with patch('olympia.files.models.statsd.incr') as mock_incr:
|
||||
track_file_status_change(f)
|
||||
mock_incr.assert_any_call(
|
||||
'file_status_change.all.status_{}'.format(amo.STATUS_PUBLIC)
|
||||
|
@ -339,7 +339,7 @@ class TestTrackFileStatusChange(TestCase):
|
|||
no_restart=True,
|
||||
requires_chrome=False,
|
||||
)
|
||||
with patch('files.models.statsd.incr') as mock_incr:
|
||||
with patch('olympia.files.models.statsd.incr') as mock_incr:
|
||||
track_file_status_change(f)
|
||||
mock_incr.assert_any_call(
|
||||
'file_status_change.jetpack_sdk_only.status_{}'
|
||||
|
@ -532,7 +532,7 @@ class TestParseAlternateXpi(TestCase, amo.tests.AMOPaths):
|
|||
AppVersion.objects.get(version='4.0b3pre'))
|
||||
eq_(self.parse()['apps'], [exp])
|
||||
|
||||
@mock.patch('files.utils.rdflib.Graph')
|
||||
@mock.patch('olympia.files.utils.rdflib.Graph')
|
||||
def test_no_manifest_node(self, graph_mock):
|
||||
rdf_mock = mock.Mock()
|
||||
graph_mock.return_value.parse.return_value = rdf_mock
|
||||
|
@ -1005,7 +1005,7 @@ class TestFileFromUpload(UploadTest):
|
|||
def test_litenominated_to_unreviewed(self):
|
||||
upload = self.upload('extension')
|
||||
d = parse_addon(upload.path)
|
||||
with mock.patch('addons.models.Addon.update_status'):
|
||||
with mock.patch('olympia.addons.models.Addon.update_status'):
|
||||
# mock update_status because it doesn't like Addons without files.
|
||||
self.addon.update(status=amo.STATUS_LITE_AND_NOMINATED)
|
||||
eq_(self.addon.status, amo.STATUS_LITE_AND_NOMINATED)
|
||||
|
@ -1015,7 +1015,7 @@ class TestFileFromUpload(UploadTest):
|
|||
def test_trusted_litenominated_to_litenominated(self):
|
||||
upload = self.upload('extension')
|
||||
d = parse_addon(upload.path)
|
||||
with mock.patch('addons.models.Addon.update_status'):
|
||||
with mock.patch('olympia.addons.models.Addon.update_status'):
|
||||
# mock update_status because it doesn't like Addons without files.
|
||||
self.addon.update(status=amo.STATUS_LITE_AND_NOMINATED,
|
||||
trusted=True)
|
||||
|
@ -1134,7 +1134,7 @@ class TestParseSearch(TestCase, amo.tests.AMOPaths):
|
|||
'summary': 'Search Engine for Firefox',
|
||||
'type': amo.ADDON_SEARCH})
|
||||
|
||||
@mock.patch('files.utils.extract_search')
|
||||
@mock.patch('olympia.files.utils.extract_search')
|
||||
def test_extract_search_error(self, extract_mock):
|
||||
extract_mock.side_effect = Exception
|
||||
with self.assertRaises(forms.ValidationError) as e:
|
||||
|
@ -1142,8 +1142,8 @@ class TestParseSearch(TestCase, amo.tests.AMOPaths):
|
|||
assert e.exception.messages[0].startswith('Could not parse ')
|
||||
|
||||
|
||||
@mock.patch('files.utils.parse_xpi')
|
||||
@mock.patch('files.utils.parse_search')
|
||||
@mock.patch('olympia.files.utils.parse_xpi')
|
||||
@mock.patch('olympia.files.utils.parse_search')
|
||||
def test_parse_addon(search_mock, xpi_mock):
|
||||
parse_addon('file.xpi', None)
|
||||
xpi_mock.assert_called_with('file.xpi', None, True)
|
||||
|
@ -1194,13 +1194,13 @@ class TestLanguagePack(LanguagePackBase):
|
|||
obj = self.file_create('search.xml')
|
||||
eq_(obj.get_localepicker(), '')
|
||||
|
||||
@mock.patch('files.utils.SafeUnzip.extract_path')
|
||||
@mock.patch('olympia.files.utils.SafeUnzip.extract_path')
|
||||
def test_no_locale_browser(self, extract_path):
|
||||
extract_path.return_value = 'some garbage'
|
||||
obj = self.file_create('langpack-localepicker')
|
||||
eq_(obj.get_localepicker(), '')
|
||||
|
||||
@mock.patch('files.utils.SafeUnzip.extract_path')
|
||||
@mock.patch('olympia.files.utils.SafeUnzip.extract_path')
|
||||
def test_corrupt_locale_browser_path(self, extract_path):
|
||||
extract_path.return_value = 'locale browser de woot?!'
|
||||
obj = self.file_create('langpack-localepicker')
|
||||
|
@ -1209,7 +1209,7 @@ class TestLanguagePack(LanguagePackBase):
|
|||
# Result should be 'locale browser de woo:t?!as', but we have caching.
|
||||
eq_(obj.get_localepicker(), '')
|
||||
|
||||
@mock.patch('files.utils.SafeUnzip.extract_path')
|
||||
@mock.patch('olympia.files.utils.SafeUnzip.extract_path')
|
||||
def test_corrupt_locale_browser_data(self, extract_path):
|
||||
extract_path.return_value = 'locale browser de jar:install.rdf!foo'
|
||||
obj = self.file_create('langpack-localepicker')
|
||||
|
@ -1221,12 +1221,12 @@ class TestLanguagePack(LanguagePackBase):
|
|||
obj.update(filename='garbage')
|
||||
assert 'title=Select a language' in obj.get_localepicker()
|
||||
|
||||
@mock.patch('files.models.File.get_localepicker')
|
||||
@mock.patch('olympia.files.models.File.get_localepicker')
|
||||
def test_cache_on_create(self, get_localepicker):
|
||||
self.file_create('langpack-localepicker')
|
||||
assert get_localepicker.called
|
||||
|
||||
@mock.patch('files.models.File.get_localepicker')
|
||||
@mock.patch('olympia.files.models.File.get_localepicker')
|
||||
def test_cache_not_on_create(self, get_localepicker):
|
||||
self.addon.update(type=amo.ADDON_DICT)
|
||||
self.file_create('langpack-localepicker')
|
||||
|
|
|
@ -34,7 +34,7 @@ def test_fix_let_scope_bustage():
|
|||
assert_test_file_fixed(temp_filename2)
|
||||
|
||||
|
||||
@mock.patch('files.tasks.fix_let_scope_bustage')
|
||||
@mock.patch('olympia.files.tasks.fix_let_scope_bustage')
|
||||
def test_fix_let_scope_bustage_in_xpi(mock_fixer):
|
||||
"""Fix the "let scope bustage" in the test XPI.
|
||||
|
||||
|
@ -58,9 +58,9 @@ def test_fix_let_scope_bustage_in_xpi(mock_fixer):
|
|||
assert call[1].endswith('foobar/main.js')
|
||||
|
||||
|
||||
@mock.patch('files.tasks.fix_let_scope_bustage_in_xpi')
|
||||
@mock.patch('files.tasks.update_version_number')
|
||||
@mock.patch('files.tasks.sign_file')
|
||||
@mock.patch('olympia.files.tasks.fix_let_scope_bustage_in_xpi')
|
||||
@mock.patch('olympia.files.tasks.update_version_number')
|
||||
@mock.patch('olympia.files.tasks.sign_file')
|
||||
def test_fix_let_scope_bustage_in_addon(mock_sign_file, mock_version_bump,
|
||||
mock_fixer, db):
|
||||
# Create an add-on, with a version.
|
||||
|
|
|
@ -137,10 +137,10 @@ class TestExtractor(TestCase):
|
|||
assert exc.exception.message == (
|
||||
"No install.rdf or package.json or manifest.json found")
|
||||
|
||||
@mock.patch('files.utils.ManifestJSONExtractor')
|
||||
@mock.patch('files.utils.PackageJSONExtractor')
|
||||
@mock.patch('files.utils.RDFExtractor')
|
||||
@mock.patch('files.utils.os.path.exists')
|
||||
@mock.patch('olympia.files.utils.ManifestJSONExtractor')
|
||||
@mock.patch('olympia.files.utils.PackageJSONExtractor')
|
||||
@mock.patch('olympia.files.utils.RDFExtractor')
|
||||
@mock.patch('olympia.files.utils.os.path.exists')
|
||||
def test_parse_install_rdf(self, exists_mock, rdf_extractor,
|
||||
package_json_extractor,
|
||||
manifest_json_extractor):
|
||||
|
@ -150,10 +150,10 @@ class TestExtractor(TestCase):
|
|||
assert not package_json_extractor.called
|
||||
assert not manifest_json_extractor.called
|
||||
|
||||
@mock.patch('files.utils.ManifestJSONExtractor')
|
||||
@mock.patch('files.utils.PackageJSONExtractor')
|
||||
@mock.patch('files.utils.RDFExtractor')
|
||||
@mock.patch('files.utils.os.path.exists')
|
||||
@mock.patch('olympia.files.utils.ManifestJSONExtractor')
|
||||
@mock.patch('olympia.files.utils.PackageJSONExtractor')
|
||||
@mock.patch('olympia.files.utils.RDFExtractor')
|
||||
@mock.patch('olympia.files.utils.os.path.exists')
|
||||
def test_parse_package_json(self, exists_mock, rdf_extractor,
|
||||
package_json_extractor,
|
||||
manifest_json_extractor):
|
||||
|
@ -163,10 +163,10 @@ class TestExtractor(TestCase):
|
|||
assert package_json_extractor.called
|
||||
assert not manifest_json_extractor.called
|
||||
|
||||
@mock.patch('files.utils.ManifestJSONExtractor')
|
||||
@mock.patch('files.utils.PackageJSONExtractor')
|
||||
@mock.patch('files.utils.RDFExtractor')
|
||||
@mock.patch('files.utils.os.path.exists')
|
||||
@mock.patch('olympia.files.utils.ManifestJSONExtractor')
|
||||
@mock.patch('olympia.files.utils.PackageJSONExtractor')
|
||||
@mock.patch('olympia.files.utils.RDFExtractor')
|
||||
@mock.patch('olympia.files.utils.os.path.exists')
|
||||
def test_parse_manifest_json(self, exists_mock, rdf_extractor,
|
||||
package_json_extractor,
|
||||
manifest_json_extractor):
|
||||
|
@ -177,10 +177,10 @@ class TestExtractor(TestCase):
|
|||
assert not package_json_extractor.called
|
||||
assert manifest_json_extractor.called
|
||||
|
||||
@mock.patch('files.utils.ManifestJSONExtractor')
|
||||
@mock.patch('files.utils.PackageJSONExtractor')
|
||||
@mock.patch('files.utils.RDFExtractor')
|
||||
@mock.patch('files.utils.os.path.exists')
|
||||
@mock.patch('olympia.files.utils.ManifestJSONExtractor')
|
||||
@mock.patch('olympia.files.utils.PackageJSONExtractor')
|
||||
@mock.patch('olympia.files.utils.RDFExtractor')
|
||||
@mock.patch('olympia.files.utils.os.path.exists')
|
||||
def test_parse_manifest_json_no_waffle(self, exists_mock, rdf_extractor,
|
||||
package_json_extractor,
|
||||
manifest_json_extractor):
|
||||
|
|
|
@ -63,8 +63,9 @@ class TestPackaged(TestCase):
|
|||
@pytest.fixture(autouse=True)
|
||||
def mock_get_signature_serial_number(self, monkeypatch):
|
||||
"""Fake a standard signing-client response."""
|
||||
monkeypatch.setattr('lib.crypto.packaged.get_signature_serial_number',
|
||||
lambda pkcs7: 'serial number')
|
||||
monkeypatch.setattr(
|
||||
'olympia.lib.crypto.packaged.get_signature_serial_number',
|
||||
lambda pkcs7: 'serial number')
|
||||
|
||||
def assert_not_signed(self):
|
||||
assert not self.file_.is_signed
|
||||
|
@ -318,7 +319,7 @@ class TestTasks(TestCase):
|
|||
"""Make sure there's no backup file."""
|
||||
assert not os.path.exists(self.get_backup_file_path())
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_no_bump_unreviewed(self, mock_sign_file):
|
||||
"""Don't bump nor sign unreviewed files."""
|
||||
for status in (amo.UNREVIEWED_STATUSES + (amo.STATUS_BETA,)):
|
||||
|
@ -336,7 +337,7 @@ class TestTasks(TestCase):
|
|||
assert file_hash == self.file_.generate_hash()
|
||||
self.assert_no_backup()
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_bump_version_in_model(self, mock_sign_file):
|
||||
# We want to make sure each file has been signed.
|
||||
self.file2 = amo.tests.file_factory(version=self.version)
|
||||
|
@ -367,7 +368,7 @@ class TestTasks(TestCase):
|
|||
if os.path.exists(backup_file2_path):
|
||||
os.unlink(backup_file2_path)
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_sign_full(self, mock_sign_file):
|
||||
"""Use the full signing server if files are fully reviewed."""
|
||||
self.file_.update(status=amo.STATUS_PUBLIC)
|
||||
|
@ -378,7 +379,7 @@ class TestTasks(TestCase):
|
|||
mock_sign_file.assert_called_with(
|
||||
self.file_, settings.SIGNING_SERVER)
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_sign_prelim(self, mock_sign_file):
|
||||
"""Use the prelim signing server if files aren't fully reviewed."""
|
||||
self.file_.update(status=amo.STATUS_LITE)
|
||||
|
@ -389,7 +390,7 @@ class TestTasks(TestCase):
|
|||
mock_sign_file.assert_called_with(
|
||||
self.file_, settings.PRELIMINARY_SIGNING_SERVER)
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_dont_sign_dont_bump_old_versions(self, mock_sign_file):
|
||||
"""Don't sign files which are too old, or not default to compatible."""
|
||||
def not_signed():
|
||||
|
@ -423,7 +424,7 @@ class TestTasks(TestCase):
|
|||
tasks.sign_addons([self.addon.pk])
|
||||
not_signed()
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_sign_bump_non_ascii_filename(self, mock_sign_file):
|
||||
"""Sign files which have non-ascii filenames."""
|
||||
self.file_.update(filename=u'jétpack.xpi')
|
||||
|
@ -441,7 +442,7 @@ class TestTasks(TestCase):
|
|||
assert file_hash != self.file_.generate_hash()
|
||||
self.assert_backup()
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_sign_bump_non_ascii_version(self, mock_sign_file):
|
||||
"""Sign versions which have non-ascii version numbers."""
|
||||
self.version.update(version=u'é1.3')
|
||||
|
@ -459,7 +460,7 @@ class TestTasks(TestCase):
|
|||
assert file_hash != self.file_.generate_hash()
|
||||
self.assert_backup()
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_sign_bump_old_versions_default_compat(self, mock_sign_file):
|
||||
"""Sign files which are old, but default to compatible."""
|
||||
with amo.tests.copy_file(
|
||||
|
@ -477,7 +478,7 @@ class TestTasks(TestCase):
|
|||
assert file_hash != self.file_.generate_hash()
|
||||
self.assert_backup()
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_sign_bump_new_versions_not_default_compat(self, mock_sign_file):
|
||||
"""Sign files which are recent, event if not default to compatible."""
|
||||
with amo.tests.copy_file(
|
||||
|
@ -496,7 +497,7 @@ class TestTasks(TestCase):
|
|||
assert file_hash != self.file_.generate_hash()
|
||||
self.assert_backup()
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_dont_resign_dont_bump_version_in_model(self, mock_sign_file):
|
||||
with amo.tests.copy_file(
|
||||
'src/olympia/files/fixtures/files/new-addon-signature.xpi',
|
||||
|
@ -513,7 +514,7 @@ class TestTasks(TestCase):
|
|||
assert file_hash == self.file_.generate_hash()
|
||||
self.assert_no_backup()
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_dont_sign_dont_bump_version_bad_zipfile(self, mock_sign_file):
|
||||
with amo.tests.copy_file(__file__, self.file_.file_path):
|
||||
file_hash = self.file_.generate_hash()
|
||||
|
@ -527,7 +528,7 @@ class TestTasks(TestCase):
|
|||
assert file_hash == self.file_.generate_hash()
|
||||
self.assert_no_backup()
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_dont_sign_dont_bump_sign_error(self, mock_sign_file):
|
||||
mock_sign_file.side_effect = IOError()
|
||||
with amo.tests.copy_file('src/olympia/files/fixtures/files/jetpack.xpi',
|
||||
|
@ -543,7 +544,7 @@ class TestTasks(TestCase):
|
|||
assert file_hash == self.file_.generate_hash()
|
||||
self.assert_no_backup()
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_dont_bump_not_signed(self, mock_sign_file):
|
||||
mock_sign_file.return_value = None # Pretend we didn't sign.
|
||||
with amo.tests.copy_file('src/olympia/files/fixtures/files/jetpack.xpi',
|
||||
|
@ -559,7 +560,7 @@ class TestTasks(TestCase):
|
|||
assert file_hash == self.file_.generate_hash()
|
||||
self.assert_no_backup()
|
||||
|
||||
@mock.patch('lib.crypto.tasks.sign_file')
|
||||
@mock.patch('olympia.lib.crypto.tasks.sign_file')
|
||||
def test_resign_bump_version_in_model_if_force(self, mock_sign_file):
|
||||
with amo.tests.copy_file(
|
||||
'src/olympia/files/fixtures/files/new-addon-signature.xpi',
|
||||
|
|
|
@ -23,7 +23,7 @@ class TestReindexManager(TestCase):
|
|||
assert Reindexing.objects.filter(site='foo').count() == 1
|
||||
assert res is None
|
||||
|
||||
@mock.patch('lib.es.models.ReindexingManager._flag_reindexing')
|
||||
@mock.patch('olympia.lib.es.models.ReindexingManager._flag_reindexing')
|
||||
def test_flag_reindexing_amo(self, flag_reindexing_mock):
|
||||
Reindexing.objects.flag_reindexing_amo('bar', 'baz', 'quux')
|
||||
assert flag_reindexing_mock.called_with([
|
||||
|
@ -50,7 +50,7 @@ class TestReindexManager(TestCase):
|
|||
Reindexing.objects._unflag_reindexing('foo')
|
||||
assert Reindexing.objects.filter(site='bar').count() == 1
|
||||
|
||||
@mock.patch('lib.es.models.ReindexingManager._unflag_reindexing')
|
||||
@mock.patch('olympia.lib.es.models.ReindexingManager._unflag_reindexing')
|
||||
def test_unflag_reindexing_amo(self, unflag_reindexing_mock):
|
||||
Reindexing.objects.unflag_reindexing_amo()
|
||||
assert unflag_reindexing_mock.called_with([('amo')])
|
||||
|
@ -66,7 +66,7 @@ class TestReindexManager(TestCase):
|
|||
# Reindexing on another site doesn't clash.
|
||||
assert not Reindexing.objects._is_reindexing('bar')
|
||||
|
||||
@mock.patch('lib.es.models.ReindexingManager._is_reindexing')
|
||||
@mock.patch('olympia.lib.es.models.ReindexingManager._is_reindexing')
|
||||
def test_is_reindexing_amo(self, is_reindexing_mock):
|
||||
Reindexing.objects.is_reindexing_amo()
|
||||
assert is_reindexing_mock.called_with([('amo')])
|
||||
|
|
|
@ -10,7 +10,7 @@ from olympia.amo.decorators import set_modified_on
|
|||
from olympia.lib.video import library
|
||||
|
||||
log = logging.getLogger('z.devhub.task')
|
||||
time_limits = settings.CELERY_TIME_LIMITS['lib.video.tasks.resize_video']
|
||||
time_limits = settings.CELERY_TIME_LIMITS['olympia.lib.video.tasks.resize_video']
|
||||
|
||||
|
||||
# Video decoding can take a while, so let's increase these limits.
|
||||
|
|
|
@ -176,10 +176,10 @@ class TestTotemVideo(TestCase):
|
|||
os.remove(video)
|
||||
|
||||
|
||||
@patch('lib.video.totem.Video.library_available')
|
||||
@patch('lib.video.ffmpeg.Video.library_available')
|
||||
@patch('olympia.lib.video.totem.Video.library_available')
|
||||
@patch('olympia.lib.video.ffmpeg.Video.library_available')
|
||||
@patch.object(settings, 'VIDEO_LIBRARIES',
|
||||
['lib.video.totem', 'lib.video.ffmpeg'])
|
||||
['olympia.lib.video.totem', 'olympia.lib.video.ffmpeg'])
|
||||
def test_choose(ffmpeg_, totem_):
|
||||
ffmpeg_.return_value = True
|
||||
totem_.return_value = True
|
||||
|
@ -201,7 +201,7 @@ class TestTask(TestCase):
|
|||
self.mock.image_path = tempfile.mkstemp()[1]
|
||||
self.mock.pk = 1
|
||||
|
||||
@patch('lib.video.tasks._resize_video')
|
||||
@patch('olympia.lib.video.tasks._resize_video')
|
||||
def test_resize_error(self, _resize_video):
|
||||
user = UserProfile.objects.create(email='a@a.com')
|
||||
_resize_video.side_effect = ValueError
|
||||
|
@ -211,7 +211,7 @@ class TestTask(TestCase):
|
|||
assert UserLog.objects.filter(
|
||||
user=user, activity_log__action=amo.LOG.VIDEO_ERROR.id).exists()
|
||||
|
||||
@patch('lib.video.tasks._resize_video')
|
||||
@patch('olympia.lib.video.tasks._resize_video')
|
||||
def test_resize_failed(self, _resize_video):
|
||||
user = UserProfile.objects.create(email='a@a.com')
|
||||
_resize_video.return_value = None
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.conf import settings
|
|||
|
||||
from nose.tools import eq_
|
||||
|
||||
from olympia.olympia.amo.tests import TestCase
|
||||
from olympia.amo.tests import TestCase
|
||||
from olympia.amo.urlresolvers import reverse
|
||||
|
||||
|
||||
|
|
|
@ -56,22 +56,22 @@ class TestPayKey(TestCase):
|
|||
data['amount'] = 'some random text'
|
||||
self.assertRaises(paypal.PaypalError, paypal.get_paykey, data)
|
||||
|
||||
@mock.patch('paypal.requests.post')
|
||||
@mock.patch('olympia.paypal.requests.post')
|
||||
def test_auth_fails(self, opener):
|
||||
opener.return_value.text = auth_error
|
||||
self.assertRaises(paypal.AuthError, paypal.get_paykey, self.data)
|
||||
|
||||
@mock.patch('paypal.requests.post')
|
||||
@mock.patch('olympia.paypal.requests.post')
|
||||
def test_get_key(self, opener):
|
||||
opener.return_value.text = good_response
|
||||
eq_(paypal.get_paykey(self.data), ('AP-9GD76073HJ780401K', 'CREATED'))
|
||||
|
||||
@mock.patch('paypal.requests.post')
|
||||
@mock.patch('olympia.paypal.requests.post')
|
||||
def test_error_is_paypal(self, opener):
|
||||
opener.side_effect = ZeroDivisionError
|
||||
self.assertRaises(paypal.PaypalError, paypal.get_paykey, self.data)
|
||||
|
||||
@mock.patch('paypal.requests.post')
|
||||
@mock.patch('olympia.paypal.requests.post')
|
||||
def test_error_raised(self, opener):
|
||||
opener.return_value.text = other_error.replace('520001', '589023')
|
||||
try:
|
||||
|
@ -82,7 +82,7 @@ class TestPayKey(TestCase):
|
|||
else:
|
||||
raise ValueError('No PaypalError was raised')
|
||||
|
||||
@mock.patch('paypal.requests.post')
|
||||
@mock.patch('olympia.paypal.requests.post')
|
||||
def test_error_one_currency(self, opener):
|
||||
opener.return_value.text = other_error.replace('520001', '559044')
|
||||
try:
|
||||
|
@ -95,7 +95,7 @@ class TestPayKey(TestCase):
|
|||
else:
|
||||
raise ValueError('No PaypalError was raised')
|
||||
|
||||
@mock.patch('paypal.requests.post')
|
||||
@mock.patch('olympia.paypal.requests.post')
|
||||
def test_error_no_currency(self, opener):
|
||||
opener.return_value.text = other_error.replace('520001', '559044')
|
||||
try:
|
||||
|
@ -106,12 +106,12 @@ class TestPayKey(TestCase):
|
|||
else:
|
||||
raise ValueError('No PaypalError was raised')
|
||||
|
||||
@mock.patch('paypal.requests.post')
|
||||
@mock.patch('olympia.paypal.requests.post')
|
||||
def test_other_fails(self, opener):
|
||||
opener.return_value.text = other_error
|
||||
self.assertRaises(paypal.PaypalError, paypal.get_paykey, self.data)
|
||||
|
||||
@mock.patch('paypal._call')
|
||||
@mock.patch('olympia.paypal._call')
|
||||
def test_qs_passed(self, _call):
|
||||
data = self.data.copy()
|
||||
data['qs'] = {'foo': 'bar'}
|
||||
|
@ -132,13 +132,13 @@ class TestPayKey(TestCase):
|
|||
key = paypal.get_paykey(self.data)
|
||||
eq_(paypal.check_purchase(key), 'CREATED')
|
||||
|
||||
@mock.patch('paypal._call')
|
||||
@mock.patch('olympia.paypal._call')
|
||||
def test_usd_default(self, _call):
|
||||
_call.return_value = {'payKey': '', 'paymentExecStatus': ''}
|
||||
paypal.get_paykey(self.data)
|
||||
eq_(_call.call_args[0][1]['currencyCode'], 'USD')
|
||||
|
||||
@mock.patch('paypal._call')
|
||||
@mock.patch('olympia.paypal._call')
|
||||
def test_other_currency(self, _call):
|
||||
_call.return_value = {'payKey': '', 'paymentExecStatus': ''}
|
||||
data = self.data.copy()
|
||||
|
@ -146,7 +146,7 @@ class TestPayKey(TestCase):
|
|||
paypal.get_paykey(data)
|
||||
eq_(_call.call_args[0][1]['currencyCode'], 'EUR')
|
||||
|
||||
@mock.patch('paypal._call')
|
||||
@mock.patch('olympia.paypal._call')
|
||||
def test_error_currency(self, _call):
|
||||
_call.side_effect = paypal.CurrencyError()
|
||||
data = self.data.copy()
|
||||
|
@ -156,18 +156,18 @@ class TestPayKey(TestCase):
|
|||
|
||||
class TestPurchase(TestCase):
|
||||
|
||||
@mock.patch('paypal.requests.post')
|
||||
@mock.patch('olympia.paypal.requests.post')
|
||||
def test_check_purchase(self, opener):
|
||||
opener.return_value.text = good_check_purchase
|
||||
eq_(paypal.check_purchase('some-paykey'), 'CREATED')
|
||||
|
||||
@mock.patch('paypal.requests.post')
|
||||
@mock.patch('olympia.paypal.requests.post')
|
||||
def test_check_purchase_fails(self, opener):
|
||||
opener.return_value.text = other_error
|
||||
eq_(paypal.check_purchase('some-paykey'), False)
|
||||
|
||||
|
||||
@mock.patch('paypal.requests.get')
|
||||
@mock.patch('olympia.paypal.requests.get')
|
||||
def test_check_paypal_id(get):
|
||||
get.return_value.text = 'ACK=Success'
|
||||
val = paypal.check_paypal_id(u'\u30d5\u30a9\u30af\u3059\u3051')
|
||||
|
|
|
@ -72,7 +72,7 @@ class PaypalTest(TestCase):
|
|||
return m
|
||||
|
||||
|
||||
@patch('paypal.views.requests.post')
|
||||
@patch('olympia.paypal.views.requests.post')
|
||||
class TestPaypal(PaypalTest):
|
||||
fixtures = ['base/users']
|
||||
|
||||
|
|
|
@ -450,7 +450,7 @@ class TestTranslate(ReviewTest):
|
|||
eq_(r.get('Location'),
|
||||
'https://translate.google.com/#auto/fr/h%C3%A9h%C3%A9%203%25')
|
||||
|
||||
@mock.patch('reviews.views.requests')
|
||||
@mock.patch('olympia.reviews.views.requests')
|
||||
def test_ajax_call(self, requests):
|
||||
# Mock requests.
|
||||
response = mock.Mock()
|
||||
|
@ -470,7 +470,7 @@ class TestTranslate(ReviewTest):
|
|||
eq_(json.loads(r.content), {"body": "oui", "title": "oui"})
|
||||
|
||||
@mock.patch('waffle.switch_is_active', lambda x: True)
|
||||
@mock.patch('reviews.views.requests')
|
||||
@mock.patch('olympia.reviews.views.requests')
|
||||
def test_invalid_api_key(self, requests):
|
||||
# Mock requests.
|
||||
response = mock.Mock()
|
||||
|
|
|
@ -14,14 +14,14 @@ class TestElasticsearchExceptionMiddleware(TestCase):
|
|||
super(TestElasticsearchExceptionMiddleware, self).setUp()
|
||||
self.request = RequestFactory()
|
||||
|
||||
@mock.patch('search.middleware.render')
|
||||
@mock.patch('olympia.search.middleware.render')
|
||||
def test_exceptions_we_catch(self, render_mock):
|
||||
ESM().process_exception(self.request, TransportError(400, 'ES ERROR'))
|
||||
render_mock.assert_called_with(self.request, 'search/down.html',
|
||||
status=503)
|
||||
render_mock.reset_mock()
|
||||
|
||||
@mock.patch('search.middleware.render')
|
||||
@mock.patch('olympia.search.middleware.render')
|
||||
def test_exceptions_we_do_not_catch(self, render_mock):
|
||||
ESM().process_exception(self.request, Exception)
|
||||
eq_(render_mock.called, False)
|
||||
|
|
|
@ -751,7 +751,7 @@ class TestPersonaSearch(SearchBase):
|
|||
self.check_name_results({}, sorted(p.id for p in self.personas))
|
||||
|
||||
# Pretend we only want 2 personas per result page.
|
||||
@mock.patch('search.views.DEFAULT_NUM_PERSONAS', 2)
|
||||
@mock.patch('olympia.search.views.DEFAULT_NUM_PERSONAS', 2)
|
||||
def test_pagination(self):
|
||||
self._generate_personas() # This creates 3 public personas.
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class BaseUploadVersionCase(SigningAPITestCase):
|
|||
super(BaseUploadVersionCase, self).setUp()
|
||||
self.guid = '{2fa4ed95-0317-4c6a-a74c-5f3e3912c1f9}'
|
||||
self.view = VersionView.as_view()
|
||||
patcher = mock.patch('devhub.tasks.create_version_for_upload',
|
||||
patcher = mock.patch('olympia.devhub.tasks.create_version_for_upload',
|
||||
tasks.create_version_for_upload.non_atomic)
|
||||
self.create_version_for_upload = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
@ -75,7 +75,7 @@ class TestUploadVersion(BaseUploadVersionCase):
|
|||
assert response.status_code == 503
|
||||
assert 'website maintenance' in response.data['error']
|
||||
|
||||
@mock.patch('devhub.views.auto_sign_version')
|
||||
@mock.patch('olympia.devhub.views.auto_sign_version')
|
||||
def test_addon_does_not_exist(self, sign_version):
|
||||
guid = '@create-version'
|
||||
qs = Addon.unfiltered.filter(guid=guid)
|
||||
|
@ -107,7 +107,7 @@ class TestUploadVersion(BaseUploadVersionCase):
|
|||
assert response.status_code == 409
|
||||
assert response.data['error'] == 'Version already exists.'
|
||||
|
||||
@mock.patch('devhub.views.Version.from_upload')
|
||||
@mock.patch('olympia.devhub.views.Version.from_upload')
|
||||
def test_no_version_yet(self, from_upload):
|
||||
response = self.put(self.url(self.guid, '3.0'))
|
||||
assert response.status_code == 202
|
||||
|
@ -117,7 +117,7 @@ class TestUploadVersion(BaseUploadVersionCase):
|
|||
assert response.status_code == 200
|
||||
assert 'processed' in response.data
|
||||
|
||||
@mock.patch('devhub.views.auto_sign_version')
|
||||
@mock.patch('olympia.devhub.views.auto_sign_version')
|
||||
def test_version_added(self, sign_version):
|
||||
assert Addon.objects.get(guid=self.guid).status == amo.STATUS_PUBLIC
|
||||
qs = Version.objects.filter(addon__guid=self.guid, version='3.0')
|
||||
|
@ -159,7 +159,7 @@ class TestUploadVersion(BaseUploadVersionCase):
|
|||
assert response.status_code == 200
|
||||
assert 'processed' in response.data
|
||||
|
||||
@mock.patch('devhub.views.auto_sign_version')
|
||||
@mock.patch('olympia.devhub.views.auto_sign_version')
|
||||
def test_version_added_is_experiment(self, sign_version):
|
||||
self.grant_permission(self.user, 'Experiments:submit')
|
||||
guid = 'experiment@xpi'
|
||||
|
@ -176,7 +176,7 @@ class TestUploadVersion(BaseUploadVersionCase):
|
|||
assert addon.status == amo.STATUS_LITE
|
||||
sign_version.assert_called_with(addon.latest_version)
|
||||
|
||||
@mock.patch('devhub.views.auto_sign_version')
|
||||
@mock.patch('olympia.devhub.views.auto_sign_version')
|
||||
def test_version_added_is_experiment_reject_no_perm(self, sign_version):
|
||||
guid = 'experiment@xpi'
|
||||
qs = Addon.unfiltered.filter(guid=guid)
|
||||
|
@ -223,7 +223,7 @@ class TestCheckVersion(BaseUploadVersionCase):
|
|||
|
||||
def test_version_exists_with_pk(self):
|
||||
# Mock Version.from_upload so the Version won't be created.
|
||||
with mock.patch('devhub.tasks.Version.from_upload'):
|
||||
with mock.patch('olympia.devhub.tasks.Version.from_upload'):
|
||||
self.create_version('3.0')
|
||||
upload = FileUpload.objects.latest()
|
||||
upload.update(created=datetime.today() - timedelta(hours=1))
|
||||
|
@ -237,7 +237,7 @@ class TestCheckVersion(BaseUploadVersionCase):
|
|||
assert response.data['pk'] == upload.pk
|
||||
assert 'processed' in response.data
|
||||
|
||||
@mock.patch('devhub.tasks.submit_file')
|
||||
@mock.patch('olympia.devhub.tasks.submit_file')
|
||||
def test_version_exists_with_pk_not_owner(self, submit_file):
|
||||
orig_user, orig_api_key = self.user, self.api_key
|
||||
|
||||
|
@ -327,7 +327,7 @@ class TestSignedFile(SigningAPITestCase):
|
|||
assert response.status_code == 401
|
||||
|
||||
def test_api_relies_on_version_downloader(self):
|
||||
with mock.patch('versions.views.download_file') as df:
|
||||
with mock.patch('olympia.versions.views.download_file') as df:
|
||||
df.return_value = Response({})
|
||||
self.get(self.url())
|
||||
assert df.called is True
|
||||
|
|
|
@ -45,8 +45,8 @@ class TestGoogleAnalytics(TestCase):
|
|||
'token_expiry': '', 'token_uri': '',
|
||||
'user_agent': ''}, create=True)
|
||||
@mock.patch('httplib2.Http')
|
||||
@mock.patch('stats.tasks.get_profile_id')
|
||||
@mock.patch('stats.tasks.build')
|
||||
@mock.patch('olympia.stats.tasks.get_profile_id')
|
||||
@mock.patch('olympia.stats.tasks.build')
|
||||
def test_ask_google(self, build, gpi, http):
|
||||
gpi.return_value = '1'
|
||||
d = '2012-01-01'
|
||||
|
@ -83,7 +83,7 @@ class TestTotalContributions(TestCase):
|
|||
eq_(float(a.total_contributions), 19.99)
|
||||
|
||||
|
||||
@mock.patch('stats.management.commands.index_stats.create_tasks')
|
||||
@mock.patch('olympia.stats.management.commands.index_stats.create_tasks')
|
||||
class TestIndexStats(TestCase):
|
||||
fixtures = ['stats/test_models']
|
||||
|
||||
|
@ -167,7 +167,7 @@ class TestIndexLatest(amo.tests.ESTestCase):
|
|||
|
||||
start = latest.strftime('%Y-%m-%d')
|
||||
finish = datetime.date.today().strftime('%Y-%m-%d')
|
||||
with mock.patch('stats.cron.call_command') as call:
|
||||
with mock.patch('olympia.stats.cron.call_command') as call:
|
||||
cron.index_latest_stats()
|
||||
call.assert_called_with('index_stats', addons=None,
|
||||
date='%s:%s' % (start, finish))
|
||||
|
|
|
@ -746,7 +746,7 @@ class TestSiteQuery(TestCase):
|
|||
self.start, self.end)
|
||||
|
||||
|
||||
@mock.patch('stats.views._site_query')
|
||||
@mock.patch('olympia.stats.views._site_query')
|
||||
class TestSite(TestCase):
|
||||
|
||||
def tests_period(self, _site_query):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from nose.tools import eq_
|
||||
|
||||
from olympia.tests import TestCase
|
||||
from olympia.amo.tests import TestCase
|
||||
from olympia.addons.models import Addon
|
||||
from olympia.files.models import File
|
||||
from olympia.tags.models import Tag, AddonTag
|
||||
|
|
|
@ -12,9 +12,9 @@ from olympia.versions.urls import download_patterns
|
|||
|
||||
admin.autodiscover()
|
||||
|
||||
handler403 = 'amo.views.handler403'
|
||||
handler404 = 'amo.views.handler404'
|
||||
handler500 = 'amo.views.handler500'
|
||||
handler403 = 'olympia.amo.views.handler403'
|
||||
handler404 = 'olympia.amo.views.handler404'
|
||||
handler500 = 'olympia.amo.views.handler500'
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
|
|
|
@ -156,7 +156,7 @@ class TestUserDeleteForm(UserFormBase):
|
|||
eq_(u.deleted, True)
|
||||
eq_(u.email, None)
|
||||
|
||||
@patch('users.models.UserProfile.is_developer')
|
||||
@patch('olympia.users.models.UserProfile.is_developer')
|
||||
def test_developer_attempt(self, f):
|
||||
"""A developer's attempt to delete one's self must be thwarted."""
|
||||
f.return_value = True
|
||||
|
@ -228,7 +228,7 @@ class TestUserEditForm(UserFormBase):
|
|||
err = u'Ensure this value has at most %s characters (it has %s).'
|
||||
self.assertFormError(r, 'form', field, err % (length, length + 1))
|
||||
|
||||
@patch('amo.models.ModelBase.update')
|
||||
@patch('olympia.amo.models.ModelBase.update')
|
||||
def test_photo_modified(self, update_mock):
|
||||
dummy = Mock()
|
||||
dummy.user = self.user
|
||||
|
|
|
@ -392,7 +392,7 @@ class TestFlushURLs(TestCase):
|
|||
_disconnect()
|
||||
super(TestFlushURLs, self).tearDown()
|
||||
|
||||
@patch('amo.tasks.flush_front_end_cache_urls.apply_async')
|
||||
@patch('olympia.amo.tasks.flush_front_end_cache_urls.apply_async')
|
||||
def test_flush(self, flush):
|
||||
user = UserProfile.objects.get(pk=2519)
|
||||
user.save()
|
||||
|
|
|
@ -45,7 +45,7 @@ class TestAutoCreateUsername(TestCase):
|
|||
assert not un.startswith('fuuuuuuuuuuuuuuuuuu'), 'Unexpected: %s' % un
|
||||
|
||||
@mock.patch.object(settings, 'MAX_GEN_USERNAME_TRIES', 3)
|
||||
@fudge.patch('users.utils.UserProfile.objects.filter')
|
||||
@fudge.patch('olympia.users.utils.UserProfile.objects.filter')
|
||||
def test_too_many_tries(self, filter):
|
||||
filter = (filter.is_callable().returns_fake().provides('count')
|
||||
.returns(1))
|
||||
|
@ -58,7 +58,7 @@ class TestAutoCreateUsername(TestCase):
|
|||
un = autocreate_username('base')
|
||||
assert not un.startswith('base'), 'Unexpected: %s' % un
|
||||
|
||||
@fudge.patch('users.utils.UserProfile.objects.filter')
|
||||
@fudge.patch('olympia.users.utils.UserProfile.objects.filter')
|
||||
def test_duplicate_username_counter(self, filter):
|
||||
filter = (filter.expects_call().returns_fake().expects('count')
|
||||
.returns(1)
|
||||
|
|
|
@ -661,7 +661,7 @@ class TestLogin(UserViewBase):
|
|||
|
||||
|
||||
@patch.object(settings, 'RECAPTCHA_PRIVATE_KEY', '')
|
||||
@patch('users.models.UserProfile.log_login_attempt')
|
||||
@patch('olympia.users.models.UserProfile.log_login_attempt')
|
||||
class TestFailedCount(UserViewBase):
|
||||
fixtures = ['users/test_backends', 'base/addon_3615']
|
||||
|
||||
|
|
|
@ -272,7 +272,7 @@ class TestVersion(TestCase):
|
|||
version = Version.objects.get(pk=81551)
|
||||
assert not version.is_allowed_upload()
|
||||
|
||||
@mock.patch('files.models.File.hide_disabled_file')
|
||||
@mock.patch('olympia.files.models.File.hide_disabled_file')
|
||||
def test_new_version_disable_old_unreviewed(self, hide_mock):
|
||||
addon = Addon.objects.get(id=3615)
|
||||
# The status doesn't change for public files.
|
||||
|
@ -362,7 +362,7 @@ class TestVersion(TestCase):
|
|||
|
||||
# Non-public addon.
|
||||
self._reset_version(version)
|
||||
with mock.patch('addons.models.Addon.is_public') as is_addon_public:
|
||||
with mock.patch('olympia.addons.models.Addon.is_public') as is_addon_public:
|
||||
is_addon_public.return_value = False
|
||||
eq_(version.is_public(), False)
|
||||
|
||||
|
@ -431,13 +431,13 @@ class TestVersion(TestCase):
|
|||
max_app_version='10.*')
|
||||
eq_(version.compat_override_app_versions(), [('10.0a1', '10.*')])
|
||||
|
||||
@mock.patch('addons.models.Addon.invalidate_d2c_versions')
|
||||
@mock.patch('olympia.addons.models.Addon.invalidate_d2c_versions')
|
||||
def test_invalidate_d2c_version_signals_on_delete(self, inv_mock):
|
||||
version = Addon.objects.get(pk=3615).current_version
|
||||
version.delete()
|
||||
assert inv_mock.called
|
||||
|
||||
@mock.patch('addons.models.Addon.invalidate_d2c_versions')
|
||||
@mock.patch('olympia.addons.models.Addon.invalidate_d2c_versions')
|
||||
def test_invalidate_d2c_version_signals_on_save(self, inv_mock):
|
||||
addon = Addon.objects.get(pk=3615)
|
||||
amo.tests.version_factory(addon=addon)
|
||||
|
@ -1243,7 +1243,7 @@ class TestExtensionVersionFromUpload(TestVersionFromUpload):
|
|||
# would be in the microsecond range.
|
||||
self.upload.update(created=datetime.now() - timedelta(days=1))
|
||||
|
||||
with mock.patch('versions.models.statsd.timing') as mock_timing:
|
||||
with mock.patch('olympia.versions.models.statsd.timing') as mock_timing:
|
||||
Version.from_upload(self.upload, self.addon, [self.platform])
|
||||
|
||||
upload_start = utc_millesecs_from_epoch(self.upload.created)
|
||||
|
|
|
@ -75,7 +75,7 @@ class TestLangpackFetcher(TestCase):
|
|||
|
||||
def setUp(self):
|
||||
super(TestLangpackFetcher, self).setUp()
|
||||
request_patch = mock.patch('zadmin.tasks.requests.get')
|
||||
request_patch = mock.patch('olympia.zadmin.tasks.requests.get')
|
||||
self.mock_request = request_patch.start()
|
||||
self.addCleanup(request_patch.stop)
|
||||
|
||||
|
@ -103,7 +103,7 @@ class TestLangpackFetcher(TestCase):
|
|||
[mock.call(list_url, verify=settings.CA_CERT_BUNDLE_PATH),
|
||||
mock.call(langpack_url, verify=settings.CA_CERT_BUNDLE_PATH)])
|
||||
|
||||
@mock.patch('zadmin.tasks.sign_file')
|
||||
@mock.patch('olympia.zadmin.tasks.sign_file')
|
||||
def test_fetch_new_langpack(self, mock_sign_file):
|
||||
assert self.get_langpacks().count() == 0
|
||||
|
||||
|
@ -125,7 +125,7 @@ class TestLangpackFetcher(TestCase):
|
|||
mock_sign_file.assert_called_once_with(
|
||||
addon.current_version.files.get(), settings.SIGNING_SERVER)
|
||||
|
||||
@mock.patch('zadmin.tasks.sign_file')
|
||||
@mock.patch('olympia.zadmin.tasks.sign_file')
|
||||
def test_fetch_updated_langpack(self, mock_sign_file):
|
||||
versions = ('16.0', '17.0')
|
||||
|
||||
|
@ -147,7 +147,7 @@ class TestLangpackFetcher(TestCase):
|
|||
mock_sign_file.assert_called_with(
|
||||
version.files.get(), settings.SIGNING_SERVER)
|
||||
|
||||
@mock.patch('zadmin.tasks.sign_file')
|
||||
@mock.patch('olympia.zadmin.tasks.sign_file')
|
||||
def test_fetch_duplicate_langpack(self, mock_sign_file):
|
||||
self.fetch_langpacks(amo.FIREFOX.latest_version)
|
||||
|
||||
|
@ -169,7 +169,7 @@ class TestLangpackFetcher(TestCase):
|
|||
mock_sign_file.assert_called_once_with(
|
||||
addon.current_version.files.get(), settings.SIGNING_SERVER)
|
||||
|
||||
@mock.patch('zadmin.tasks.sign_file')
|
||||
@mock.patch('olympia.zadmin.tasks.sign_file')
|
||||
def test_fetch_updated_langpack_beta(self, mock_sign_file):
|
||||
versions = ('16.0', '16.0a2')
|
||||
|
||||
|
@ -191,7 +191,7 @@ class TestLangpackFetcher(TestCase):
|
|||
mock_sign_file.assert_called_with(
|
||||
version.files.get(), settings.PRELIMINARY_SIGNING_SERVER)
|
||||
|
||||
@mock.patch('zadmin.tasks.sign_file')
|
||||
@mock.patch('olympia.zadmin.tasks.sign_file')
|
||||
def test_fetch_new_langpack_beta(self, mock_sign_file):
|
||||
self.fetch_langpacks('16.0a2')
|
||||
|
||||
|
@ -199,7 +199,7 @@ class TestLangpackFetcher(TestCase):
|
|||
|
||||
assert not mock_sign_file.called
|
||||
|
||||
@mock.patch('zadmin.tasks.sign_file')
|
||||
@mock.patch('olympia.zadmin.tasks.sign_file')
|
||||
def test_fetch_langpack_wrong_owner(self, mock_sign_file):
|
||||
Addon.objects.create(guid='langpack-de-DE@firefox.mozilla.org',
|
||||
type=amo.ADDON_LPAPP)
|
||||
|
@ -209,7 +209,7 @@ class TestLangpackFetcher(TestCase):
|
|||
|
||||
assert not mock_sign_file.called
|
||||
|
||||
@mock.patch('zadmin.tasks.sign_file')
|
||||
@mock.patch('olympia.zadmin.tasks.sign_file')
|
||||
def test_fetch_langpack_invalid_path_fails(self, mock_sign_file):
|
||||
self.mock_request.return_value = None
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ class BulkValidationTest(TestCase):
|
|||
|
||||
class TestBulkValidation(BulkValidationTest):
|
||||
|
||||
@mock.patch('zadmin.tasks.bulk_validate_file')
|
||||
@mock.patch('olympia.zadmin.tasks.bulk_validate_file')
|
||||
def test_start(self, bulk_validate_file):
|
||||
new_max = self.appversion('3.7a3')
|
||||
r = self.client.post(reverse('zadmin.start_validation'),
|
||||
|
@ -238,7 +238,7 @@ class TestBulkValidation(BulkValidationTest):
|
|||
len(self.version.all_files))
|
||||
assert bulk_validate_file.delay.called
|
||||
|
||||
@mock.patch('zadmin.tasks.bulk_validate_file')
|
||||
@mock.patch('olympia.zadmin.tasks.bulk_validate_file')
|
||||
def test_ignore_user_disabled_addons(self, bulk_validate_file):
|
||||
self.addon.update(disabled_by_user=True)
|
||||
r = self.client.post(reverse('zadmin.start_validation'),
|
||||
|
@ -251,7 +251,7 @@ class TestBulkValidation(BulkValidationTest):
|
|||
self.assert3xx(r, reverse('zadmin.validation'))
|
||||
assert not bulk_validate_file.delay.called
|
||||
|
||||
@mock.patch('zadmin.tasks.bulk_validate_file')
|
||||
@mock.patch('olympia.zadmin.tasks.bulk_validate_file')
|
||||
def test_ignore_non_public_addons(self, bulk_validate_file):
|
||||
target_ver = self.appversion('3.7a3').id
|
||||
for status in (amo.STATUS_DISABLED, amo.STATUS_NULL,
|
||||
|
@ -268,7 +268,7 @@ class TestBulkValidation(BulkValidationTest):
|
|||
assert not bulk_validate_file.delay.called, (
|
||||
'Addon with status %s should be ignored' % status)
|
||||
|
||||
@mock.patch('zadmin.tasks.bulk_validate_file')
|
||||
@mock.patch('olympia.zadmin.tasks.bulk_validate_file')
|
||||
def test_ignore_lang_packs(self, bulk_validate_file):
|
||||
target_ver = self.appversion('3.7a3').id
|
||||
self.addon.update(type=amo.ADDON_LPAPP)
|
||||
|
@ -283,7 +283,7 @@ class TestBulkValidation(BulkValidationTest):
|
|||
assert not bulk_validate_file.delay.called, (
|
||||
'Lang pack addons should be ignored')
|
||||
|
||||
@mock.patch('zadmin.tasks.bulk_validate_file')
|
||||
@mock.patch('olympia.zadmin.tasks.bulk_validate_file')
|
||||
def test_ignore_themes(self, bulk_validate_file):
|
||||
target_ver = self.appversion('3.7a3').id
|
||||
self.addon.update(type=amo.ADDON_THEME)
|
||||
|
@ -295,7 +295,7 @@ class TestBulkValidation(BulkValidationTest):
|
|||
assert not bulk_validate_file.delay.called, (
|
||||
'Theme addons should be ignored')
|
||||
|
||||
@mock.patch('zadmin.tasks.bulk_validate_file')
|
||||
@mock.patch('olympia.zadmin.tasks.bulk_validate_file')
|
||||
def test_validate_all_non_disabled_addons(self, bulk_validate_file):
|
||||
target_ver = self.appversion('3.7a3').id
|
||||
bulk_validate_file.delay.called = False
|
||||
|
@ -505,7 +505,7 @@ class TestBulkUpdate(BulkValidationTest):
|
|||
eq_(mail.outbox[0].subject,
|
||||
'%s' % self.addon.name)
|
||||
|
||||
@mock.patch('zadmin.tasks.log')
|
||||
@mock.patch('olympia.zadmin.tasks.log')
|
||||
def test_bulk_email_logs_stats(self, log):
|
||||
log.info = mock.Mock()
|
||||
self.create_result(self.job, self.create_file(self.version))
|
||||
|
@ -743,7 +743,7 @@ class TestBulkValidationTask(BulkValidationTest):
|
|||
pass
|
||||
assert validate.call_args[1].get('compat_test')
|
||||
|
||||
@mock.patch('zadmin.tasks.run_validator')
|
||||
@mock.patch('olympia.zadmin.tasks.run_validator')
|
||||
def test_task_error(self, run_validator):
|
||||
run_validator.side_effect = RuntimeError('validation error')
|
||||
try:
|
||||
|
@ -761,7 +761,7 @@ class TestBulkValidationTask(BulkValidationTest):
|
|||
eq_(res.validation_job.stats['passing'], 0)
|
||||
eq_(res.validation_job.stats['failing'], 0)
|
||||
|
||||
@mock.patch('zadmin.tasks.run_validator')
|
||||
@mock.patch('olympia.zadmin.tasks.run_validator')
|
||||
def test_validate_for_appversions(self, run_validator):
|
||||
data = {
|
||||
"errors": 1,
|
||||
|
@ -781,7 +781,7 @@ class TestBulkValidationTask(BulkValidationTest):
|
|||
eq_(run_validator.call_args[1]['for_appversions'],
|
||||
{amo.FIREFOX.guid: [self.new_max.version]})
|
||||
|
||||
@mock.patch('zadmin.tasks.run_validator')
|
||||
@mock.patch('olympia.zadmin.tasks.run_validator')
|
||||
def test_validate_all_tiers(self, run_validator):
|
||||
run_validator.return_value = json.dumps(VALIDATOR_SKELETON_RESULTS)
|
||||
res = self.create_result(self.create_job(), self.create_file(), **{})
|
||||
|
@ -789,7 +789,7 @@ class TestBulkValidationTask(BulkValidationTest):
|
|||
assert run_validator.called
|
||||
eq_(run_validator.call_args[1]['test_all_tiers'], True)
|
||||
|
||||
@mock.patch('zadmin.tasks.run_validator')
|
||||
@mock.patch('olympia.zadmin.tasks.run_validator')
|
||||
def test_merge_with_compat_summary(self, run_validator):
|
||||
data = {
|
||||
"errors": 1,
|
||||
|
@ -1076,7 +1076,7 @@ class TestTallyValidationErrors(BulkValidationTest):
|
|||
rows = sorted((r for r in rdr), key=lambda r: r[0])
|
||||
return header, rows
|
||||
|
||||
@mock.patch('zadmin.tasks.run_validator')
|
||||
@mock.patch('olympia.zadmin.tasks.run_validator')
|
||||
def test_csv(self, run_validator):
|
||||
run_validator.return_value = json.dumps(self.data)
|
||||
self.start_validation()
|
||||
|
|
Загрузка…
Ссылка в новой задаче