def test_basket_data_is_used_for_initial_checkbox_state(self): # When using basket, what's in the database is ignored for the # notification create_switch('activate-basket-sync') notification_id = REMOTE_NOTIFICATIONS_BY_BASKET_ID['about-addons'].id # Add some old obsolete data in the database for a notification that # is handled by basket: it should be ignored. UserNotification.objects.create(user=self.user, notification_id=notification_id, enabled=True) with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': [] } form = UserEditForm({}, instance=self.user, request=RequestFactory().get('/users/edit/')) request_call.assert_called_with( 'get', 'lookup-user', headers={'x-api-key': 'testkey'}, params={'email': u'*****@*****.**'}) assert notification_id not in form.fields['notifications'].initial
def test_basket_data_is_used_for_initial_checkbox_state(self): # When using basket, what's in the database is ignored for the # notification create_switch('activate-basket-sync') notification_id = REMOTE_NOTIFICATIONS_BY_BASKET_ID['about-addons'].id # Add some old obsolete data in the database for a notification that # is handled by basket: it should be ignored. UserNotification.objects.create( user=self.user, notification_id=notification_id, enabled=True) with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': []} form = UserEditForm( {}, instance=self.user, request=RequestFactory().get('/users/edit/')) request_call.assert_called_with( 'get', 'lookup-user', headers={'x-api-key': 'testkey'}, params={'email': u'*****@*****.**'}) assert notification_id not in form.fields['notifications'].initial
def test_webextension_boost(self): create_switch('boost-webextensions-in-search') # Repeat base test with the switch enabled. qs = self._test_q() functions = qs['query']['function_score']['functions'] assert len(functions) == 2 assert functions[1] == { 'weight': 2.0, # WEBEXTENSIONS_WEIGHT, 'filter': { 'bool': { 'should': [{ 'term': { 'current_version.files.is_webextension': True } }, { 'term': { 'current_version.files.is_mozilla_signed_extension': True } }] } } }
def test_only_show_notifications_user_has_permission_to(self): create_switch('activate-basket-sync') with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': []} form = UserEditForm({}, instance=self.user) request_call.assert_called_with( 'get', 'lookup-user', headers={'x-api-key': 'testkey'}, params={'email': u'*****@*****.**'}) # It needs a developer account to subscribe to a newsletter # So the `announcements` notification is not among the valid choices # This isn't really user visible since the user doesn't have # the ability to choose newsletters he doesn't have permissions # to see. assert len(form.fields['notifications'].choices) == 2 assert form.fields['notifications'].choices[0][0] == 3 assert form.fields['notifications'].choices[1][0] == 4 addon_factory(users=[self.user]) # Clear cache del self.user.is_developer form = UserEditForm({}, instance=self.user) assert len(form.fields['notifications'].choices) == 10 assert [x[0] for x in form.fields['notifications'].choices] == [ 3, 4, 5, 6, 7, 9, 10, 11, 12, 8 ]
def test_basket_unsubscribe_newsletter(self): create_switch('activate-basket-sync') with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': ['announcements']} form = UserEditForm( {}, instance=self.user, request=RequestFactory().get('/users/edit/')) request_call.assert_called_with( 'get', 'lookup-user', headers={'x-api-key': 'testkey'}, params={'email': u'*****@*****.**'}) with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': []} assert form.is_valid() form.save() request_call.assert_called_with( 'post', 'unsubscribe', data={ 'newsletters': 'about-addons', 'email': u'*****@*****.**'}, token='123')
def setUp(self): super(TestAccountSuperCreate, self).setUp() create_switch('super-create-accounts', active=True) self.create_api_user() self.url = reverse('accounts.super-create') group = Group.objects.create(name='Account Super Creators', rules='Accounts:SuperCreate') GroupUser.objects.create(group=group, user=self.user)
def test_bump_version_in_manifest_json(file_obj): create_switch('webextensions') with amo.tests.copy_file( 'src/olympia/files/fixtures/files/webextension.xpi', file_obj.file_path): utils.update_version_number(file_obj, '0.0.1.1-signed') parsed = utils.parse_xpi(file_obj.file_path) assert parsed['version'] == '0.0.1.1-signed'
def setUp(self): super(TestAccountSuperCreate, self).setUp() create_switch('super-create-accounts', active=True) self.create_api_user() self.url = reverse('accounts.super-create') group = Group.objects.create( name='Account Super Creators', rules='Accounts:SuperCreate') GroupUser.objects.create(group=group, user=self.user)
def test_allow_static_theme_waffle(self): create_switch('allow-static-theme-uploads') manifest = utils.ManifestJSONExtractor( '/fake_path', '{"theme": {}}').parse() utils.check_xpi_info(manifest) assert self.parse({'theme': {}})['type'] == amo.ADDON_STATICTHEME
def test_extract_version_to_git_with_cron_enabled_and_force_extraction(): addon = addon_factory(file_kw={'filename': 'webextension_no_id.xpi'}) repo = AddonGitRepository(addon.pk) create_switch('enable-git-extraction-cron') assert GitExtractionEntry.objects.count() == 0 extract_version_to_git(addon.current_version.pk, force_extraction=True) assert GitExtractionEntry.objects.count() == 0 assert repo.is_extracted
def create_superuser(transactional_db, my_base_url, tmpdir, variables): create_switch('super-create-accounts') call_command('loaddata', 'initial.json') call_command('createsuperuser', interactive=False, username='******', email='*****@*****.**', add_to_supercreate_group=True, save_api_credentials=str(tmpdir.join('variables.json')), hostname=urlparse.urlsplit(my_base_url).hostname) with tmpdir.join('variables.json').open() as f: variables.update(json.load(f))
def test_webextension_boost(self): public_addons = Addon.objects.public().all() web_extension = public_addons.order_by('name')[0] web_extension.current_version.files.update(is_webextension=True) web_extension.save() self.refresh() data = self.search_addons('q=Addon', public_addons) assert int(data[0]['id']) != web_extension.id create_switch('boost-webextensions-in-search') # The boost chosen should have made that addon the first one. data = self.search_addons('q=Addon', public_addons) assert int(data[0]['id']) == web_extension.id
def test_handle_limits_the_number_of_entries_to_process(self): create_switch(SWITCH_NAME, active=True) GitExtractionEntry.objects.create(addon=self.addon) # Create a duplicate add-on. GitExtractionEntry.objects.create(addon=self.addon) # Create another add-on. e3 = GitExtractionEntry.objects.create(addon=addon_factory()) e4 = GitExtractionEntry.objects.create(addon=addon_factory()) self.command.extract_addon = mock.Mock() self.command.handle(None, limit=2) self.command.extract_addon.assert_has_calls( [mock.call(e4), mock.call(e3)]) assert self.command.extract_addon.call_count == 2
def test_handle_calls_extract_addon_for_each_addon_in_queue(self): create_switch(SWITCH_NAME, active=True) e1 = GitExtractionEntry.objects.create(addon=self.addon) # Create a duplicate add-on. e2 = GitExtractionEntry.objects.create(addon=self.addon) # Create another add-on. e3 = GitExtractionEntry.objects.create(addon=addon_factory()) self.command.extract_addon = mock.Mock() self.command.handle() self.command.extract_addon.assert_has_calls( [mock.call(e3), mock.call(e2), mock.call(e1)]) assert self.command.extract_addon.call_count == 3
def test_webextension_boost(self): web_extension = self.addons[2] web_extension.current_version.files.update(is_webextension=True) web_extension.save() self.refresh() response = self.client.get(self.url, {'q': 'addon'}) result = self.get_results(response, sort=False) assert result[0] != web_extension.pk create_switch('boost-webextensions-in-search') # The boost chosen should have made that addon the first one. response = self.client.get(self.url, {'q': 'addon'}) result = self.get_results(response, sort=False) assert result[0] == web_extension.pk
def create_superuser(transactional_db, my_base_url, tmpdir, variables): """Creates a superuser.""" create_switch('super-create-accounts') call_command('loaddata', 'initial.json') call_command( 'createsuperuser', interactive=False, username='******', email='*****@*****.**', add_to_supercreate_group=True, save_api_credentials=str(tmpdir.join('variables.json')), hostname=urlparse.urlsplit(my_base_url).hostname ) with tmpdir.join('variables.json').open() as f: variables.update(json.load(f))
def test_webextension_boost(self): web_extension = list(sorted( self.addons, key=lambda x: x.name, reverse=True))[0] web_extension.current_version.files.update(is_webextension=True) web_extension.save() self.refresh() response = self.client.get(self.url, {'q': 'Addon'}) result = self.get_results(response, sort=False) assert result[0] != web_extension.pk create_switch('boost-webextensions-in-search') # The boost chosen should have made that addon the first one. response = self.client.get(self.url, {'q': 'Addon'}) result = self.get_results(response, sort=False) assert result[0] == web_extension.pk
def test_webextension_boost(self): create_switch('boost-webextensions-in-search') # Repeat base test with the switch enabled. qs = self._test_q() functions = qs['query']['function_score']['functions'] assert len(functions) == 2 assert functions[1] == { 'weight': 2.0, # WEBEXTENSIONS_WEIGHT, 'filter': {'bool': {'should': [ {'term': {'current_version.files.is_webextension': True}}, {'term': { 'current_version.files.is_mozilla_signed_extension': True }} ]}} }
def test_basket_subscribe_newsletter(self): create_switch('activate-basket-sync') addon_factory(users=[self.user]) with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': [] } # 8 is the `announcements` notification, or about-addons newsletter form = UserEditForm({'notifications': [3, 4, 8]}, instance=self.user, request=RequestFactory().get('/users/edit/')) request_call.assert_called_with( 'get', 'lookup-user', headers={'x-api-key': 'testkey'}, params={'email': u'*****@*****.**'}) with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': ['about-addons'] } assert form.is_valid() form.save() request_call.assert_called_with('post', 'subscribe', headers={'x-api-key': 'testkey'}, data={ 'newsletters': 'about-addons', 'sync': 'Y', 'optin': 'Y', 'source_url': 'http://testserver/users/edit/', 'email': u'*****@*****.**' })
def test_basket_unsubscribe_newsletter_no_basket_user(self): """ Test that unsubscribing from a newsletter if user didn't exist yet """ create_switch('activate-basket-sync') with patch('basket.base.request', autospec=True) as request_call: request_call.side_effect = basket.base.BasketException( 'description', status_code=401, code=basket.errors.BASKET_UNKNOWN_EMAIL) UserEditForm( {}, instance=self.user, request=RequestFactory().get('/users/edit/')) request_call.assert_called_with( 'get', 'lookup-user', headers={'x-api-key': 'testkey'}, params={'email': u'*****@*****.**'})
def test_basket_unsubscribe_newsletter_no_basket_user(self): """ Test that unsubscribing from a newsletter if user didn't exist yet """ create_switch('activate-basket-sync') with patch('basket.base.request', autospec=True) as request_call: request_call.side_effect = basket.base.BasketException( 'description', status_code=401, code=basket.errors.BASKET_UNKNOWN_EMAIL) UserEditForm({}, instance=self.user, request=RequestFactory().get('/users/edit/')) request_call.assert_called_with( 'get', 'lookup-user', headers={'x-api-key': 'testkey'}, params={'email': u'*****@*****.**'})
def test_handle_entries_with_same_created_date(self): create_switch(SWITCH_NAME, active=True) created = datetime.datetime(2020, 7, 5) # First entry inserted for the add-on. GitExtractionEntry.objects.create(addon=self.addon, created=created) # Second entry inserted for the add-on. GitExtractionEntry.objects.create(addon=self.addon, created=created) # Third entry inserted for the add-on but this one has # `in_progress=False` to simulate a previous execution of the task. # Without the right `order` value, other entries might be processed # instead of this one. e1_3 = GitExtractionEntry.objects.create(addon=self.addon, created=created, in_progress=False) self.command.extract_addon = mock.Mock() self.command.handle(None, limit=2) self.command.extract_addon.assert_has_calls( [mock.call(e1_3), mock.call(mock.ANY)]) assert self.command.extract_addon.call_count == 2
def test_basket_unsubscribe_newsletter(self): create_switch('activate-basket-sync') with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': ['announcements'] } form = UserEditForm({}, instance=self.user, request=RequestFactory().get('/users/edit/')) request_call.assert_called_with( 'get', 'lookup-user', headers={'x-api-key': 'testkey'}, params={'email': u'*****@*****.**'}) with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': [] } assert form.is_valid() form.save() request_call.assert_called_with('post', 'unsubscribe', data={ 'newsletters': 'about-addons', 'email': u'*****@*****.**' }, token='123')
def test_basket_subscribe_newsletter(self): create_switch('activate-basket-sync') addon_factory(users=[self.user]) with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': []} # 8 is the `announcements` notification, or about-addons newsletter form = UserEditForm( {'notifications': [3, 4, 8]}, instance=self.user, request=RequestFactory().get('/users/edit/')) request_call.assert_called_with( 'get', 'lookup-user', headers={'x-api-key': 'testkey'}, params={'email': u'*****@*****.**'}) with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': ['about-addons']} assert form.is_valid() form.save() request_call.assert_called_with( 'post', 'subscribe', headers={'x-api-key': 'testkey'}, data={ 'newsletters': 'about-addons', 'sync': 'Y', 'optin': 'Y', 'source_url': 'http://testserver/users/edit/', 'email': u'*****@*****.**'})
def test_only_show_notifications_user_has_permission_to(self): create_switch('activate-basket-sync') with patch('basket.base.request', autospec=True) as request_call: request_call.return_value = { 'status': 'ok', 'token': '123', 'newsletters': [] } form = UserEditForm({}, instance=self.user) request_call.assert_called_with( 'get', 'lookup-user', headers={'x-api-key': 'testkey'}, params={'email': u'*****@*****.**'}) # It needs a developer account to subscribe to a newsletter # So the `announcements` notification is not among the valid choices # This isn't really user visible since the user doesn't have # the ability to choose newsletters he doesn't have permissions # to see. assert len(form.fields['notifications'].choices) == 2 assert form.fields['notifications'].choices[0][0] == 3 assert form.fields['notifications'].choices[1][0] == 4 addon_factory(users=[self.user]) # Clear cache del self.user.is_developer form = UserEditForm({}, instance=self.user) assert len(form.fields['notifications'].choices) == 10 assert [x[0] for x in form.fields['notifications'].choices ] == [3, 4, 5, 6, 7, 9, 10, 11, 12, 8]
def setUp(self): super(TestIndexCommandClassicAlgorithm, self).setUp() create_switch('es-use-classic-similarity')
def setUp(self): super(TestTaskQueued, self).setUp() create_switch('activate-django-post-request') fake_task_func.reset_mock() _discard_tasks()
def setUpTestData(cls): # For simplicity reasons, let's simply use the new algorithm # we're most certainly going to put live anyway # Also, this needs to be created before `setUpTestData` # since we need that setting on index-creation time. create_switch('es-use-classic-similarity') super(TestRankingScenarios, cls).setUpTestData() # Shouldn't be necessary, but just in case. cls.empty_index('default') # This data was taken from our production add-ons to test # a few search scenarios. (2018-01-25) # Note that it's important to set average_daily_users for extensions # and weekly_downloads for themes (personas) in every case, because it # affects the ranking score and otherwise addon_factory() sets a random # value. amo.tests.addon_factory( average_daily_users=18981, description=None, name='Tab Center Redux', slug=u'tab-center-redux', summary='Move your tabs to the side of your browser window.', weekly_downloads=915) amo.tests.addon_factory( average_daily_users=468126, description=None, name='Tab Mix Plus', slug=u'tab-mix-plus', summary=( 'Tab Mix Plus enhances Firefox\'s tab browsing capabilities. ' 'It includes such features as duplicating tabs, controlling ' 'tab focus, tab clicking options, undo closed tabs and ' 'windows, plus much more. It also includes a full-featured ' 'session manager.'), weekly_downloads=3985) amo.tests.addon_factory( average_daily_users=8838, description=None, name='Redux DevTools', slug=u'remotedev', summary=( 'DevTools for Redux with actions history, undo and replay.'), weekly_downloads=1032) amo.tests.addon_factory( average_daily_users=482, description=None, name='Open Image in New Tab', slug=u'open-image-new-tab', summary='Adds a context menu to open images in a new tab.', weekly_downloads=158) amo.tests.addon_factory( average_daily_users=2607, description=None, name='Open image in a new tab', slug=u'open-image-in-a-new-tab', summary='A context menu to open images in a new tab', weekly_downloads=329) amo.tests.addon_factory( average_daily_users=27832, description=None, name='Open Bookmarks in New Tab', slug=u'open-bookmarks-in-new-tab', summary=( 'After you installed this addon to your Firefox, bookmarks ' 'are opened in new tab always.'), weekly_downloads=145) amo.tests.addon_factory( average_daily_users=528, description=None, name='Coinhive Blocker', slug=u'coinhive-blocker', summary='Coinhive mining blocker', weekly_downloads=132) amo.tests.addon_factory( average_daily_users=3015, description=None, name='CoinBlock', slug=u'coinblock', summary=( 'With the rising popularity of coinminers in js form, this ' 'extension attempts to block those hosted on coin-hive, and ' 'cryptoloot.\nA multiple entry block list is planned.'), weekly_downloads=658) amo.tests.addon_factory( average_daily_users=418, description=None, name='NoMiners', slug=u'nominers', summary=( 'NoMiners is an Add-on that tries to block cryptominers such ' 'as coinhive.\n\nBlocking those pesky miner scripts will ' 'relieve your CPU and BATTERY while browsing the web.' '\n\nIt\'s open source, so feel free to check out the code ' 'and submit improvements.'), weekly_downloads=71) amo.tests.addon_factory( average_daily_users=399485, description=None, name='Privacy Badger', slug=u'privacy-badger17', summary=( 'Protects your privacy by blocking spying ads and invisible ' 'trackers.'), weekly_downloads=22931) amo.tests.addon_factory( average_daily_users=8728, description=None, name='Privacy Pass', slug=u'privacy-pass', summary=( 'Handles passes containing cryptographically blinded tokens ' 'for bypassing challenge pages.'), weekly_downloads=4599) amo.tests.addon_factory( average_daily_users=15406, description=None, name='Privacy Settings', slug=u'privacy-settings', summary=( 'Alter Firefox\'s built-in privacy settings easily with a ' 'toolbar panel.'), weekly_downloads=1492) amo.tests.addon_factory( average_daily_users=12857, description=None, name='Google Privacy', slug=u'google-privacy', summary=( 'Make some popular websites respect your privacy settings.\n' 'Please see the known issues below!'), weekly_downloads=117) amo.tests.addon_factory( average_daily_users=70553, description=None, name='Blur', slug=u'donottrackplus', summary='Protect your Passwords, Payments, and Privacy.', weekly_downloads=2224) amo.tests.addon_factory( average_daily_users=1009156, description=None, name='Ghostery', slug=u'ghostery', summary=( u'See who’s tracking you online and protect your privacy with ' u'Ghostery.'), weekly_downloads=49315) amo.tests.addon_factory( average_daily_users=954288, description=None, name='Firebug', slug=u'firebug', summary=( 'Firebug integrates with Firefox to put a wealth of ' 'development tools at your fingertips while you browse. You ' 'can edit, debug, and monitor CSS, HTML, and JavaScript live ' 'in any web page...'), weekly_downloads=21969) amo.tests.addon_factory( average_daily_users=10821, description=None, name='Firebug Autocompleter', slug=u'firebug-autocompleter', summary='Firebug command line autocomplete.', weekly_downloads=76) amo.tests.addon_factory( average_daily_users=11992, description=None, name='Firefinder for Firebug', slug=u'firefinder-for-firebug', summary=( 'Finds HTML elements matching chosen CSS selector(s) or XPath ' 'expression'), weekly_downloads=358) amo.tests.addon_factory( average_daily_users=8200, description=None, name='Fire Drag', slug=u'fire-drag', summary='drag texts and links with/without e10s', weekly_downloads=506) amo.tests.addon_factory( average_daily_users=61014, description=None, name='Menu Wizard', slug=u's3menu-wizard', summary=( 'Customizemenus=Helps removing, moving and renaming menus and ' 'menu items\nColorize important menu for ease of use! (use ' 'Style (CSS))\nChange or disable any of used keyboard ' 'shortcutsnSuppor=Firefox, Thunderbird and SeaMonkey'), weekly_downloads=927) amo.tests.addon_factory( average_daily_users=81237, description=None, name='Add-ons Manager Context Menu', slug=u'am-context', summary='Add more items to Add-ons Manager context menu.', weekly_downloads=169) amo.tests.addon_factory( average_daily_users=51, description=None, name='Frame Demolition', slug=u'frame-demolition', summary=( 'Enabling route to load abstracted file layer in select ' 'sites.'), weekly_downloads=70) amo.tests.addon_factory( average_daily_users=99, description=None, name='reStyle', slug=u're-style', summary=( 'A user style manager which can load local files and apply UI ' 'styles even in Firefox 57+'), weekly_downloads=70) amo.tests.addon_factory( average_daily_users=150, description=None, name='MegaUpload DownloadHelper', slug=u'megaupload-downloadhelper', summary=( 'Download from MegaUpload.\nMegaUpload Download Helper will ' 'start your download once ready.\nMegaUpload Download Helper ' 'will monitor time limitations and will auto-start your ' 'download.'), weekly_downloads=77) amo.tests.addon_factory( average_daily_users=2830, description=None, name='RapidShare DownloadHelper', slug=u'rapidshare-downloadhelper', summary=( 'Note from Mozilla: This add-on has been discontinued. Try ' '<a rel="nofollow" href="https://addons.mozilla.org/firefox/' 'addon/rapidshare-helper/">Rapidshare Helper</a> instead.\n\n' 'RapidShare Download Helper will start your download once ' 'ready.'), weekly_downloads=125) amo.tests.addon_factory( average_daily_users=98716, description=None, name='Popup Blocker', slug=u'popup_blocker', summary=( 'Prevents your web browser from opening a new window on top ' 'of the content or web site you are viewing. The Addon also ' 'supresses unwanted advertisement windows on your screen. ' 'The one deciding what consitutes a popup is the user.'), weekly_downloads=3940) amo.tests.addon_factory( average_daily_users=8830, description=None, name='No Flash', slug=u'no-flash', summary=( 'Replace Youtube, Vimeo and Dailymotion Flash video players ' 'embedded on third-party website by the HTML5 counterpart ' 'when the content author still use the old style embed ' '(Flash).\n\nSource code at <a rel="nofollow" href="https://' 'outgoing.prod.mozaws.net/v1/14b404a3c05779fa94b24e0bffc0d710' '6836f1d6b771367b065fb96e9c8656b9/https%3A//github.com/hfigui' 'ere/no-flash">https://github.com/hfiguiere/no-flash</a>'), weekly_downloads=77) amo.tests.addon_factory( average_daily_users=547880, description=None, name='Download Flash and Video', slug=u'download-flash-and-video', summary=( 'Download Flash and Video is a great download helper tool ' 'that lets you download Flash games and Flash videos ' '(YouTube, Facebook, Dailymotion, Google Videos and more) ' 'with a single click.\nThe downloader is very easy to use.'), weekly_downloads=65891) amo.tests.addon_factory( average_daily_users=158796, description=None, name='YouTube Flash Video Player', slug=u'youtube-flash-video-player', summary=( 'YouTube Flash Video Player is a powerful tool that will let ' 'you choose Flash video player as default YouTube video ' 'player.'), weekly_downloads=12239) amo.tests.addon_factory( average_daily_users=206980, description=None, name='YouTube Flash Player', slug=u'youtube-flash-player', summary=( u'A very lightweight add-on that allows you to watch YouTube™ ' u'videos using Flash® Player instead of the ' u'default HTML5 player. The Flash® Player will consume less ' u'CPU and RAM resources if your device doesn\'t easily ' u'support HTML5 videos. Try it!'), weekly_downloads=21882) amo.tests.addon_factory( average_daily_users=5056, description=None, name='Disable Hello, Pocket & Reader+', slug=u'disable-hello-pocket-reader', summary=( 'Turn off Pocket, Reader, Hello and WebRTC bloatware - keep ' 'browser fast and clean'), weekly_downloads=85) amo.tests.addon_factory( average_daily_users=26135, description=None, name='Reader', slug=u'reader', summary='Reader is the ultimate Reader tool for Firefox.', weekly_downloads=2463) amo.tests.addon_factory( average_daily_users=53412, description=None, name='Disable WebRTC', slug=u'happy-bonobo-disable-webrtc', summary=( 'WebRTC leaks your actual IP addresses from behind your VPN, ' 'by default.'), weekly_downloads=10583) amo.tests.addon_factory( average_daily_users=12953, description=None, name='In My Pocket', slug=u'in-my-pocket', summary=( 'For all those who are missing the old Firefox Pocket addon, ' 'and not satisfied with the new Pocket integration, here is ' 'an unofficial client for the excellent Pocket service. ' 'Hope you\'ll enjoy it!'), weekly_downloads=1123) amo.tests.addon_factory( average_daily_users=4089, description=None, name='Tabby Cat', slug=u'tabby-cat-friend', summary='A new friend in every new tab.', weekly_downloads=350) amo.tests.addon_factory( average_daily_users=5819, description=None, name='Authenticator', slug=u'auth-helper', summary=( 'Authenticator generates 2-Step Verification codes in your' ' browser.'), weekly_downloads=500) amo.tests.addon_factory( average_daily_users=74094, description=None, name='OneTab', slug=u'onetab', summary=( 'OneTab - Too many tabs? Convert tabs to a list and reduce ' 'browser memory'), weekly_downloads=3249) amo.tests.addon_factory( average_daily_users=14968, description=None, name='FoxyTab', slug=u'foxytab', summary=( 'Collection of Tab Related Actions Lorem ipsum dolor sit ' 'amet, mea dictas corpora aliquando te. Et pri docendi ' 'fuisset petentium, ne aeterno concludaturque usu, vide ' 'modus quidam per ex. Illum tempor duo eu, ut mutat noluisse ' 'consulatu vel.'), weekly_downloads=700) amo.tests.addon_factory( average_daily_users=3064, description=None, name='Simple WebSocket Client', slug=u'in-my-pocket', summary=( u'Construct custom Web Socket requests and handle responses ' u'to directly test your Web Socket services.')) amo.tests.addon_factory( name='GrApple Yummy', type=amo.ADDON_EXTENSION, average_daily_users=1, weekly_downloads=1, summary=None) amo.tests.addon_factory( name='Delicious Bookmarks', type=amo.ADDON_EXTENSION, average_daily_users=1, weekly_downloads=1, summary=None) amo.tests.addon_factory( average_daily_users=101940, description=None, name='Personas Plus', slug=u'personas-plus', summary=u'Persona Plus') # Some more or less Dummy data to test a few very specific scenarios # e.g for exact name matching amo.tests.addon_factory( name='Merge Windows', type=amo.ADDON_EXTENSION, average_daily_users=1, weekly_downloads=1, summary=None) amo.tests.addon_factory( name='Merge All Windows', type=amo.ADDON_EXTENSION, average_daily_users=1, weekly_downloads=1, summary=None) amo.tests.addon_factory( name='All Downloader Professional', type=amo.ADDON_EXTENSION, average_daily_users=1, weekly_downloads=1, summary=None) amo.tests.addon_factory( name='test addon test11', type=amo.ADDON_EXTENSION, average_daily_users=1, weekly_downloads=1, summary=None) amo.tests.addon_factory( name='test addon test21', type=amo.ADDON_EXTENSION, average_daily_users=1, weekly_downloads=1, summary=None) amo.tests.addon_factory( name='test addon test31', type=amo.ADDON_EXTENSION, average_daily_users=1, weekly_downloads=1, summary=None, description='I stole test addon test21 name for my description!') names = { 'fr': 'Foobar unique francais', 'en-US': 'Foobar unique english', } amo.tests.addon_factory( name=names, type=amo.ADDON_EXTENSION, default_locale='fr', slug='test-addon-test-special', average_daily_users=1, weekly_downloads=1, summary=None) amo.tests.addon_factory( name='1-Click YouTube Video Download', type=amo.ADDON_EXTENSION, average_daily_users=566337, weekly_downloads=150000, summary=None, description=( 'This addon contains Amazon 1-Click Lock in its description ' ' but not in its name.')), amo.tests.addon_factory( name='Amazon 1-Click Lock', type=amo.ADDON_EXTENSION, average_daily_users=50, weekly_downloads=1, summary=None) cls.refresh()
def test_login_404_when_waffle_is_off(self): create_switch('fxa-auth', active=False) response = self.client.post(self.login_url) assert response.status_code == 404
def test_register_422_when_waffle_is_on(self): create_switch('fxa-auth', active=True) response = self.client.post(self.register_url) assert response.status_code == 422
def test_handle_tries_to_acquire_lock(self, lock_mock): create_switch(SWITCH_NAME, active=True) self.command.handle() lock_mock.assert_called()
def setUp(self): self.url = reverse(self.view_name) create_switch('fxa-auth', active=True) self.fxa_identify = self.patch( 'olympia.accounts.views.verify.fxa_identify')
def test_source_404_when_waffle_is_off(self): create_switch('fxa-auth', active=False) response = self.client.get(self.source_url) assert response.status_code == 404
def setUp(self): create_switch('fxa-auth', active=True)
def test_source_200_when_waffle_is_on(self): create_switch('fxa-auth', active=True) response = self.client.get(self.source_url, {'email': '*****@*****.**'}) assert response.status_code == 200
def setUp(self): create_switch('activate-autograph-signing') super(TestPackagedAutograph, self).setUp()
def test_handle_does_not_run_if_switch_is_not_active(self, lock_mock): create_switch(SWITCH_NAME, active=False) self.command.handle() lock_mock.assert_not_called()
def setUpTestData(cls): # For simplicity reasons, let's simply use the new algorithm # we're most certainly going to put live anyway # Also, this needs to be created before `setUpTestData` # since we need that setting on index-creation time. create_switch('es-use-classic-similarity') super(TestRankingScenarios, cls).setUpTestData() # Shouldn't be necessary, but just in case. cls.empty_index('default') # This data was taken from our production add-ons to test # a few search scenarios. (2018-01-25) # Note that it's important to set average_daily_users in every case, # because it affects the ranking score and otherwise addon_factory() # sets a random value. amo.tests.addon_factory( average_daily_users=18981, description=None, name='Tab Center Redux', slug=u'tab-center-redux', summary='Move your tabs to the side of your browser window.', weekly_downloads=915) amo.tests.addon_factory( average_daily_users=468126, description=None, name='Tab Mix Plus', slug=u'tab-mix-plus', summary=( 'Tab Mix Plus enhances Firefox\'s tab browsing capabilities. ' 'It includes such features as duplicating tabs, controlling ' 'tab focus, tab clicking options, undo closed tabs and ' 'windows, plus much more. It also includes a full-featured ' 'session manager.'), weekly_downloads=3985) amo.tests.addon_factory( average_daily_users=8838, description=None, name='Redux DevTools', slug=u'remotedev', summary=( 'DevTools for Redux with actions history, undo and replay.'), weekly_downloads=1032) amo.tests.addon_factory( average_daily_users=482, description=None, name='Open Image in New Tab', slug=u'open-image-new-tab', summary='Adds a context menu to open images in a new tab.', weekly_downloads=158) amo.tests.addon_factory( average_daily_users=2607, description=None, name='Open image in a new tab', slug=u'open-image-in-a-new-tab', summary='A context menu to open images in a new tab', weekly_downloads=329) amo.tests.addon_factory( average_daily_users=27832, description=None, name='Open Bookmarks in New Tab', slug=u'open-bookmarks-in-new-tab', summary=( 'After you installed this addon to your Firefox, bookmarks ' 'are opened in new tab always.'), weekly_downloads=145) amo.tests.addon_factory(average_daily_users=528, description=None, name='Coinhive Blocker', slug=u'coinhive-blocker', summary='Coinhive mining blocker', weekly_downloads=132) amo.tests.addon_factory( average_daily_users=3015, description=None, name='CoinBlock', slug=u'coinblock', summary=( 'With the rising popularity of coinminers in js form, this ' 'extension attempts to block those hosted on coin-hive, and ' 'cryptoloot.\nA multiple entry block list is planned.'), weekly_downloads=658) amo.tests.addon_factory( average_daily_users=418, description=None, name='NoMiners', slug=u'nominers', summary=( 'NoMiners is an Add-on that tries to block cryptominers such ' 'as coinhive.\n\nBlocking those pesky miner scripts will ' 'relieve your CPU and BATTERY while browsing the web.' '\n\nIt\'s open source, so feel free to check out the code ' 'and submit improvements.'), weekly_downloads=71) amo.tests.addon_factory( average_daily_users=399485, description=None, name='Privacy Badger', slug=u'privacy-badger17', summary=( 'Protects your privacy by blocking spying ads and invisible ' 'trackers.'), weekly_downloads=22931) amo.tests.addon_factory( average_daily_users=8728, description=None, name='Privacy Pass', slug=u'privacy-pass', summary=( 'Handles passes containing cryptographically blinded tokens ' 'for bypassing challenge pages.'), weekly_downloads=4599) amo.tests.addon_factory( average_daily_users=15406, description=None, name='Privacy Settings', slug=u'privacy-settings', summary=( 'Alter Firefox\'s built-in privacy settings easily with a ' 'toolbar panel.'), weekly_downloads=1492) amo.tests.addon_factory( average_daily_users=12857, description=None, name='Google Privacy', slug=u'google-privacy', summary=( 'Make some popular websites respect your privacy settings.\n' 'Please see the known issues below!'), weekly_downloads=117) amo.tests.addon_factory( average_daily_users=70553, description=None, name='Blur', slug=u'donottrackplus', summary='Protect your Passwords, Payments, and Privacy.', weekly_downloads=2224) amo.tests.addon_factory( average_daily_users=1009156, description=None, name='Ghostery', slug=u'ghostery', summary=( u'See who’s tracking you online and protect your privacy with ' u'Ghostery.'), weekly_downloads=49315) amo.tests.addon_factory( average_daily_users=954288, description=None, name='Firebug', slug=u'firebug', summary=( 'Firebug integrates with Firefox to put a wealth of ' 'development tools at your fingertips while you browse. You ' 'can edit, debug, and monitor CSS, HTML, and JavaScript live ' 'in any web page...'), weekly_downloads=21969) amo.tests.addon_factory(average_daily_users=10821, description=None, name='Firebug Autocompleter', slug=u'firebug-autocompleter', summary='Firebug command line autocomplete.', weekly_downloads=76) amo.tests.addon_factory( average_daily_users=11992, description=None, name='Firefinder for Firebug', slug=u'firefinder-for-firebug', summary=( 'Finds HTML elements matching chosen CSS selector(s) or XPath ' 'expression'), weekly_downloads=358) amo.tests.addon_factory( average_daily_users=8200, description=None, name='Fire Drag', slug=u'fire-drag', summary='drag texts and links with/without e10s', weekly_downloads=506) amo.tests.addon_factory( average_daily_users=61014, description=None, name='Menu Wizard', slug=u's3menu-wizard', summary=( 'Customizemenus=Helps removing, moving and renaming menus and ' 'menu items\nColorize important menu for ease of use! (use ' 'Style (CSS))\nChange or disable any of used keyboard ' 'shortcutsnSuppor=Firefox, Thunderbird and SeaMonkey'), weekly_downloads=927) amo.tests.addon_factory( average_daily_users=81237, description=None, name='Add-ons Manager Context Menu', slug=u'am-context', summary='Add more items to Add-ons Manager context menu.', weekly_downloads=169) amo.tests.addon_factory( average_daily_users=51, description=None, name='Frame Demolition', slug=u'frame-demolition', summary=('Enabling route to load abstracted file layer in select ' 'sites.'), weekly_downloads=70) amo.tests.addon_factory( average_daily_users=99, description=None, name='reStyle', slug=u're-style', summary=( 'A user style manager which can load local files and apply UI ' 'styles even in Firefox 57+'), weekly_downloads=70) amo.tests.addon_factory( average_daily_users=150, description=None, name='MegaUpload DownloadHelper', slug=u'megaupload-downloadhelper', summary=( 'Download from MegaUpload.\nMegaUpload Download Helper will ' 'start your download once ready.\nMegaUpload Download Helper ' 'will monitor time limitations and will auto-start your ' 'download.'), weekly_downloads=77) amo.tests.addon_factory( average_daily_users=2830, description=None, name='RapidShare DownloadHelper', slug=u'rapidshare-downloadhelper', summary=( 'Note from Mozilla: This add-on has been discontinued. Try ' '<a rel="nofollow" href="https://addons.mozilla.org/firefox/' 'addon/rapidshare-helper/">Rapidshare Helper</a> instead.\n\n' 'RapidShare Download Helper will start your download once ' 'ready.'), weekly_downloads=125) amo.tests.addon_factory( average_daily_users=98716, description=None, name='Popup Blocker', slug=u'popup_blocker', summary=( 'Prevents your web browser from opening a new window on top ' 'of the content or web site you are viewing. The Addon also ' 'supresses unwanted advertisement windows on your screen. ' 'The one deciding what consitutes a popup is the user.'), weekly_downloads=3940) amo.tests.addon_factory( average_daily_users=8830, description=None, name='No Flash', slug=u'no-flash', summary=( 'Replace Youtube, Vimeo and Dailymotion Flash video players ' 'embedded on third-party website by the HTML5 counterpart ' 'when the content author still use the old style embed ' '(Flash).\n\nSource code at <a rel="nofollow" href="https://' 'outgoing.prod.mozaws.net/v1/14b404a3c05779fa94b24e0bffc0d710' '6836f1d6b771367b065fb96e9c8656b9/https%3A//github.com/hfigui' 'ere/no-flash">https://github.com/hfiguiere/no-flash</a>'), weekly_downloads=77) amo.tests.addon_factory( average_daily_users=547880, description=None, name='Download Flash and Video', slug=u'download-flash-and-video', summary=( 'Download Flash and Video is a great download helper tool ' 'that lets you download Flash games and Flash videos ' '(YouTube, Facebook, Dailymotion, Google Videos and more) ' 'with a single click.\nThe downloader is very easy to use.'), weekly_downloads=65891) amo.tests.addon_factory( average_daily_users=158796, description=None, name='YouTube Flash Video Player', slug=u'youtube-flash-video-player', summary=( 'YouTube Flash Video Player is a powerful tool that will let ' 'you choose Flash video player as default YouTube video ' 'player.'), weekly_downloads=12239) amo.tests.addon_factory( average_daily_users=206980, description=None, name='YouTube Flash Player', slug=u'youtube-flash-player', summary=( u'A very lightweight add-on that allows you to watch YouTube™ ' u'videos using Flash® Player instead of the ' u'default HTML5 player. The Flash® Player will consume less ' u'CPU and RAM resources if your device doesn\'t easily ' u'support HTML5 videos. Try it!'), weekly_downloads=21882) amo.tests.addon_factory( average_daily_users=5056, description=None, name='Disable Hello, Pocket & Reader+', slug=u'disable-hello-pocket-reader', summary=( 'Turn off Pocket, Reader, Hello and WebRTC bloatware - keep ' 'browser fast and clean'), weekly_downloads=85) amo.tests.addon_factory( average_daily_users=26135, description=None, name='Reader', slug=u'reader', summary='Reader is the ultimate Reader tool for Firefox.', weekly_downloads=2463) amo.tests.addon_factory( average_daily_users=53412, description=None, name='Disable WebRTC', slug=u'happy-bonobo-disable-webrtc', summary=( 'WebRTC leaks your actual IP addresses from behind your VPN, ' 'by default.'), weekly_downloads=10583) amo.tests.addon_factory( average_daily_users=12953, description=None, name='In My Pocket', slug=u'in-my-pocket', summary=( 'For all those who are missing the old Firefox Pocket addon, ' 'and not satisfied with the new Pocket integration, here is ' 'an unofficial client for the excellent Pocket service. ' 'Hope you\'ll enjoy it!'), weekly_downloads=1123) amo.tests.addon_factory(name='GrApple Yummy', type=amo.ADDON_EXTENSION, average_daily_users=0, weekly_downloads=0) amo.tests.addon_factory(name='Delicious Bookmarks', type=amo.ADDON_EXTENSION, average_daily_users=0, weekly_downloads=0) # Some more or less Dummy data to test a few very specific scenarios # e.g for exact name matching amo.tests.addon_factory(name='Merge Windows', type=amo.ADDON_EXTENSION, average_daily_users=0, weekly_downloads=0), amo.tests.addon_factory(name='Merge All Windows', type=amo.ADDON_EXTENSION, average_daily_users=0, weekly_downloads=0), amo.tests.addon_factory(name='All Downloader Professional', type=amo.ADDON_EXTENSION, average_daily_users=0, weekly_downloads=0), amo.tests.addon_factory(name='test addon test11', type=amo.ADDON_EXTENSION, average_daily_users=0, weekly_downloads=0), amo.tests.addon_factory(name='test addon test21', type=amo.ADDON_EXTENSION, average_daily_users=0, weekly_downloads=0), amo.tests.addon_factory(name='test addon test31', type=amo.ADDON_EXTENSION, average_daily_users=0, weekly_downloads=0), amo.tests.addon_factory( name='1-Click YouTube Video Download', type=amo.ADDON_EXTENSION, average_daily_users=566337, weekly_downloads=150000, description=('button, click that button, 1-Click Youtube Video ' 'Downloader is a click click great tool')), amo.tests.addon_factory(name='Amazon 1-Click Lock', type=amo.ADDON_EXTENSION, average_daily_users=50, weekly_downloads=0), cls.refresh()