diff --git a/.gitignore b/.gitignore index 5df2ffd6d6..f8d94c21f1 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/services/theme_update.py b/services/theme_update.py index 07a1eb7b8e..2978452fba 100644 --- a/services/theme_update.py +++ b/services/theme_update.py @@ -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. diff --git a/settings.py b/settings.py index bd62e66e72..ec28ac2dec 100644 --- a/settings.py +++ b/settings.py @@ -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. diff --git a/settings_test.py b/settings_test.py index 67267b45d7..395d63a700 100644 --- a/settings_test.py +++ b/settings_test.py @@ -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 diff --git a/src/olympia/abuse/tests/test_models.py b/src/olympia/abuse/tests/test_models.py index e589589d75..574ba0381f 100644 --- a/src/olympia/abuse/tests/test_models.py +++ b/src/olympia/abuse/tests/test_models.py @@ -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): diff --git a/src/olympia/accounts/tests/test_verify.py b/src/olympia/accounts/tests/test_verify.py index d8ffd902c1..203ecaafb5 100644 --- a/src/olympia/accounts/tests/test_verify.py +++ b/src/olympia/accounts/tests/test_verify.py @@ -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) diff --git a/src/olympia/accounts/tests/test_views.py b/src/olympia/accounts/tests/test_views.py index dd948fc4a0..26195cf2d6 100644 --- a/src/olympia/accounts/tests/test_views.py +++ b/src/olympia/accounts/tests/test_views.py @@ -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) diff --git a/src/olympia/addons/tests/test_buttons.py b/src/olympia/addons/tests/test_buttons.py index d1927187b1..ce31a88bc6 100644 --- a/src/olympia/addons/tests/test_buttons.py +++ b/src/olympia/addons/tests/test_buttons.py @@ -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('button') diff --git a/src/olympia/addons/tests/test_commands.py b/src/olympia/addons/tests/test_commands.py index 643b499035..599e7c35e2 100644 --- a/src/olympia/addons/tests/test_commands.py +++ b/src/olympia/addons/tests/test_commands.py @@ -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.""" diff --git a/src/olympia/addons/tests/test_cron.py b/src/olympia/addons/tests/test_cron.py index 4f0284c564..562b9064e5 100644 --- a/src/olympia/addons/tests/test_cron.py +++ b/src/olympia/addons/tests/test_cron.py @@ -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 diff --git a/src/olympia/addons/tests/test_decorators.py b/src/olympia/addons/tests/test_decorators.py index 6186f30eb7..e04a5154c2 100644 --- a/src/olympia/addons/tests/test_decorators.py +++ b/src/olympia/addons/tests/test_decorators.py @@ -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.""" diff --git a/src/olympia/addons/tests/test_forms.py b/src/olympia/addons/tests/test_forms.py index 7bcee7da5d..ed68f382f7 100644 --- a/src/olympia/addons/tests/test_forms.py +++ b/src/olympia/addons/tests/test_forms.py @@ -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', diff --git a/src/olympia/addons/tests/test_models.py b/src/olympia/addons/tests/test_models.py index 82e63626d6..40fe4d9739 100644 --- a/src/olympia/addons/tests/test_models.py +++ b/src/olympia/addons/tests/test_models.py @@ -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 = 'test' @@ -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) diff --git a/src/olympia/addons/tests/test_theme_update.py b/src/olympia/addons/tests/test_theme_update.py index ea3dd12fcb..f8648966d3 100644 --- a/src/olympia/addons/tests/test_theme_update.py +++ b/src/olympia/addons/tests/test_theme_update.py @@ -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): diff --git a/src/olympia/addons/tests/test_update.py b/src/olympia/addons/tests/test_update.py index de12e61f3c..dbfae32b73 100644 --- a/src/olympia/addons/tests/test_update.py +++ b/src/olympia/addons/tests/test_update.py @@ -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): diff --git a/src/olympia/addons/tests/test_views.py b/src/olympia/addons/tests/test_views.py index ef3083fbbd..96d43f28eb 100644 --- a/src/olympia/addons/tests/test_views.py +++ b/src/olympia/addons/tests/test_views.py @@ -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 diff --git a/src/olympia/amo/tests/__init__.py b/src/olympia/amo/tests/__init__.py index 1e907771fb..4681205e43 100644 --- a/src/olympia/amo/tests/__init__.py +++ b/src/olympia/amo/tests/__init__.py @@ -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. diff --git a/src/olympia/amo/tests/test_amo_utils.py b/src/olympia/amo/tests/test_amo_utils.py index 85afb7fd96..bf6118826a 100644 --- a/src/olympia/amo/tests/test_amo_utils.py +++ b/src/olympia/amo/tests/test_amo_utils.py @@ -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' diff --git a/src/olympia/amo/tests/test_decorators.py b/src/olympia/amo/tests/test_decorators.py index fe6d16ec70..7198a602c3 100644 --- a/src/olympia/amo/tests/test_decorators.py +++ b/src/olympia/amo/tests/test_decorators.py @@ -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) diff --git a/src/olympia/amo/tests/test_helpers.py b/src/olympia/amo/tests/test_helpers.py index 404a2fe8a7..9a7ea5740d 100644 --- a/src/olympia/amo/tests/test_helpers.py +++ b/src/olympia/amo/tests/test_helpers.py @@ -162,7 +162,7 @@ class TestBreadcrumbs(amo.tests.BaseTestCase): assert '