diff --git a/src/olympia/addons/tests/test_addon_utils.py b/src/olympia/addons/tests/test_addon_utils.py index 9df8b3019d..d869afa321 100644 --- a/src/olympia/addons/tests/test_addon_utils.py +++ b/src/olympia/addons/tests/test_addon_utils.py @@ -1,5 +1,3 @@ -from nose.tools import eq_ - from olympia import amo from olympia.amo.tests import TestCase from olympia.addons.models import Addon @@ -14,26 +12,26 @@ class TestReverseNameLookup(TestCase): self.addon = Addon.objects.get() def test_delete_addon(self): - eq_(reverse_name_lookup('Delicious Bookmarks', - addon_type=amo.ADDON_EXTENSION), 3615) + assert reverse_name_lookup( + 'Delicious Bookmarks', addon_type=amo.ADDON_EXTENSION) == 3615 self.addon.delete('farewell my sweet amo, it was a good run') - eq_(reverse_name_lookup('Delicious Bookmarks', - addon_type=amo.ADDON_EXTENSION), None) + assert reverse_name_lookup( + 'Delicious Bookmarks', addon_type=amo.ADDON_EXTENSION) is None def test_update_addon(self): - eq_(reverse_name_lookup('Delicious Bookmarks', - addon_type=amo.ADDON_EXTENSION), 3615) + assert reverse_name_lookup( + 'Delicious Bookmarks', addon_type=amo.ADDON_EXTENSION) == 3615 self.addon.name = 'boo' self.addon.save() - eq_(reverse_name_lookup('Delicious Bookmarks', - addon_type=amo.ADDON_EXTENSION), None) - eq_(reverse_name_lookup('boo', - addon_type=amo.ADDON_EXTENSION), 3615) + assert reverse_name_lookup( + 'Delicious Bookmarks', addon_type=amo.ADDON_EXTENSION) is None + assert reverse_name_lookup( + 'boo', addon_type=amo.ADDON_EXTENSION) == 3615 def test_get_strip(self): - eq_(reverse_name_lookup('Delicious Bookmarks ', - addon_type=amo.ADDON_EXTENSION), 3615) + assert reverse_name_lookup( + 'Delicious Bookmarks ', addon_type=amo.ADDON_EXTENSION) == 3615 def test_get_case(self): - eq_(reverse_name_lookup('delicious bookmarks', - addon_type=amo.ADDON_EXTENSION), 3615) + assert reverse_name_lookup( + 'delicious bookmarks', addon_type=amo.ADDON_EXTENSION) == 3615 diff --git a/src/olympia/addons/tests/test_buttons.py b/src/olympia/addons/tests/test_buttons.py index 2e0dc847cf..9dfdf568b5 100644 --- a/src/olympia/addons/tests/test_buttons.py +++ b/src/olympia/addons/tests/test_buttons.py @@ -5,7 +5,6 @@ import jinja2 import jingo from mock import patch, Mock -from nose.tools import eq_ from pyquery import PyQuery import pytest @@ -107,47 +106,47 @@ class TestButtonSetup(ButtonTest): def test_src(self): """src defaults to '', and can be in the context or request.GET.""" b = self.get_button() - eq_(b.src, '') + assert b.src == '' self.request.GET['src'] = 'zz' b = self.get_button() - eq_(b.src, 'zz') + assert b.src == 'zz' self.context['src'] = 'yy' b = self.get_button() - eq_(b.src, 'yy') + assert b.src == 'yy' b = self.get_button(src='xx') - eq_(b.src, 'xx') + assert b.src == 'xx' def test_collection(self): """Same as src; looking for collection{,_id,_uuid} in request.""" b = self.get_button() - eq_(b.collection, None) + assert b.collection is None self.request.GET['collection_uuid'] = 'aa' b = self.get_button() - eq_(b.collection, 'aa') + assert b.collection == 'aa' self.request.GET['collection_id'] = 'bb' b = self.get_button() - eq_(b.collection, 'bb') + assert b.collection == 'bb' self.request.GET['collection'] = 'cc' b = self.get_button() - eq_(b.collection, 'cc') + assert b.collection == 'cc' self.context['collection'] = 'dd' b = self.get_button() - eq_(b.collection, 'dd') + assert b.collection == 'dd' b = self.get_button(collection='ee') - eq_(b.collection, 'ee') + assert b.collection == 'ee' c = Mock() c.uuid = 'ff' b = self.get_button(collection=c) - eq_(b.collection, 'ff') + assert b.collection == 'ff' def test_version(self): b = self.get_button() @@ -175,10 +174,10 @@ class TestButton(ButtonTest): def test_plain_button(self): b = self.get_button() - eq_(b.button_class, ['download']) - eq_(b.install_class, []) - eq_(b.install_text, '') - eq_(b.version, self.version) + assert b.button_class == ['download'] + assert b.install_class == [] + assert b.install_text == '' + assert b.version == self.version assert b.latest assert not b.featured assert not b.unreviewed @@ -196,8 +195,8 @@ class TestButton(ButtonTest): self.addon.annoying = amo.CONTRIB_ROADBLOCK b = self.get_button() assert b.show_contrib - eq_(b.button_class, ['contrib', 'go']) - eq_(b.install_class, ['contrib']) + assert b.button_class, ['contrib' == 'go'] + assert b.install_class == ['contrib'] def test_show_contrib_mobile(self): """Contributions are not shown on mobile.""" @@ -226,9 +225,9 @@ class TestButton(ButtonTest): self.addon.is_featured.return_value = True b = self.get_button() assert b.featured - eq_(b.button_class, ['download']) - eq_(b.install_class, ['featuredaddon']) - eq_(b.install_text, 'Featured') + assert b.button_class == ['download'] + assert b.install_class == ['featuredaddon'] + assert b.install_text == 'Featured' def test_unreviewed(self): # Throw featured in there to make sure it's ignored. @@ -237,9 +236,9 @@ class TestButton(ButtonTest): b = self.get_button() assert not b.featured assert b.unreviewed - eq_(b.button_class, ['download', 'caution']) - eq_(b.install_class, ['unreviewed']) - eq_(b.install_text, 'Not Reviewed') + assert b.button_class, ['download' == 'caution'] + assert b.install_class == ['unreviewed'] + assert b.install_text == 'Not Reviewed' def test_beta(self): # Throw featured in there to make sure it's ignored. @@ -247,9 +246,9 @@ class TestButton(ButtonTest): b = self.get_button(version=self.beta_version) assert not b.featured assert b.is_beta - eq_(b.button_class, ['download', 'caution']) - eq_(b.install_class, ['unreviewed', 'beta']) - eq_(b.install_text, 'Not Reviewed') + assert b.button_class, ['download' == 'caution'] + assert b.install_class, ['unreviewed' == 'beta'] + assert b.install_text == 'Not Reviewed' def test_lite(self): # Throw featured in there to make sure it's ignored. @@ -259,9 +258,9 @@ class TestButton(ButtonTest): b = self.get_button() assert not b.featured assert b.lite - eq_(b.button_class, ['caution']) - eq_(b.install_class, ['lite']) - eq_(b.install_text, 'Experimental') + assert b.button_class == ['caution'] + assert b.install_class == ['lite'] + assert b.install_text == 'Experimental' def test_lite_and_nominated(self): # Throw featured in there to make sure it's ignored. @@ -271,9 +270,9 @@ class TestButton(ButtonTest): b = self.get_button() assert not b.featured assert b.lite - eq_(b.button_class, ['caution']) - eq_(b.install_class, ['lite']) - eq_(b.install_text, 'Experimental') + assert b.button_class == ['caution'] + assert b.install_class == ['lite'] + assert b.install_text == 'Experimental' def test_lite_unreviewed_version(self): # Throw featured in there to make sure it's ignored. @@ -285,9 +284,9 @@ class TestButton(ButtonTest): assert not b.featured assert not b.lite assert b.unreviewed - eq_(b.button_class, ['download', 'caution']) - eq_(b.install_class, ['unreviewed']) - eq_(b.install_text, 'Not Reviewed') + assert b.button_class, ['download' == 'caution'] + assert b.install_class == ['unreviewed'] + assert b.install_text == 'Not Reviewed' def test_public_with_lite_version(self): # Throw featured in there to make sure it's ignored. @@ -297,29 +296,29 @@ class TestButton(ButtonTest): b = self.get_button() assert not b.featured assert b.lite - eq_(b.button_class, ['caution']) - eq_(b.install_class, ['lite']) - eq_(b.install_text, 'Experimental') + assert b.button_class == ['caution'] + assert b.install_class == ['lite'] + assert b.install_text == 'Experimental' def test_attrs(self): b = self.get_button() - eq_(b.attrs(), {}) + assert b.attrs() == {} self.addon.takes_contributions = True self.addon.annoying = amo.CONTRIB_AFTER self.addon.type = amo.ADDON_SEARCH b = self.get_button() - eq_(b.attrs(), {'data-after': 'contrib', 'data-search': 'true'}) + assert b.attrs() == {'data-after': 'contrib', 'data-search': 'true'} def test_after_no_show_contrib(self): self.addon.takes_contributions = True self.addon.annoying = amo.CONTRIB_AFTER b = self.get_button() - eq_(b.attrs(), {'data-after': 'contrib'}) + assert b.attrs() == {'data-after': 'contrib'} b = self.get_button(show_contrib=False) - eq_(b.attrs(), {}) + assert b.attrs() == {} def test_file_details(self): file = self.get_file(amo.PLATFORM_ALL.id) @@ -328,26 +327,25 @@ class TestButton(ButtonTest): # Normal. text, url, os = b.file_details(file) - eq_(text, 'Download Now') - eq_(url, 'xpi.latest') - eq_(os, None) + assert text == 'Download Now' + assert url == 'xpi.latest' + assert os is None # Platformer. file = self.get_file(amo.PLATFORM_MAC.id) _, _, os = b.file_details(file) - eq_(os, amo.PLATFORM_MAC) + assert os == amo.PLATFORM_MAC # Not the latest version. b.latest = False _, url, _ = b.file_details(file) - eq_(url, 'xpi.url') + assert url == 'xpi.url' # Contribution roadblock. b.show_contrib = True text, url, _ = b.file_details(file) - eq_(text, 'Continue to Download →') - eq_(url, - '/en-US/firefox/addon/2/contribute/roadblock/?version=v1') + assert text == 'Continue to Download →' + assert url == '/en-US/firefox/addon/2/contribute/roadblock/?version=v1' def test_file_details_unreviewed(self): file = self.get_file(amo.PLATFORM_ALL.id) @@ -355,19 +353,19 @@ class TestButton(ButtonTest): b = self.get_button() _, url, _ = b.file_details(file) - eq_(url, 'xpi.url') + assert url == 'xpi.url' def test_fix_link(self): b = self.get_button() - eq_(b.fix_link('foo.com'), 'foo.com') + assert b.fix_link('foo.com') == 'foo.com' b = self.get_button(src='src') - eq_(b.fix_link('foo.com'), 'foo.com?src=src') + assert b.fix_link('foo.com') == 'foo.com?src=src' collection = Mock() collection.uuid = 'xxx' b = self.get_button(collection=collection) - eq_(b.fix_link('foo.com'), 'foo.com?collection_id=xxx') + assert b.fix_link('foo.com') == 'foo.com?collection_id=xxx' b = self.get_button(collection=collection, src='src') self.assertUrlEqual(b.fix_link('foo.com'), @@ -377,8 +375,8 @@ class TestButton(ButtonTest): self.version.all_files = self.platform_files links = self.get_button().links() - eq_(len(links), len(self.platforms)) - eq_([x.os.id for x in links], list(self.platforms)) + assert len(links) == len(self.platforms) + assert [x.os.id for x in links] == list(self.platforms) def test_link_with_invalid_file(self): self.version.all_files = self.platform_files @@ -386,12 +384,12 @@ class TestButton(ButtonTest): links = self.get_button().links() expected_platforms = self.platforms[1:] - eq_(len(links), len(expected_platforms)) - eq_([x.os.id for x in links], list(expected_platforms)) + assert len(links) == len(expected_platforms) + assert [x.os.id for x in links] == list(expected_platforms) def test_no_version(self): self.addon.current_version = None - eq_(self.get_button().links(), []) + assert self.get_button().links() == [] class TestButtonHtml(ButtonTest): @@ -405,63 +403,63 @@ class TestButtonHtml(ButtonTest): self.file.hash = 'file hash' doc = self.render() - eq_(doc('.install-shell').length, 1) - eq_(doc('.install').length, 1) - eq_(doc('.install').length, 1) - eq_(doc('.install-button').length, 1) - eq_(doc('.button').length, 1) + assert doc('.install-shell').length == 1 + assert doc('.install').length == 1 + assert doc('.install').length == 1 + assert doc('.install-button').length == 1 + assert doc('.button').length == 1 install = doc('.install') - eq_('12345', install.attr('data-addon')) - eq_('icon url', install.attr('data-icon')) - eq_('meet.dev', install.attr('data-developers')) - eq_(reverse('addons.versions', args=[a.id]), + assert '12345' == install.attr('data-addon') + assert 'icon url' == install.attr('data-icon') + assert 'meet.dev' == install.attr('data-developers') + assert reverse('addons.versions', args=[a.id]) == ( install.attr('data-versions')) - eq_('addon name', install.attr('data-name')) - eq_(None, install.attr('data-min')) - eq_(None, install.attr('data-max')) + assert 'addon name' == install.attr('data-name') + assert None is install.attr('data-min') + assert None is install.attr('data-max') button = doc('.button') - eq_(['button', 'download'], button.attr('class').split()) - eq_('file hash', button.attr('data-hash')) - eq_('xpi.latest', button.attr('href')) + assert ['button', 'download'] == button.attr('class').split() + assert 'file hash' == button.attr('data-hash') + assert 'xpi.latest' == button.attr('href') def test_featured(self): self.addon.is_featured.return_value = True doc = self.render() - eq_(['install', 'featuredaddon'], + assert ['install', 'featuredaddon'] == ( doc('.install').attr('class').split()) - eq_('Featured', doc('.install strong:last-child').text()) + assert 'Featured' == doc('.install strong:last-child').text() def test_unreviewed(self): self.addon.status = amo.STATUS_UNREVIEWED self.addon.is_unreviewed.return_value = True self.addon.get_url_path.return_value = 'addon.url' button = self.render()('.button.caution') - eq_('addon.url', button.attr('href')) - eq_('xpi.url', button.attr('data-realurl')) + assert 'addon.url' == button.attr('href') + assert 'xpi.url' == button.attr('data-realurl') def test_detailed_privacy_policy(self): policy = self.render(detailed=True)('.install-shell .privacy-policy') - eq_(policy.length, 0) + assert policy.length == 0 self.addon.privacy_policy = 'privacy!' policy = self.render(detailed=True)('.install-shell .privacy-policy') - eq_(policy.text(), 'View privacy policy') + assert policy.text() == 'View privacy policy' def test_unreviewed_detailed_warning(self): self.addon.status = amo.STATUS_UNREVIEWED self.addon.is_unreviewed.return_value = True self.addon.get_url_path.return_value = 'addon.url' warning = self.render(detailed=True)('.install-shell .warning') - eq_(warning.text(), + assert warning.text() == ( 'This add-on has not been reviewed by Mozilla. Learn more') def test_lite_detailed_warning(self): self.addon.status = amo.STATUS_LITE self.version.is_lite = True warning = self.render(detailed=True)('.install-shell .warning') - eq_(warning.text(), + assert warning.text() == ( 'This add-on has been preliminarily reviewed by Mozilla.' ' Learn more') @@ -469,19 +467,19 @@ class TestButtonHtml(ButtonTest): self.addon.status = amo.STATUS_LITE_AND_NOMINATED self.version.is_lite = True warning = self.render(detailed=True)('.install-shell .warning') - eq_(warning.text(), + assert warning.text() == ( 'This add-on has been preliminarily reviewed by Mozilla.' ' Learn more') def test_multi_platform(self): self.version.all_files = self.platform_files doc = self.render() - eq_(doc('.button').length, 2) + assert doc('.button').length == 2 for platform in self.platforms: os = doc('.button.%s .os' % amo.PLATFORMS[platform].shortname).attr('data-os') - eq_(amo.PLATFORMS[platform].name, os) + assert amo.PLATFORMS[platform].name == os def test_compatible_apps(self): compat = Mock() @@ -492,8 +490,8 @@ class TestButtonHtml(ButtonTest): self.version.is_compatible_app.return_value = True self.version.created = datetime.now() install = self.render()('.install') - eq_('min version', install.attr('data-min')) - eq_('max version', install.attr('data-max')) + assert 'min version' == install.attr('data-min') + assert 'max version' == install.attr('data-max') def test_contrib_text_with_platform(self): self.version.all_files = self.platform_files @@ -501,7 +499,7 @@ class TestButtonHtml(ButtonTest): self.addon.annoying = amo.CONTRIB_ROADBLOCK self.addon.meet_the_dev_url.return_value = 'addon.url' doc = self.render() - eq_(doc('.contrib .os').text(), '') + assert doc('.contrib .os').text() == '' @patch('olympia.addons.buttons.install_button') @patch('olympia.addons.helpers.statusflags') @@ -522,18 +520,18 @@ class TestButtonHtml(ButtonTest): doc = self.render(impala=True) install_shell = doc('.install-shell') install = doc('.install') - eq_(install.attr('data-min'), '4.0') - eq_(install.attr('data-max'), '12.0') - eq_(install.attr('data-is-compatible'), 'true') - eq_(install.attr('data-is-compatible-app'), 'true') - eq_(install.attr('data-compat-overrides'), '[]') - eq_(install_shell.find('.d2c-reasons-popup ul li').length, 0) + assert install.attr('data-min') == '4.0' + assert install.attr('data-max') == '12.0' + assert install.attr('data-is-compatible') == 'true' + assert install.attr('data-is-compatible-app') == 'true' + assert install.attr('data-compat-overrides') == '[]' + assert install_shell.find('.d2c-reasons-popup ul li').length == 0 # Also test overrides. override = [('10.0a1', '10.*')] self.version.compat_override_app_versions.return_value = override install = self.render(impala=True)('.install') - eq_(install.attr('data-is-compatible'), 'true') - eq_(install.attr('data-compat-overrides'), json.dumps(override)) + assert install.attr('data-is-compatible') == 'true' + assert install.attr('data-compat-overrides') == json.dumps(override) def test_d2c_attrs_binary(self): compat = Mock() @@ -545,12 +543,12 @@ class TestButtonHtml(ButtonTest): doc = self.render(impala=True) install_shell = doc('.install-shell') install = doc('.install') - eq_(install.attr('data-min'), '4.0') - eq_(install.attr('data-max'), '12.0') - eq_(install.attr('data-is-compatible'), 'false') - eq_(install.attr('data-is-compatible-app'), 'true') - eq_(install.attr('data-compat-overrides'), '[]') - eq_(install_shell.find('.d2c-reasons-popup ul li').length, 1) + assert install.attr('data-min') == '4.0' + assert install.attr('data-max') == '12.0' + assert install.attr('data-is-compatible') == 'false' + assert install.attr('data-is-compatible-app') == 'true' + assert install.attr('data-compat-overrides') == '[]' + assert install_shell.find('.d2c-reasons-popup ul li').length == 1 def test_d2c_attrs_strict_and_binary(self): compat = Mock() @@ -562,12 +560,12 @@ class TestButtonHtml(ButtonTest): doc = self.render(impala=True) install_shell = doc('.install-shell') install = doc('.install') - eq_(install.attr('data-min'), '4.0') - eq_(install.attr('data-max'), '12.0') - eq_(install.attr('data-is-compatible'), 'false') - eq_(install.attr('data-is-compatible-app'), 'true') - eq_(install.attr('data-compat-overrides'), '[]') - eq_(install_shell.find('.d2c-reasons-popup ul li').length, 2) + assert install.attr('data-min') == '4.0' + assert install.attr('data-max') == '12.0' + assert install.attr('data-is-compatible') == 'false' + assert install.attr('data-is-compatible-app') == 'true' + assert install.attr('data-compat-overrides') == '[]' + assert install_shell.find('.d2c-reasons-popup ul li').length == 2 class TestViews(TestCase): @@ -577,4 +575,4 @@ class TestViews(TestCase): url = reverse('addons.eula', args=[11730, 53612]) response = self.client.get(url, follow=True) doc = PyQuery(response.content) - eq_(doc('[data-search]').attr('class'), 'install ') + assert doc('[data-search]').attr('class') == 'install ' diff --git a/src/olympia/addons/tests/test_cron.py b/src/olympia/addons/tests/test_cron.py index 287f91d5a4..58fc235c6f 100644 --- a/src/olympia/addons/tests/test_cron.py +++ b/src/olympia/addons/tests/test_cron.py @@ -5,7 +5,6 @@ import time from django.core.management.base import CommandError from django.test.utils import override_settings -from nose.tools import eq_ import mock from olympia import amo @@ -27,12 +26,12 @@ class TestLastUpdated(TestCase): cron.addon_last_updated() for addon in Addon.objects.all(): - eq_(addon.last_updated, addon.created) + assert addon.last_updated == addon.created # Make sure it's stable. cron.addon_last_updated() for addon in Addon.objects.all(): - eq_(addon.last_updated, addon.created) + assert addon.last_updated == addon.created def test_catchall(self): """Make sure the catch-all last_updated is stable and accurate.""" @@ -45,12 +44,12 @@ class TestLastUpdated(TestCase): cron.addon_last_updated() for addon in Addon.objects.filter(status=amo.STATUS_PUBLIC, type=amo.ADDON_EXTENSION): - eq_(addon.last_updated, addon.created) + assert addon.last_updated == addon.created # Make sure it's stable. cron.addon_last_updated() for addon in Addon.objects.filter(status=amo.STATUS_PUBLIC): - eq_(addon.last_updated, addon.created) + assert addon.last_updated == addon.created def test_last_updated_lite(self): # Make sure lite addons' last_updated matches their file's @@ -60,8 +59,8 @@ class TestLastUpdated(TestCase): cron.addon_last_updated() addon = Addon.objects.get(id=3615) files = File.objects.filter(version__addon=addon) - eq_(len(files), 1) - eq_(addon.last_updated, files[0].datestatuschanged) + assert len(files) == 1 + assert addon.last_updated == files[0].datestatuschanged assert addon.last_updated def test_last_update_lite_no_files(self): @@ -69,32 +68,32 @@ class TestLastUpdated(TestCase): File.objects.update(status=amo.STATUS_UNREVIEWED) cron.addon_last_updated() addon = Addon.objects.get(id=3615) - eq_(addon.last_updated, addon.created) + assert addon.last_updated == addon.created assert addon.last_updated def test_appsupport(self): ids = Addon.objects.values_list('id', flat=True) cron._update_appsupport(ids) - eq_(AppSupport.objects.filter(app=amo.FIREFOX.id).count(), 4) + assert AppSupport.objects.filter(app=amo.FIREFOX.id).count() == 4 # Run it again to test deletes. cron._update_appsupport(ids) - eq_(AppSupport.objects.filter(app=amo.FIREFOX.id).count(), 4) + assert AppSupport.objects.filter(app=amo.FIREFOX.id).count() == 4 def test_appsupport_listed(self): AppSupport.objects.all().delete() - eq_(AppSupport.objects.filter(addon=3723).count(), 0) + assert AppSupport.objects.filter(addon=3723).count() == 0 cron.update_addon_appsupport() - eq_(AppSupport.objects.filter(addon=3723, - app=amo.FIREFOX.id).count(), 0) + assert AppSupport.objects.filter( + addon=3723, app=amo.FIREFOX.id).count() == 0 def test_appsupport_seamonkey(self): addon = Addon.objects.get(pk=15663) addon.update(status=amo.STATUS_PUBLIC) AppSupport.objects.all().delete() cron.update_addon_appsupport() - eq_(AppSupport.objects.filter(addon=15663, - app=amo.SEAMONKEY.id).count(), 1) + assert AppSupport.objects.filter( + addon=15663, app=amo.SEAMONKEY.id).count() == 1 class TestHideDisabledFiles(TestCase): @@ -147,8 +146,8 @@ class TestHideDisabledFiles(TestCase): self.msg) m_storage.delete.assert_called_with(f1.mirror_file_path) # There's only 2 files, both should have been moved. - eq_(mv_mock.call_count, 2) - eq_(m_storage.delete.call_count, 2) + assert mv_mock.call_count == 2 + assert m_storage.delete.call_count == 2 @mock.patch('olympia.files.models.File.mv') @mock.patch('olympia.files.models.storage') @@ -170,8 +169,8 @@ class TestHideDisabledFiles(TestCase): self.msg) m_storage.delete.assert_called_with(f1.mirror_file_path) # There's only 2 files, both should have been moved. - eq_(mv_mock.call_count, 2) - eq_(m_storage.delete.call_count, 2) + assert mv_mock.call_count == 2 + assert m_storage.delete.call_count == 2 @mock.patch('olympia.files.models.File.mv') @mock.patch('olympia.files.models.storage') @@ -184,10 +183,10 @@ class TestHideDisabledFiles(TestCase): f1 = self.f1 mv_mock.assert_called_with(f1.file_path, f1.guarded_file_path, self.msg) - eq_(mv_mock.call_count, 1) + assert mv_mock.call_count == 1 # It should have been removed from mirror stagins. m_storage.delete.assert_called_with(f1.mirror_file_path) - eq_(m_storage.delete.call_count, 1) + assert m_storage.delete.call_count == 1 class TestUnhideDisabledFiles(TestCase): @@ -243,14 +242,14 @@ class AvgDailyUserCountTestCase(TestCase): def test_adu_is_adjusted_in_cron(self): addon = Addon.objects.get(pk=3615) - eq_(addon.average_daily_users, 6000000) + assert addon.average_daily_users == 6000000 assert \ addon.average_daily_users > addon.total_downloads + 10000, \ ('Unexpected ADU count. ADU of %d not greater than %d' % ( addon.average_daily_users, addon.total_downloads + 10000)) cron._update_addon_average_daily_users([(3615, 6000000)]) addon = Addon.objects.get(pk=3615) - eq_(addon.average_daily_users, addon.total_downloads) + assert addon.average_daily_users == addon.total_downloads def test_adu_flag(self): addon = Addon.objects.get(pk=3615) @@ -279,7 +278,7 @@ class AvgDailyUserCountTestCase(TestCase): os.environ.pop('FORCE_INDEXING', None) addon = Addon.objects.get(pk=3615) - eq_(addon.average_daily_users, 1234) + assert addon.average_daily_users == 1234 class TestCleanupImageFiles(TestCase): diff --git a/src/olympia/addons/tests/test_decorators.py b/src/olympia/addons/tests/test_decorators.py index e9c5a8a42f..8de7c7bd2f 100644 --- a/src/olympia/addons/tests/test_decorators.py +++ b/src/olympia/addons/tests/test_decorators.py @@ -1,7 +1,6 @@ from django import http import mock -from nose.tools import eq_ from olympia.amo.tests import TestCase from olympia.addons import decorators as dec @@ -41,7 +40,7 @@ class TestAddonView(TestCase): def test_200_by_slug(self): res = self.view(self.request, self.addon.slug) - eq_(res, mock.sentinel.OK) + assert res == mock.sentinel.OK def test_404_by_id(self): with self.assertRaises(http.Http404): @@ -65,7 +64,7 @@ class TestAddonView(TestCase): view = dec.addon_view_factory(qs=qs)(self.func) res = view(self.request, self.addon.slug) - eq_(res, mock.sentinel.OK) + assert res == mock.sentinel.OK def test_alternate_qs_404_by_id(self): def qs(): @@ -86,15 +85,15 @@ class TestAddonView(TestCase): def test_addon_no_slug(self): app = Addon.objects.create(type=1, name='xxxx') res = self.view(self.request, app.slug) - eq_(res, mock.sentinel.OK) + assert res == mock.sentinel.OK def test_slug_isdigit(self): app = Addon.objects.create(type=1, name='xxxx') app.update(slug=str(app.id)) r = self.view(self.request, app.slug) - eq_(r, mock.sentinel.OK) + assert r == mock.sentinel.OK request, addon = self.func.call_args[0] - eq_(addon, app) + assert addon == app class TestAddonViewWithUnlisted(TestAddonView): diff --git a/src/olympia/addons/tests/test_forms.py b/src/olympia/addons/tests/test_forms.py index 3057678577..cd857a8de9 100644 --- a/src/olympia/addons/tests/test_forms.py +++ b/src/olympia/addons/tests/test_forms.py @@ -3,7 +3,6 @@ import os import tempfile from mock import patch -from nose.tools import eq_ from django.conf import settings from django.core.files.storage import default_storage as storage @@ -102,7 +101,7 @@ class FormsTest(TestCase): f = forms.AddonFormBasic(dict(name=self.existing_name), request=None, instance=a) assert not f.is_valid() - eq_(f.errors.get('name')[0][1], self.error_msg) + assert f.errors.get('name')[0][1] == self.error_msg def test_old_same(self): """ @@ -112,18 +111,18 @@ class FormsTest(TestCase): f = forms.AddonFormBasic(dict(name=self.existing_name), request=None, instance=delicious) f.is_valid() - eq_(f.errors.get('name'), None) + assert f.errors.get('name') is None def test_locales(self): form = forms.AddonFormDetails(request={}) - eq_(form.fields['default_locale'].choices[0][0], 'af') + assert form.fields['default_locale'].choices[0][0] == 'af' def test_slug_blacklist(self): delicious = Addon.objects.get() form = forms.AddonFormBasic({'slug': 'submit'}, request=None, instance=delicious) assert not form.is_valid() - eq_(form.errors['slug'], + assert form.errors['slug'] == ( [u'The slug cannot be "submit". Please choose another.']) def test_bogus_homepage(self): @@ -136,7 +135,7 @@ class FormsTest(TestCase): form = forms.AddonFormDetails( {'homepage': 'ftp://foo.com'}, request=None) assert not form.is_valid() - eq_(form.errors['homepage'][0][1], u'Enter a valid URL.') + assert form.errors['homepage'][0][1] == u'Enter a valid URL.' def test_homepage_is_not_required(self): delicious = Addon.objects.get() @@ -150,7 +149,7 @@ class FormsTest(TestCase): form = forms.AddonFormBasic({'slug': '123'}, request=None, instance=delicious) assert not form.is_valid() - eq_(form.errors['slug'], + assert form.errors['slug'] == ( [u'The slug cannot be "123". Please choose another.']) @@ -187,24 +186,24 @@ class TestTagsForm(TestCase): def test_tags(self): self.add_tags('foo, bar') - eq_(self.get_tag_text(), ['bar', 'foo']) + assert self.get_tag_text(), ['bar' == 'foo'] def test_tags_xss(self): self.add_tags(', bar') - eq_(self.get_tag_text(), ['bar', 'scriptalertfooscript']) + assert self.get_tag_text(), ['bar' == 'scriptalertfooscript'] def test_tags_case_spaces(self): self.add_tags('foo, bar') self.add_tags('foo, bar , Bar, BAR, b a r ') - eq_(self.get_tag_text(), ['b a r', 'bar', 'foo']) + assert self.get_tag_text(), ['b a r', 'bar' == 'foo'] def test_tags_spaces(self): self.add_tags('foo, bar beer') - eq_(self.get_tag_text(), ['bar beer', 'foo']) + assert self.get_tag_text(), ['bar beer' == 'foo'] def test_tags_unicode(self): self.add_tags(u'Österreich') - eq_(self.get_tag_text(), [u'Österreich'.lower()]) + assert self.get_tag_text() == [u'Österreich'.lower()] def add_restricted(self, *args): if not args: @@ -219,10 +218,10 @@ class TestTagsForm(TestCase): form = forms.AddonFormBasic(data=self.data, request=None, instance=self.addon) - eq_(form.fields['tags'].initial, 'bar, foo') - eq_(self.get_tag_text(), ['bar', 'foo', 'restartless']) + assert form.fields['tags'].initial, 'bar == foo' + assert self.get_tag_text(), ['bar', 'foo' == 'restartless'] self.add_tags('') - eq_(self.get_tag_text(), ['restartless']) + assert self.get_tag_text() == ['restartless'] def test_tags_error(self): self.add_restricted('restartless', 'sdk') @@ -230,12 +229,12 @@ class TestTagsForm(TestCase): data.update({'tags': 'restartless'}) form = forms.AddonFormBasic(data=data, request=None, instance=self.addon) - eq_(form.errors['tags'][0], + assert form.errors['tags'][0] == ( '"restartless" is a reserved tag and cannot be used.') data.update({'tags': 'restartless, sdk'}) form = forms.AddonFormBasic(data=data, request=None, instance=self.addon) - eq_(form.errors['tags'][0], + assert form.errors['tags'][0] == ( '"restartless", "sdk" are reserved tags and cannot be used.') @patch('olympia.access.acl.action_allowed') @@ -243,12 +242,12 @@ class TestTagsForm(TestCase): action_allowed.return_value = True self.add_restricted('restartless') self.add_tags('foo, bar') - eq_(self.get_tag_text(), ['bar', 'foo']) + assert self.get_tag_text(), ['bar' == 'foo'] self.add_tags('foo, bar, restartless') - eq_(self.get_tag_text(), ['bar', 'foo', 'restartless']) + assert self.get_tag_text(), ['bar', 'foo' == 'restartless'] form = forms.AddonFormBasic(data=self.data, request=None, instance=self.addon) - eq_(form.fields['tags'].initial, 'bar, foo, restartless') + assert form.fields['tags'].initial, 'bar, foo == restartless' @patch('olympia.access.acl.action_allowed') def test_tags_admin_restricted_count(self, action_allowed): @@ -263,7 +262,7 @@ class TestTagsForm(TestCase): def test_tags_slugified_count(self): self.add_tags(', '.join('tag-test' for i in range(0, 21))) - eq_(self.get_tag_text(), ['tag-test']) + assert self.get_tag_text() == ['tag-test'] def test_tags_limit(self): self.add_tags(' %s' % ('t' * 128)) @@ -275,8 +274,9 @@ class TestTagsForm(TestCase): form = forms.AddonFormBasic(data=data, request=None, instance=self.addon) assert not form.is_valid() - eq_(form.errors['tags'], ['All tags must be 128 characters or less' - ' after invalid characters are removed.']) + assert form.errors['tags'] == [ + 'All tags must be 128 characters or less after invalid characters' + ' are removed.'] class TestIconForm(TestCase): @@ -350,7 +350,7 @@ class TestCategoryForm(TestCase): addon = Addon.objects.create(type=amo.ADDON_SEARCH) form = forms.CategoryFormSet(addon=addon) apps = [f.app for f in form.forms] - eq_(apps, [amo.FIREFOX]) + assert apps == [amo.FIREFOX] class TestThemeForm(TestCase): diff --git a/src/olympia/addons/tests/test_helpers.py b/src/olympia/addons/tests/test_helpers.py index dfc2a88058..1acdc68acd 100644 --- a/src/olympia/addons/tests/test_helpers.py +++ b/src/olympia/addons/tests/test_helpers.py @@ -1,5 +1,4 @@ from mock import Mock -from nose.tools import eq_ from pyquery import PyQuery from olympia import amo @@ -20,30 +19,30 @@ class TestHelpers(TestCase): # unreviewed a = Addon(status=amo.STATUS_UNREVIEWED) - eq_(statusflags(ctx, a), 'unreviewed') + assert statusflags(ctx, a) == 'unreviewed' # featured featured = Addon.objects.get(pk=1003) - eq_(statusflags(ctx, featured), 'featuredaddon') + assert statusflags(ctx, featured) == 'featuredaddon' # category featured featured = Addon.objects.get(pk=1001) - eq_(statusflags(ctx, featured), 'featuredaddon') + assert statusflags(ctx, featured) == 'featuredaddon' def test_flags(self): ctx = {'APP': amo.FIREFOX, 'LANG': 'en-US'} # unreviewed a = Addon(status=amo.STATUS_UNREVIEWED) - eq_(flag(ctx, a), '
Hi" "There should be no nl's above this.") - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after def test_newlines_blockquote_loose(self): before = ("There should be two nls below this.\n\n" @@ -843,7 +845,7 @@ class TestAddonModels(TestCase): "
Hi\n" "There should be one nl above this.") - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after def test_newlines_inline(self): before = ("If we end a paragraph w/ a non-block-level tag\n\n" @@ -851,7 +853,7 @@ class TestAddonModels(TestCase): after = before # Should stay the same - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after def test_newlines_code_inline(self): before = ("Code tags aren't blocks.\n\n" @@ -860,24 +862,24 @@ class TestAddonModels(TestCase): after = before # Should stay the same - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after def test_newlines_li_newlines(self): before = ("
\ntest.") a = ("Test.\n\n
test.") - eq_(self.newlines_helper(b), a) + assert self.newlines_helper(b) == a def test_newlines_empty_tag_block_nested_spaced(self): before = ("Test.\n\n
\n\n\ntest.") after = ("Test.\n\n\n\n
\n\n- " "
\n\n
test.") - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after def test_newlines_li_newlines_inline(self): before = ("
block level "
@@ -928,7 +930,7 @@ class TestAddonModels(TestCase):
after = before # Should stay the same
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_spaced_blocks(self):
before = ("\n\n\n\n- \n\ntest\n\n
\n\n"
@@ -936,31 +938,31 @@ class TestAddonModels(TestCase):
after = "- test
"
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_spaced_inline(self):
before = "Line.\n\n\nThis line is bold.\n\n\nThis isn't."
after = before
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_nested_inline(self):
before = "\nThis line is bold.\n\nThis is also italic"
after = before
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_xss_script(self):
before = ""
after = "<script>\n\nalert('test');\n</script>"
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_xss_inline(self):
before = "test"
after = "test"
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
@patch('olympia.amo.helpers.urlresolvers.get_outgoing_url')
def test_newlines_attribute_link_doublequote(self, mock_get_outgoing_url):
@@ -975,83 +977,83 @@ class TestAddonModels(TestCase):
before = "lol"
after = 'lol'
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_attribute_doublequote(self):
before = 'lol'
after = before
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_attribute_nestedquotes_doublesingle(self):
before = 'lol'
after = before
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_attribute_nestedquotes_singledouble(self):
before = 'lol'
after = before
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_unclosed_b(self):
before = ("test")
after = ("test")
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_unclosed_b_wrapped(self):
before = ("This is a test")
after = ("This is a test")
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_unclosed_li(self):
before = ("- test
")
after = ("- test
")
- eq_(self.newlines_helper(before), after)
+ assert self.newlines_helper(before) == after
def test_newlines_malformed_faketag(self):
before = "xss')
def test_link_if_listed_else_text_xss(self):
@@ -1699,11 +1704,11 @@ class TestAddonModelsFeatured(TestCase):
def _test_featured_random(self):
f = Addon.featured_random(amo.FIREFOX, 'en-US')
- eq_(sorted(f), [1001, 1003, 2464, 3481, 7661, 15679])
+ assert sorted(f), [1001, 1003, 2464, 3481, 7661 == 15679]
f = Addon.featured_random(amo.FIREFOX, 'fr')
- eq_(sorted(f), [1001, 1003, 2464, 7661, 15679])
+ assert sorted(f), [1001, 1003, 2464, 7661 == 15679]
f = Addon.featured_random(amo.THUNDERBIRD, 'en-US')
- eq_(f, [])
+ assert f == []
def test_featured_random(self):
self._test_featured_random()
@@ -1728,14 +1733,14 @@ class TestBackupVersion(TestCase):
for v in Version.objects.all():
v.delete()
self.addon.update(_current_version=None)
- eq_(self.addon.current_version, None)
+ assert self.addon.current_version is None
def test_firefox_versions(self):
self.setup_new_version()
assert self.addon.update_version()
current = self.addon.current_version.compatible_apps[amo.FIREFOX]
- eq_(current.max.version, '4.0b8pre')
- eq_(current.min.version, '3.0.12')
+ assert current.max.version == '4.0b8pre'
+ assert current.min.version == '3.0.12'
def test_version_signals(self):
self.addon.update(_current_version=None)
@@ -1788,33 +1793,23 @@ class TestPersonaModel(TestCase):
# AMO-uploaded themes have `persona_id=0`.
self.persona.persona_id = 0
self.persona.save()
- ok_(self.persona.thumb_url.endswith(self.p('preview.png')),
- self.persona.thumb_url)
- ok_(self.persona.icon_url.endswith(self.p('icon.png')),
- self.persona.icon_url)
- ok_(self.persona.preview_url.endswith(self.p('preview.png')),
- self.persona.preview_url)
- ok_(self.persona.header_url.endswith(self.p('header.png')),
- self.persona.header_url)
- ok_(self.persona.footer_url.endswith(self.p('footer.png')),
- self.persona.footer_url)
+ assert self.persona.thumb_url.endswith(self.p('preview.png'))
+ assert self.persona.icon_url.endswith(self.p('icon.png'))
+ assert self.persona.preview_url.endswith(self.p('preview.png'))
+ assert self.persona.header_url.endswith(self.p('header.png'))
+ assert self.persona.footer_url.endswith(self.p('footer.png'))
def test_old_image_urls(self):
- ok_(self.persona.thumb_url.endswith(self.p('preview.jpg')),
- self.persona.thumb_url)
- ok_(self.persona.icon_url.endswith(self.p('preview_small.jpg')),
- self.persona.icon_url)
- ok_(self.persona.preview_url.endswith(self.p('preview_large.jpg')),
- self.persona.preview_url)
- ok_(self.persona.header_url.endswith(self.p('header.png')),
- self.persona.header_url)
- ok_(self.persona.footer_url.endswith(self.p('footer.png')),
- self.persona.footer_url)
+ assert self.persona.thumb_url.endswith(self.p('preview.jpg'))
+ assert self.persona.icon_url.endswith(self.p('preview_small.jpg'))
+ assert self.persona.preview_url.endswith(self.p('preview_large.jpg'))
+ assert self.persona.header_url.endswith(self.p('header.png'))
+ assert self.persona.footer_url.endswith(self.p('footer.png'))
def test_update_url(self):
with self.settings(LANGUAGE_CODE='fr', LANGUAGE_URL_MAP={}):
url_ = self.persona.update_url
- ok_(url_.endswith('/fr/themes/update-check/15663'), url_)
+ assert url_.endswith('/fr/themes/update-check/15663')
def test_json_data(self):
self.persona.addon.all_categories = [Category(name='Yolo Art')]
@@ -1829,13 +1824,13 @@ class TestPersonaModel(TestCase):
id_ = str(self.persona.addon.id)
- eq_(data['id'], id_)
- eq_(data['name'], unicode(self.persona.addon.name))
- eq_(data['accentcolor'], '#8d8d97')
- eq_(data['textcolor'], '#ffffff')
- eq_(data['category'], 'Yolo Art')
- eq_(data['author'], 'persona_author')
- eq_(data['description'], unicode(self.addon.description))
+ assert data['id'] == id_
+ assert data['name'] == unicode(self.persona.addon.name)
+ assert data['accentcolor'] == '#8d8d97'
+ assert data['textcolor'] == '#ffffff'
+ assert data['category'] == 'Yolo Art'
+ assert data['author'] == 'persona_author'
+ assert data['description'] == unicode(self.addon.description)
assert data['headerURL'].startswith(
'%s%s/header.png?' % (user_media_url('addons'), id_))
@@ -1846,11 +1841,11 @@ class TestPersonaModel(TestCase):
assert data['iconURL'].startswith(
'%s%s/preview_small.jpg?' % (user_media_url('addons'), id_))
- eq_(data['detailURL'],
+ assert data['detailURL'] == (
'https://omgsh.it%s' % self.persona.addon.get_url_path())
- eq_(data['updateURL'],
+ assert data['updateURL'] == (
'https://vamo/fr/themes/update-check/' + id_)
- eq_(data['version'], '1.0')
+ assert data['version'] == '1.0'
def test_image_urls_without_footer(self):
self.persona.footer = ''
@@ -1871,15 +1866,15 @@ class TestPreviewModel(TestCase):
def test_as_dict(self):
expect = ['caption', 'full', 'thumbnail']
reality = sorted(Preview.objects.all()[0].as_dict().keys())
- eq_(expect, reality)
+ assert expect == reality
def test_filename(self):
preview = Preview.objects.get(pk=24)
- eq_(preview.file_extension, 'png')
+ assert preview.file_extension == 'png'
preview.update(filetype='')
- eq_(preview.file_extension, 'png')
+ assert preview.file_extension == 'png'
preview.update(filetype='video/webm')
- eq_(preview.file_extension, 'webm')
+ assert preview.file_extension == 'webm'
def test_filename_in_url(self):
preview = Preview.objects.get(pk=24)
@@ -1929,14 +1924,14 @@ class TestAddonDependencies(TestCase):
addon=addon,
dependent_addon=Addon.objects.get(id=dependent_id)).save()
- eq_(sorted([a.id for a in addon.dependencies.all()]), sorted(ids))
- eq_(list(a.dependencies.all()), a.all_dependencies)
+ assert sorted([a.id for a in addon.dependencies.all()]) == sorted(ids)
+ assert list(a.dependencies.all()) == a.all_dependencies
def test_unique_dependencies(self):
a = Addon.objects.get(id=5299)
b = Addon.objects.get(id=3615)
AddonDependency.objects.create(addon=a, dependent_addon=b)
- eq_(list(a.dependencies.values_list('id', flat=True)), [3615])
+ assert list(a.dependencies.values_list('id', flat=True)) == [3615]
with self.assertRaises(IntegrityError):
AddonDependency.objects.create(addon=a, dependent_addon=b)
@@ -2082,66 +2077,66 @@ class TestAddonFromUpload(UploadTest):
def test_xpi_attributes(self):
addon = Addon.from_upload(self.get_upload('extension.xpi'),
[self.platform])
- eq_(addon.name, 'xpi name')
- eq_(addon.guid, 'guid@xpi')
- eq_(addon.type, amo.ADDON_EXTENSION)
- eq_(addon.status, amo.STATUS_NULL)
- eq_(addon.homepage, 'http://homepage.com')
- eq_(addon.summary, 'xpi description')
- eq_(addon.description, None)
- eq_(addon.slug, 'xpi-name')
+ assert addon.name == 'xpi name'
+ assert addon.guid == 'guid@xpi'
+ assert addon.type == amo.ADDON_EXTENSION
+ assert addon.status == amo.STATUS_NULL
+ assert addon.homepage == 'http://homepage.com'
+ assert addon.summary == 'xpi description'
+ assert addon.description is None
+ assert addon.slug == 'xpi-name'
def test_xpi_version(self):
addon = Addon.from_upload(self.get_upload('extension.xpi'),
[self.platform])
v = addon.versions.get()
- eq_(v.version, '0.1')
- eq_(v.files.get().platform, self.platform)
- eq_(v.files.get().status, amo.STATUS_UNREVIEWED)
+ assert v.version == '0.1'
+ assert v.files.get().platform == self.platform
+ assert v.files.get().status == amo.STATUS_UNREVIEWED
def test_xpi_for_multiple_platforms(self):
platforms = [amo.PLATFORM_LINUX.id, amo.PLATFORM_MAC.id]
addon = Addon.from_upload(self.get_upload('extension.xpi'),
platforms)
v = addon.versions.get()
- eq_(sorted([f.platform for f in v.all_files]),
+ assert sorted([f.platform for f in v.all_files]) == (
sorted(platforms))
def test_search_attributes(self):
addon = Addon.from_upload(self.get_upload('search.xml'),
[self.platform])
- eq_(addon.name, 'search tool')
- eq_(addon.guid, None)
- eq_(addon.type, amo.ADDON_SEARCH)
- eq_(addon.status, amo.STATUS_NULL)
- eq_(addon.homepage, None)
- eq_(addon.description, None)
- eq_(addon.slug, 'search-tool')
- eq_(addon.summary, 'Search Engine for Firefox')
+ assert addon.name == 'search tool'
+ assert addon.guid is None
+ assert addon.type == amo.ADDON_SEARCH
+ assert addon.status == amo.STATUS_NULL
+ assert addon.homepage is None
+ assert addon.description is None
+ assert addon.slug == 'search-tool'
+ assert addon.summary == 'Search Engine for Firefox'
def test_search_version(self):
addon = Addon.from_upload(self.get_upload('search.xml'),
[self.platform])
v = addon.versions.get()
- eq_(v.version, datetime.now().strftime('%Y%m%d'))
- eq_(v.files.get().platform, amo.PLATFORM_ALL.id)
- eq_(v.files.get().status, amo.STATUS_UNREVIEWED)
+ assert v.version == datetime.now().strftime('%Y%m%d')
+ assert v.files.get().platform == amo.PLATFORM_ALL.id
+ assert v.files.get().status == amo.STATUS_UNREVIEWED
def test_no_homepage(self):
addon = Addon.from_upload(self.get_upload('extension-no-homepage.xpi'),
[self.platform])
- eq_(addon.homepage, None)
+ assert addon.homepage is None
def test_default_locale(self):
# Make sure default_locale follows the active translation.
addon = Addon.from_upload(self.get_upload('search.xml'),
[self.platform])
- eq_(addon.default_locale, 'en-US')
+ assert addon.default_locale == 'en-US'
translation.activate('es')
addon = Addon.from_upload(self.get_upload('search.xml'),
[self.platform])
- eq_(addon.default_locale, 'es')
+ assert addon.default_locale == 'es'
def test_is_listed(self):
# By default, the addon is listed.
@@ -2197,7 +2192,7 @@ class TestFrozenAddons(TestCase):
# Adding a FrozenAddon should immediately drop the addon's hotness.
a = Addon.objects.create(type=1, hotness=22)
FrozenAddon.objects.create(addon=a)
- eq_(Addon.objects.get(id=a.id).hotness, 0)
+ assert Addon.objects.get(id=a.id).hotness == 0
class TestRemoveLocale(TestCase):
@@ -2210,8 +2205,8 @@ class TestRemoveLocale(TestCase):
a.remove_locale('el')
qs = (Translation.objects.filter(localized_string__isnull=False)
.values_list('locale', flat=True))
- eq_(sorted(qs.filter(id=a.name_id)), ['en-US'])
- eq_(sorted(qs.filter(id=a.description_id)), ['en-US', 'he'])
+ assert sorted(qs.filter(id=a.name_id)) == ['en-US']
+ assert sorted(qs.filter(id=a.description_id)) == ['en-US', 'he']
def test_remove_version_locale(self):
addon = Addon.objects.create(type=amo.ADDON_THEME)
@@ -2238,7 +2233,7 @@ class TestUpdateNames(TestCase):
def check_names(self, names):
"""`names` in {locale: name} format."""
for locale, localized_string in names.iteritems():
- eq_(self.get_name(self.addon, locale).localized_string,
+ assert self.get_name(self.addon, locale).localized_string == (
localized_string)
def test_new_name(self):
@@ -2295,7 +2290,7 @@ class TestUpdateNames(TestCase):
self.addon.save()
self.check_names(names)
addon = self.addon.reload()
- eq_(addon.default_locale, 'de')
+ assert addon.default_locale == 'de'
def test_default_locale_change_remove_old(self):
names = dict(self.names, **{'de': u'frü', 'es': u'eso', 'en-US': None})
@@ -2303,7 +2298,7 @@ class TestUpdateNames(TestCase):
self.addon.update_names(names)
self.addon.save()
self.check_names(names)
- eq_(self.addon.reload().default_locale, 'de')
+ assert self.addon.reload().default_locale == 'de'
def test_default_locale_removal_not_deleted(self):
names = {'en-US': None}
@@ -2604,10 +2599,10 @@ class TestLanguagePack(TestCase, amo.tests.AMOPaths):
File.objects.create(platform=self.platform_mob, version=self.version,
filename=self.xpi_path('langpack'),
status=amo.STATUS_PUBLIC)
- eq_(self.addon.reload().get_localepicker(), '')
+ assert self.addon.reload().get_localepicker() == ''
def test_extract_no_files(self):
- eq_(self.addon.get_localepicker(), '')
+ assert self.addon.get_localepicker() == ''
def test_extract_not_language_pack(self):
File.objects.create(platform=self.platform_mob, version=self.version,
@@ -2615,13 +2610,13 @@ class TestLanguagePack(TestCase, amo.tests.AMOPaths):
status=amo.STATUS_PUBLIC)
assert self.addon.reload().get_localepicker()
self.addon.update(type=amo.ADDON_EXTENSION)
- eq_(self.addon.get_localepicker(), '')
+ assert self.addon.get_localepicker() == ''
def test_extract_not_platform_mobile(self):
File.objects.create(platform=self.platform_all, version=self.version,
filename=self.xpi_path('langpack-localepicker'),
status=amo.STATUS_PUBLIC)
- eq_(self.addon.reload().get_localepicker(), '')
+ assert self.addon.reload().get_localepicker() == ''
class TestCompatOverride(TestCase):
@@ -2645,7 +2640,7 @@ class TestCompatOverride(TestCase):
"""Check that key/value pairs in kw match attributes of obj."""
for key, expected in kw.items():
actual = getattr(obj, key)
- eq_(actual, expected, '[%s] %r != %r' % (key, actual, expected))
+ assert actual == expected
def test_is_hosted(self):
c = CompatOverride.objects.create(guid='a')
@@ -2660,16 +2655,16 @@ class TestCompatOverride(TestCase):
# The default is incompatible.
c = CompatOverrideRange.objects.create(compat=one, app=1)
- eq_(c.override_type(), 'incompatible')
+ assert c.override_type() == 'incompatible'
c = CompatOverrideRange.objects.create(compat=one, app=1, type=0)
- eq_(c.override_type(), 'compatible')
+ assert c.override_type() == 'compatible'
def test_guid_match(self):
# We hook up the add-on automatically if we see a matching guid.
addon = Addon.objects.create(id=1, guid='oh yeah', type=1)
c = CompatOverride.objects.create(guid=addon.guid)
- eq_(c.addon_id, addon.id)
+ assert c.addon_id == addon.id
c = CompatOverride.objects.create(guid='something else')
assert c.addon is None
@@ -2681,7 +2676,7 @@ class TestCompatOverride(TestCase):
# If the transformer works then we won't have any more queries.
with self.assertNumQueries(0):
for c in compats:
- eq_(c.compat_ranges,
+ assert c.compat_ranges == (
[r for r in ranges if r.compat_id == c.id])
def test_collapsed_ranges(self):
@@ -2689,11 +2684,11 @@ class TestCompatOverride(TestCase):
c = CompatOverride.objects.get(guid='one')
r = c.collapsed_ranges()
- eq_(len(r), 1)
+ assert len(r) == 1
compat_range = r[0]
self.check(compat_range, type='incompatible', min='0', max='*')
- eq_(len(compat_range.apps), 1)
+ assert len(compat_range.apps) == 1
self.check(compat_range.apps[0], app=amo.FIREFOX, min='0', max='*')
def test_collapsed_ranges_multiple_versions(self):
@@ -2704,14 +2699,14 @@ class TestCompatOverride(TestCase):
max_app_version='3.*')
r = c.collapsed_ranges()
- eq_(len(r), 2)
+ assert len(r) == 2
self.check(r[0], type='incompatible', min='0', max='*')
- eq_(len(r[0].apps), 1)
+ assert len(r[0].apps) == 1
self.check(r[0].apps[0], app=amo.FIREFOX, min='0', max='*')
self.check(r[1], type='incompatible', min='1', max='2')
- eq_(len(r[1].apps), 1)
+ assert len(r[1].apps) == 1
self.check(r[1].apps[0], app=amo.FIREFOX, min='3', max='3.*')
def test_collapsed_ranges_different_types(self):
@@ -2723,25 +2718,25 @@ class TestCompatOverride(TestCase):
max_app_version='3.*')
r = c.collapsed_ranges()
- eq_(len(r), 2)
+ assert len(r) == 2
self.check(r[0], type='compatible', min='0', max='*')
- eq_(len(r[0].apps), 1)
+ assert len(r[0].apps) == 1
self.check(r[0].apps[0], app=amo.FIREFOX, min='3', max='3.*')
self.check(r[1], type='incompatible', min='0', max='*')
- eq_(len(r[1].apps), 1)
+ assert len(r[1].apps) == 1
self.check(r[1].apps[0], app=amo.FIREFOX, min='0', max='*')
def test_collapsed_ranges_multiple_apps(self):
c = CompatOverride.objects.get(guid='two')
r = c.collapsed_ranges()
- eq_(len(r), 1)
+ assert len(r) == 1
compat_range = r[0]
self.check(compat_range, type='incompatible', min='1', max='2')
- eq_(len(compat_range.apps), 2)
+ assert len(compat_range.apps) == 2
self.check(compat_range.apps[0], app=amo.FIREFOX, min='0', max='*')
self.check(compat_range.apps[1], app=amo.FIREFOX, min='3', max='4')
@@ -2751,15 +2746,15 @@ class TestCompatOverride(TestCase):
compat=c, app=1)
r = c.collapsed_ranges()
- eq_(len(r), 2)
+ assert len(r) == 2
self.check(r[0], type='incompatible', min='1', max='2')
- eq_(len(r[0].apps), 2)
+ assert len(r[0].apps) == 2
self.check(r[0].apps[0], app=amo.FIREFOX, min='0', max='*')
self.check(r[0].apps[1], app=amo.FIREFOX, min='3', max='4')
self.check(r[1], type='incompatible', min='5', max='6')
- eq_(len(r[1].apps), 1)
+ assert len(r[1].apps) == 1
self.check(r[1].apps[0], app=amo.FIREFOX, min='0', max='*')
@@ -2771,7 +2766,7 @@ class TestIncompatibleVersions(TestCase):
self.addon = Addon.objects.create(guid='r@b', type=amo.ADDON_EXTENSION)
def test_signals_min(self):
- eq_(IncompatibleVersions.objects.count(), 0)
+ assert IncompatibleVersions.objects.count() == 0
c = CompatOverride.objects.create(guid='r@b')
CompatOverrideRange.objects.create(compat=c, app=self.app.id,
@@ -2781,24 +2776,26 @@ class TestIncompatibleVersions(TestCase):
# Test the max version matched.
version1 = Version.objects.create(id=2, addon=self.addon,
version='1.0')
- eq_(IncompatibleVersions.objects.filter(version=version1).count(), 1)
- eq_(IncompatibleVersions.objects.count(), 1)
+ assert IncompatibleVersions.objects.filter(
+ version=version1).count() == 1
+ assert IncompatibleVersions.objects.count() == 1
# Test the lower range.
version2 = Version.objects.create(id=1, addon=self.addon,
version='0.5')
- eq_(IncompatibleVersions.objects.filter(version=version2).count(), 1)
- eq_(IncompatibleVersions.objects.count(), 2)
+ assert IncompatibleVersions.objects.filter(
+ version=version2).count() == 1
+ assert IncompatibleVersions.objects.count() == 2
# Test delete signals.
version1.delete()
- eq_(IncompatibleVersions.objects.count(), 1)
+ assert IncompatibleVersions.objects.count() == 1
version2.delete()
- eq_(IncompatibleVersions.objects.count(), 0)
+ assert IncompatibleVersions.objects.count() == 0
def test_signals_max(self):
- eq_(IncompatibleVersions.objects.count(), 0)
+ assert IncompatibleVersions.objects.count() == 0
c = CompatOverride.objects.create(guid='r@b')
CompatOverrideRange.objects.create(compat=c, app=self.app.id,
@@ -2807,20 +2804,22 @@ class TestIncompatibleVersions(TestCase):
# Test the min_version matched.
version1 = Version.objects.create(addon=self.addon, version='1.0')
- eq_(IncompatibleVersions.objects.filter(version=version1).count(), 1)
- eq_(IncompatibleVersions.objects.count(), 1)
+ assert IncompatibleVersions.objects.filter(
+ version=version1).count() == 1
+ assert IncompatibleVersions.objects.count() == 1
# Test the upper range.
version2 = Version.objects.create(addon=self.addon, version='99.0')
- eq_(IncompatibleVersions.objects.filter(version=version2).count(), 1)
- eq_(IncompatibleVersions.objects.count(), 2)
+ assert IncompatibleVersions.objects.filter(
+ version=version2).count() == 1
+ assert IncompatibleVersions.objects.count() == 2
# Test delete signals.
version1.delete()
- eq_(IncompatibleVersions.objects.count(), 1)
+ assert IncompatibleVersions.objects.count() == 1
version2.delete()
- eq_(IncompatibleVersions.objects.count(), 0)
+ assert IncompatibleVersions.objects.count() == 0
class TestQueue(TestCase):
diff --git a/src/olympia/addons/tests/test_theme_update.py b/src/olympia/addons/tests/test_theme_update.py
index f8648966d3..3b07d60766 100644
--- a/src/olympia/addons/tests/test_theme_update.py
+++ b/src/olympia/addons/tests/test_theme_update.py
@@ -6,7 +6,6 @@ from django.conf import settings
from django.db import connection
import mock
-from nose.tools import eq_
from olympia.amo.tests import TestCase
from olympia.addons.models import Addon
@@ -114,8 +113,8 @@ class TestThemeUpdate(TestCase):
return update
def test_get_json_bad_ids(self):
- eq_(self.get_update('en-US', 999).get_json(), None)
- eq_(self.get_update('en-US', 813).get_json(), None)
+ assert self.get_update('en-US', 999).get_json() == None
+ assert self.get_update('en-US', 813).get_json() == None
def test_get_json_good_ids(self):
self.addon = Addon.objects.get()
diff --git a/src/olympia/addons/tests/test_update.py b/src/olympia/addons/tests/test_update.py
index dbfae32b73..8aa33ba108 100644
--- a/src/olympia/addons/tests/test_update.py
+++ b/src/olympia/addons/tests/test_update.py
@@ -4,8 +4,6 @@ from email import utils
from django.db import connection
-from nose.tools import eq_
-
from olympia import amo
from olympia.amo.tests import TestCase
from olympia.addons.models import (
@@ -43,7 +41,7 @@ class TestDataValidate(VersionCheckMixin, TestCase):
data['appOS'] = 'something %s penguin' % amo.PLATFORM_LINUX.api_name
form = self.get(data)
assert form.is_valid()
- eq_(form.data['appOS'], amo.PLATFORM_LINUX.id)
+ assert form.data['appOS'] == amo.PLATFORM_LINUX.id
def test_app_version_fails(self):
data = self.good_data.copy()
@@ -64,7 +62,7 @@ class TestDataValidate(VersionCheckMixin, TestCase):
data = self.good_data.copy()
form = self.get(data)
assert form.is_valid()
- eq_(form.data['version_int'], 3070000001000)
+ assert form.data['version_int'] == 3070000001000
def test_sql_injection(self):
data = self.good_data.copy()
@@ -152,7 +150,7 @@ class TestLookup(VersionCheckMixin, TestCase):
"""
version, file = self.get('', '3000000001100',
self.app, self.platform)
- eq_(version, self.version_1_0_2)
+ assert version == self.version_1_0_2
def test_new_client(self):
"""
@@ -161,7 +159,7 @@ class TestLookup(VersionCheckMixin, TestCase):
"""
version, file = self.get('', self.version_int,
self.app, self.platform)
- eq_(version, self.version_1_2_2)
+ assert version == self.version_1_2_2
def test_min_client(self):
"""
@@ -176,7 +174,7 @@ class TestLookup(VersionCheckMixin, TestCase):
version, file = self.get('', '3070000005000', # 3.7a5pre
self.app, self.platform)
- eq_(version, self.version_1_1_3)
+ assert version == self.version_1_1_3
def test_new_client_ordering(self):
"""
@@ -197,7 +195,7 @@ class TestLookup(VersionCheckMixin, TestCase):
version, file = self.get('', self.version_int,
self.app, self.platform)
- eq_(version, self.version_1_2_2)
+ assert version == self.version_1_2_2
def test_public_not_beta(self):
"""
@@ -205,10 +203,10 @@ class TestLookup(VersionCheckMixin, TestCase):
for a beta version, then you get a public version.
"""
self.change_status(self.version_1_2_2, amo.STATUS_PENDING)
- eq_(self.addon.status, amo.STATUS_PUBLIC)
+ assert self.addon.status == amo.STATUS_PUBLIC
version, file = self.get('1.2', self.version_int,
self.app, self.platform)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
def test_public_beta(self):
"""
@@ -221,7 +219,7 @@ class TestLookup(VersionCheckMixin, TestCase):
version, file = self.get('1.2beta', self.version_int,
self.app, self.platform)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
def test_can_downgrade(self):
"""
@@ -234,7 +232,7 @@ class TestLookup(VersionCheckMixin, TestCase):
version, file = self.get('1.2', self.version_int,
self.app, self.platform)
- eq_(version, self.version_1_1_3)
+ assert version == self.version_1_1_3
def test_public_pending_exists(self):
"""
@@ -250,7 +248,7 @@ class TestLookup(VersionCheckMixin, TestCase):
version, file = self.get('1.2', self.version_int,
self.app, self.platform)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
def test_public_pending_no_file_beta(self):
"""
@@ -265,9 +263,9 @@ class TestLookup(VersionCheckMixin, TestCase):
version, file = self.get('1.2beta', self.version_int,
self.app, self.platform)
dest = Version.objects.get(pk=self.version_1_2_2)
- eq_(dest.addon.status, amo.STATUS_PUBLIC)
- eq_(dest.files.all()[0].status, amo.STATUS_PUBLIC)
- eq_(version, dest.pk)
+ assert dest.addon.status == amo.STATUS_PUBLIC
+ assert dest.files.all()[0].status == amo.STATUS_PUBLIC
+ assert version == dest.pk
def test_public_pending_not_exists(self):
"""
@@ -282,7 +280,7 @@ class TestLookup(VersionCheckMixin, TestCase):
version, file = self.get('1.2beta', self.version_int,
self.app, self.platform)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
def test_not_public(self):
"""
@@ -293,7 +291,7 @@ class TestLookup(VersionCheckMixin, TestCase):
self.addon.update(status=amo.STATUS_NULL)
version, file = self.get('1.2.1', self.version_int,
self.app, self.platform)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
def test_platform_does_not_exist(self):
"""If client passes a platform, find that specific platform."""
@@ -304,7 +302,7 @@ class TestLookup(VersionCheckMixin, TestCase):
version, file = self.get('1.2', self.version_int,
self.app, self.platform)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
def test_platform_exists(self):
"""If client passes a platform, find that specific platform."""
@@ -315,7 +313,7 @@ class TestLookup(VersionCheckMixin, TestCase):
version, file = self.get('1.2', self.version_int,
self.app, amo.PLATFORM_LINUX)
- eq_(version, self.version_1_2_2)
+ assert version == self.version_1_2_2
def test_file_for_platform(self):
"""If client passes a platform, make sure we get the right file."""
@@ -330,13 +328,13 @@ class TestLookup(VersionCheckMixin, TestCase):
file_two.save()
version, file = self.get('1.2', self.version_int,
self.app, amo.PLATFORM_LINUX)
- eq_(version, self.version_1_2_2)
- eq_(file, file_one.pk)
+ assert version == self.version_1_2_2
+ assert file == file_one.pk
version, file = self.get('1.2', self.version_int,
self.app, amo.PLATFORM_WIN)
- eq_(version, self.version_1_2_2)
- eq_(file, file_two.pk)
+ assert version == self.version_1_2_2
+ assert file == file_two.pk
def test_file_preliminary(self):
"""
@@ -350,7 +348,7 @@ class TestLookup(VersionCheckMixin, TestCase):
version, file = self.get('1.2', self.version_int,
self.app, amo.PLATFORM_LINUX)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
def test_file_preliminary_addon(self):
"""
@@ -367,7 +365,7 @@ class TestLookup(VersionCheckMixin, TestCase):
self.change_status(self.version_1_2_1, amo.STATUS_LITE)
version, file = self.get('1.2', self.version_int,
self.app, amo.PLATFORM_LINUX)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
def test_file_preliminary_odd_statuses(self):
"""
@@ -382,13 +380,13 @@ class TestLookup(VersionCheckMixin, TestCase):
self.change_status(self.version_1_2_0, amo.STATUS_DISABLED)
version, file = self.get('1.2', self.version_int,
self.app, amo.PLATFORM_LINUX)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
# Current version deleted.
Version.objects.get(pk=self.version_1_2_0).delete()
version, file = self.get('1.2', self.version_int,
self.app, amo.PLATFORM_LINUX)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
def test_file_preliminary_ex_full_addon(self):
"""
@@ -400,7 +398,7 @@ class TestLookup(VersionCheckMixin, TestCase):
self.change_status(self.version_1_2_2, amo.STATUS_LITE)
version, file = self.get('1.2', self.version_int,
self.app, amo.PLATFORM_LINUX)
- eq_(version, self.version_1_2_1)
+ assert version == self.version_1_2_1
class TestDefaultToCompat(VersionCheckMixin, TestCase):
@@ -482,9 +480,8 @@ class TestDefaultToCompat(VersionCheckMixin, TestCase):
for version in versions:
for mode in modes:
- eq_(self.get(app_version=version, compat_mode=mode),
- expected['-'.join([version, mode])],
- 'Unexpected version for "%s-%s"' % (version, mode))
+ assert self.get(app_version=version, compat_mode=mode) == (
+ expected['-'.join([version, mode])])
def test_baseline(self):
# Tests simple add-on (non-binary-components, non-strict).
@@ -570,7 +567,7 @@ class TestDefaultToCompat(VersionCheckMixin, TestCase):
# versioning scheme. This results in no versions being written to the
# incompatible_versions table.
self.create_override(min_version='ver1', max_version='ver2')
- eq_(IncompatibleVersions.objects.all().count(), 0)
+ assert IncompatibleVersions.objects.all().count() == 0
def test_min_max_version(self):
# Tests the minimum requirement of the app maxVersion.
@@ -613,7 +610,7 @@ class TestResponse(VersionCheckMixin, TestCase):
data = self.good_data.copy()
data["id"] = "garbage"
up = self.get(data)
- eq_(up.get_rdf(), up.get_bad_rdf())
+ assert up.get_rdf() == up.get_bad_rdf()
def test_no_platform(self):
file = File.objects.get(pk=67442)
@@ -624,11 +621,11 @@ class TestResponse(VersionCheckMixin, TestCase):
data["appOS"] = self.win.api_name
up = self.get(data)
assert up.get_rdf()
- eq_(up.data['row']['file_id'], file.pk)
+ assert up.data['row']['file_id'] == file.pk
data["appOS"] = self.mac.api_name
up = self.get(data)
- eq_(up.get_rdf(), up.get_no_updates_rdf())
+ assert up.get_rdf() == up.get_no_updates_rdf()
def test_different_platform(self):
file = File.objects.get(pk=67442)
@@ -646,21 +643,21 @@ class TestResponse(VersionCheckMixin, TestCase):
up = self.get(data)
up.is_valid()
up.get_update()
- eq_(up.data['row']['file_id'], file_pk)
+ assert up.data['row']['file_id'] == file_pk
data['appOS'] = self.mac.api_name
up = self.get(data)
up.is_valid()
up.get_update()
- eq_(up.data['row']['file_id'], mac_file_pk)
+ assert up.data['row']['file_id'] == mac_file_pk
def test_good_version(self):
up = self.get(self.good_data)
up.is_valid()
up.get_update()
assert up.data['row']['hash'].startswith('sha256:3808b13e')
- eq_(up.data['row']['min'], '2.0')
- eq_(up.data['row']['max'], '4.0')
+ assert up.data['row']['min'] == '2.0'
+ assert up.data['row']['max'] == '4.0'
def test_beta_version(self):
file = File.objects.get(pk=67442)
@@ -686,7 +683,7 @@ class TestResponse(VersionCheckMixin, TestCase):
up = self.get(data)
up.is_valid()
up.get_update()
- eq_(up.data['row']['file_id'], file.pk)
+ assert up.data['row']['file_id'] == file.pk
def test_no_app_version(self):
data = self.good_data.copy()
@@ -702,8 +699,8 @@ class TestResponse(VersionCheckMixin, TestCase):
up.is_valid()
up.get_update()
assert up.data['row']['hash'].startswith('sha256:3808b13e')
- eq_(up.data['row']['min'], '2.0')
- eq_(up.data['row']['max'], '4.0')
+ assert up.data['row']['min'] == '2.0'
+ assert up.data['row']['max'] == '4.0'
def test_content_type(self):
up = self.get(self.good_data)
@@ -725,7 +722,7 @@ class TestResponse(VersionCheckMixin, TestCase):
hdrs = dict(up.get_headers(1))
lm = datetime(*utils.parsedate_tz(hdrs['Last-Modified'])[:7])
exp = datetime(*utils.parsedate_tz(hdrs['Expires'])[:7])
- eq_((exp - lm).seconds, 3600)
+ assert (exp - lm).seconds == 3600
def test_appguid(self):
up = self.get(self.good_data)
@@ -764,7 +761,7 @@ class TestResponse(VersionCheckMixin, TestCase):
self.addon_one.status = amo.STATUS_PUBLIC
self.addon_one.save()
up.get_rdf()
- eq_(up.data['row']['file_id'], file.pk)
+ assert up.data['row']['file_id'] == file.pk
assert up.data['row']['url'] == self.get_file_url()
def test_hash(self):
@@ -776,7 +773,7 @@ class TestResponse(VersionCheckMixin, TestCase):
file.save()
rdf = self.get(self.good_data).get_rdf()
- eq_(rdf.find('updateHash'), -1)
+ assert rdf.find('updateHash') == -1
def test_releasenotes(self):
rdf = self.get(self.good_data).get_rdf()
@@ -786,7 +783,7 @@ class TestResponse(VersionCheckMixin, TestCase):
version.update(releasenotes=None)
rdf = self.get(self.good_data).get_rdf()
- eq_(rdf.find('updateInfoURL'), -1)
+ assert rdf.find('updateInfoURL') == -1
def test_sea_monkey(self):
data = {
@@ -799,20 +796,20 @@ class TestResponse(VersionCheckMixin, TestCase):
up = self.get(data)
rdf = up.get_rdf()
assert up.data['row']['hash'].startswith('sha256:9d9a389')
- eq_(up.data['row']['min'], '1.0')
- eq_(up.data['row']['version'], '0.5.2')
+ assert up.data['row']['min'] == '1.0'
+ assert up.data['row']['version'] == '0.5.2'
assert rdf.find(data['appID']) > -1
def test_no_updates_at_all(self):
self.addon_one.versions.all().delete()
upd = self.get(self.good_data)
- eq_(upd.get_rdf(), upd.get_no_updates_rdf())
+ assert upd.get_rdf() == upd.get_no_updates_rdf()
def test_no_updates_my_fx(self):
data = self.good_data.copy()
data['appVersion'] = '5.0.1'
upd = self.get(data)
- eq_(upd.get_rdf(), upd.get_no_updates_rdf())
+ assert upd.get_rdf() == upd.get_no_updates_rdf()
class TestFirefoxHotfix(VersionCheckMixin, TestCase):
diff --git a/src/olympia/addons/tests/test_utils_.py b/src/olympia/addons/tests/test_utils_.py
index cd40040280..3df03b2ca2 100644
--- a/src/olympia/addons/tests/test_utils_.py
+++ b/src/olympia/addons/tests/test_utils_.py
@@ -1,5 +1,3 @@
-from nose.tools import eq_
-
from olympia import amo
from olympia.addons.utils import get_featured_ids, get_creatured_ids
from olympia.amo.tests import TestCase
@@ -19,25 +17,25 @@ class TestGetFeaturedIds(TestCase):
super(TestGetFeaturedIds, self).setUp()
def test_by_app(self):
- eq_(set(get_featured_ids(amo.FIREFOX)),
+ assert set(get_featured_ids(amo.FIREFOX)) == (
set(self.all_locales))
def test_by_type(self):
- eq_(set(get_featured_ids(amo.FIREFOX, 'xx', 1)),
+ assert set(get_featured_ids(amo.FIREFOX, 'xx', 1)) == (
set(self.no_locale_type_one))
def test_by_locale(self):
- eq_(set(get_featured_ids(amo.FIREFOX)),
+ assert set(get_featured_ids(amo.FIREFOX)) == (
set(self.all_locales))
- eq_(set(get_featured_ids(amo.FIREFOX, 'xx')),
+ assert set(get_featured_ids(amo.FIREFOX, 'xx')) == (
set(self.no_locale))
- eq_(set(get_featured_ids(amo.FIREFOX, 'en-US')),
+ assert set(get_featured_ids(amo.FIREFOX, 'en-US')) == (
set(self.no_locale + self.en_us_locale))
def test_locale_shuffle(self):
# Make sure the locale-specific add-ons are at the front.
ids = get_featured_ids(amo.FIREFOX, 'en-US')
- eq_((ids[0],), self.en_us_locale)
+ assert (ids[0],) == self.en_us_locale
class TestGetCreaturedIds(TestCase):
@@ -53,13 +51,13 @@ class TestGetCreaturedIds(TestCase):
super(TestGetCreaturedIds, self).setUp()
def test_by_category(self):
- eq_(set(get_creatured_ids(self.category, None)),
+ assert set(get_creatured_ids(self.category, None)) == (
set(self.no_locale))
def test_by_locale(self):
- eq_(set(get_creatured_ids(self.category, 'en-US')),
+ assert set(get_creatured_ids(self.category, 'en-US')) == (
set(self.no_locale + self.en_us_locale))
def test_shuffle(self):
ids = get_creatured_ids(self.category, 'en-US')
- eq_((ids[0],), self.en_us_locale)
+ assert (ids[0],) == self.en_us_locale
diff --git a/src/olympia/addons/tests/test_views.py b/src/olympia/addons/tests/test_views.py
index 70c732b392..60a7313a1a 100644
--- a/src/olympia/addons/tests/test_views.py
+++ b/src/olympia/addons/tests/test_views.py
@@ -14,7 +14,6 @@ from django.utils.encoding import iri_to_uri
import fudge
from mock import patch
-from nose.tools import eq_, nottest
from pyquery import PyQuery as pq
from olympia import amo
@@ -53,20 +52,19 @@ def check_cat_sidebar(url, addon):
for type_ in [amo.ADDON_EXTENSION, amo.ADDON_THEME, amo.ADDON_SEARCH]:
addon.update(type=type_)
r = Client().get(url)
- eq_(pq(r.content)('#side-nav').attr('data-addontype'), str(type_))
+ assert pq(r.content)('#side-nav').attr('data-addontype') == str(type_)
-@nottest
-def test_hovercards(self, doc, addons, src=''):
+def _test_hovercards(self, doc, addons, src=''):
addons = list(addons)
- eq_(doc.find('.addon.hovercard').length, len(addons))
+ assert doc.find('.addon.hovercard').length == len(addons)
for addon in addons:
btn = doc.find('.install[data-addon=%s]' % addon.id)
- eq_(btn.length, 1)
+ assert btn.length == 1
hc = btn.parents('.addon.hovercard')
- eq_(hc.find('a').attr('href'),
+ assert hc.find('a').attr('href') == (
urlparams(addon.get_url_path(), src=src))
- eq_(hc.find('h3').text(), unicode(addon.name))
+ assert hc.find('h3').text() == unicode(addon.name)
class TestHomepage(TestCase):
@@ -79,17 +77,17 @@ class TestHomepage(TestCase):
"""Thunderbird homepage should have the Thunderbird title."""
r = self.client.get('/en-US/thunderbird/')
doc = pq(r.content)
- eq_('Add-ons for Thunderbird', doc('title').text())
+ assert 'Add-ons for Thunderbird' == doc('title').text()
def test_welcome_msg(self):
r = self.client.get('/en-US/firefox/')
welcome = pq(r.content)('#site-welcome').remove('a.close')
- eq_(welcome.text(),
+ assert welcome.text() == (
'Welcome to Firefox Add-ons. Choose from thousands of extra '
'features and styles to make Firefox your own.')
r = self.client.get('/en-US/thunderbird/')
welcome = pq(r.content)('#site-welcome').remove('a.close')
- eq_(welcome.text(),
+ assert welcome.text() == (
'Welcome to Thunderbird Add-ons. Add extra features and styles to '
'make Thunderbird your own.')
@@ -130,7 +128,7 @@ class TestHomepageFeatures(TestCase):
}
for id_, url in sections.iteritems():
# Check that the "See All" link points to the correct page.
- eq_(doc.find('%s .seeall' % id_).attr('href'), url)
+ assert doc.find('%s .seeall' % id_).attr('href') == url
@amo.tests.mobile_test
def test_mobile_home_extensions_only(self):
@@ -150,7 +148,7 @@ class TestHomepageFeatures(TestCase):
def test_mobile_home_popular(self):
r = self.client.get(self.url)
popular = r.context['popular']
- eq_([a.id for a in popular],
+ assert [a.id for a in popular] == (
[a.id for a in sorted(popular, key=lambda x: x.average_daily_users,
reverse=True)])
@@ -161,7 +159,7 @@ class TestPromobox(TestCase):
def test_promo_box_ptbr(self):
# bug 564355, we were trying to match pt-BR and pt-br
response = self.client.get('/pt-BR/firefox/', follow=True)
- eq_(response.status_code, 200)
+ assert response.status_code == 200
class TestContributeInstalled(TestCase):
@@ -179,20 +177,20 @@ class TestContributeInstalled(TestCase):
header = doc('#header')
aux_header = doc('#aux-nav')
# assert that header and aux_header are empty (don't exist)
- eq_(header, [])
- eq_(aux_header, [])
+ assert header == []
+ assert aux_header == []
def test_num_addons_link(self):
r = self.client.get(self.url)
a = pq(r.content)('.num-addons a')
- eq_(a.length, 1)
+ assert a.length == 1
author = self.addon.authors.all()[0]
- eq_(a.attr('href'), author.get_url_path())
+ assert a.attr('href') == author.get_url_path()
def test_title(self):
r = self.client.get(self.url)
title = pq(r.content)('title').text()
- eq_(title.startswith('Thank you for installing Gmail S/MIME'), True)
+ assert title.startswith('Thank you for installing Gmail S/MIME')
class TestContributeEmbedded(TestCase):
@@ -213,12 +211,12 @@ class TestContributeEmbedded(TestCase):
def test_client_get(self):
url = reverse('addons.contribute', args=[self.addon.slug])
- eq_(self.client.get(url, {}).status_code, 405)
+ assert self.client.get(url, {}).status_code == 405
def test_invalid_is_404(self):
"""we get a 404 in case of invalid addon id"""
response = self.client_post(rev=[1])
- eq_(response.status_code, 404)
+ assert response.status_code == 404
@fudge.patch('olympia.paypal.get_paykey')
def test_charity_name(self, get_paykey):
@@ -234,38 +232,38 @@ class TestContributeEmbedded(TestCase):
def test_params_common(self):
"""Test for the some of the common values"""
response = self.client_post(rev=['a592'])
- eq_(response.status_code, 302)
+ assert response.status_code == 302
con = Contribution.objects.all()[0]
- eq_(con.charity_id, None)
- eq_(con.addon_id, 592)
- eq_(con.amount, Decimal('20.00'))
+ assert con.charity_id is None
+ assert con.addon_id == 592
+ assert con.amount == Decimal('20.00')
def test_custom_amount(self):
"""Test that we have the custom amount when given."""
response = self.client_post(rev=['a592'], data={'onetime-amount': 42,
'type': 'onetime'})
- eq_(response.status_code, 302)
- eq_(Contribution.objects.all()[0].amount, Decimal('42.00'))
+ assert response.status_code == 302
+ assert Contribution.objects.all()[0].amount == Decimal('42.00')
def test_invalid_amount(self):
response = self.client_post(rev=['a592'], data={'onetime-amount': 'f',
'type': 'onetime'})
data = json.loads(response.content)
- eq_(data['paykey'], '')
- eq_(data['error'], 'Invalid data.')
+ assert data['paykey'] == ''
+ assert data['error'] == 'Invalid data.'
def test_amount_length(self):
response = self.client_post(rev=['a592'], data={'onetime-amount': '0',
'type': 'onetime'})
data = json.loads(response.content)
- eq_(data['paykey'], '')
- eq_(data['error'], 'Invalid data.')
+ assert data['paykey'] == ''
+ assert data['error'] == 'Invalid data.'
def test_ppal_json_switch(self):
response = self.client_post(rev=['a592'], qs='?result_type=json')
- eq_(response.status_code, 200)
+ assert response.status_code == 200
response = self.client_post(rev=['a592'])
- eq_(response.status_code, 302)
+ assert response.status_code == 302
def test_ppal_return_url_not_relative(self):
response = self.client_post(rev=['a592'], qs='?result_type=json')
@@ -273,16 +271,16 @@ class TestContributeEmbedded(TestCase):
def test_unicode_comment(self):
res = self.client_post(rev=['a592'], data={'comment': u'版本历史记录'})
- eq_(res.status_code, 302)
+ assert res.status_code == 302
assert settings.PAYPAL_FLOW_URL in res._headers['location'][1]
- eq_(Contribution.objects.all()[0].comment, u'版本历史记录')
+ assert Contribution.objects.all()[0].comment == u'版本历史记录'
def test_comment_too_long(self):
response = self.client_post(rev=['a592'], data={'comment': u'a' * 256})
data = json.loads(response.content)
- eq_(data['paykey'], '')
- eq_(data['error'], 'Invalid data.')
+ assert data['paykey'] == ''
+ assert data['error'] == 'Invalid data.'
def test_organization(self):
c = Charity.objects.create(name='moz', url='moz.com',
@@ -290,32 +288,32 @@ class TestContributeEmbedded(TestCase):
self.addon.update(charity=c)
r = self.client_post(rev=['a592'])
- eq_(r.status_code, 302)
- eq_(self.addon.charity_id,
+ assert r.status_code == 302
+ assert self.addon.charity_id == (
self.addon.contribution_set.all()[0].charity_id)
def test_no_org(self):
r = self.client_post(rev=['a592'])
- eq_(r.status_code, 302)
- eq_(self.addon.contribution_set.all()[0].charity_id, None)
+ assert r.status_code == 302
+ assert self.addon.contribution_set.all()[0].charity_id is None
def test_no_suggested_amount(self):
self.addon.update(suggested_amount=None)
res = self.client_post(rev=['a592'])
- eq_(res.status_code, 302)
- eq_(settings.DEFAULT_SUGGESTED_CONTRIBUTION,
+ assert res.status_code == 302
+ assert settings.DEFAULT_SUGGESTED_CONTRIBUTION == (
self.addon.contribution_set.all()[0].amount)
def test_form_suggested_amount(self):
res = self.client.get(self.detail_url)
doc = pq(res.content)
- eq_(len(doc('#contribute-box input[type=radio]')), 2)
+ assert len(doc('#contribute-box input[type=radio]')) == 2
def test_form_no_suggested_amount(self):
self.addon.update(suggested_amount=None)
res = self.client.get(self.detail_url)
doc = pq(res.content)
- eq_(len(doc('#contribute-box input[type=radio]')), 1)
+ assert len(doc('#contribute-box input[type=radio]')) == 1
@fudge.patch('olympia.paypal.get_paykey')
def test_paypal_error_json(self, get_paykey, **kwargs):
@@ -332,8 +330,8 @@ class TestContributeEmbedded(TestCase):
def _test_result_page(self):
url = self.addon.get_detail_url('paypal', ['complete'])
doc = pq(self.client.get(url, {'uuid': 'ballin'}).content)
- eq_(doc('#paypal-result').length, 1)
- eq_(doc('#paypal-thanks').length, 0)
+ assert doc('#paypal-result').length == 1
+ assert doc('#paypal-thanks').length == 0
def test_addons_result_page(self):
self._test_result_page()
@@ -361,39 +359,39 @@ class TestDeveloperPages(TestCase):
def test_meet_the_dev_title(self):
r = self.client.get(reverse('addons.meet', args=['a592']))
title = pq(r.content)('title').text()
- eq_(title.startswith('Meet the Gmail S/MIME Developer'), True)
+ assert title.startswith('Meet the Gmail S/MIME Developer') == True
def test_roadblock_title(self):
r = self.client.get(reverse('addons.meet', args=['a592']))
title = pq(r.content)('title').text()
- eq_(title.startswith('Meet the Gmail S/MIME Developer'), True)
+ assert title.startswith('Meet the Gmail S/MIME Developer') == True
def test_meet_the_dev_src(self):
r = self.client.get(reverse('addons.meet', args=['a11730']))
button = pq(r.content)('.install-button a.button').attr('href')
- eq_(button.endswith('?src=developers'), True)
+ assert button.endswith('?src=developers') == True
def test_nl2br_info(self):
r = self.client.get(reverse('addons.meet', args=['a228106']))
- eq_(r.status_code, 200)
+ assert r.status_code == 200
doc = pq(r.content)
- eq_(doc('.bio').html(),
+ assert doc('.bio').html() == (
'Bio: This is line one.
This is line two')
addon_reasons = doc('#about-addon p')
- eq_(addon_reasons.eq(0).html(),
+ assert addon_reasons.eq(0).html() == (
'Why: This is line one.
This is line two')
- eq_(addon_reasons.eq(1).html(),
+ assert addon_reasons.eq(1).html() == (
'Future: This is line one.
This is line two')
def test_nl2br_info_for_multiple_devs(self):
# Get an Add-on that has multiple developers,
# which will trigger the else block in the template.
r = self.client.get(reverse('addons.meet', args=['a228107']))
- eq_(r.status_code, 200)
+ assert r.status_code == 200
bios = pq(r.content)('.bio')
- eq_(bios.eq(0).html(),
+ assert bios.eq(0).html() == (
'Bio1: This is line one.
This is line two')
- eq_(bios.eq(1).html(),
+ assert bios.eq(1).html() == (
'Bio2: This is line one.
This is line two')
def test_roadblock_src(self):
@@ -401,19 +399,19 @@ class TestDeveloperPages(TestCase):
# If they end up at the roadblock we force roadblock on them
r = self.client.get(url + '?src=dp-btn-primary')
button = pq(r.content)('.install-button a.button').attr('href')
- eq_(button.endswith('?src=dp-btn-primary'), True)
+ assert button.endswith('?src=dp-btn-primary') == True
# No previous source gets the roadblock page source
r = self.client.get(url)
button = pq(r.content)('.install-button a.button').attr('href')
- eq_(button.endswith('?src=meetthedeveloper_roadblock'), True)
+ assert button.endswith('?src=meetthedeveloper_roadblock') == True
def test_roadblock_different(self):
url = reverse('addons.roadblock', args=['a11730'])
r = self.client.get(url + '?src=dp-btn-primary')
button = pq(r.content)('.install-button a.button').attr('href')
- eq_(button.endswith('?src=dp-btn-primary'), True)
- eq_(pq(r.content)('#contribute-box input[name=source]').val(),
+ assert button.endswith('?src=dp-btn-primary') == True
+ assert pq(r.content)('#contribute-box input[name=source]').val() == (
'roadblock')
def test_contribute_multiple_devs(self):
@@ -421,23 +419,23 @@ class TestDeveloperPages(TestCase):
u = UserProfile.objects.get(pk=999)
AddonUser(addon=a, user=u).save()
r = self.client.get(reverse('addons.meet', args=['a592']))
- eq_(pq(r.content)('#contribute-button').length, 1)
+ assert pq(r.content)('#contribute-button').length == 1
def test_get_old_version(self):
url = reverse('addons.meet', args=['a11730'])
r = self.client.get(url)
- eq_(r.context['version'].version, '20090521')
+ assert r.context['version'].version == '20090521'
r = self.client.get('%s?version=%s' % (url, '20080521'))
- eq_(r.context['version'].version, '20080521')
+ assert r.context['version'].version == '20080521'
def test_duplicate_version_number(self):
qs = Version.objects.filter(addon=11730)
qs.update(version='1.x')
- eq_(qs.count(), 2)
+ assert qs.count() == 2
url = reverse('addons.meet', args=['a11730']) + '?version=1.x'
r = self.client.get(url)
- eq_(r.context['version'].version, '1.x')
+ assert r.context['version'].version == '1.x'
def test_purified(self):
addon = Addon.objects.get(pk=592)
@@ -445,7 +443,7 @@ class TestDeveloperPages(TestCase):
addon.save()
url = reverse('addons.meet', args=['592'])
r = self.client.get(url, follow=True)
- eq_(pq(r.content)('#about-addon b').length, 2)
+ assert pq(r.content)('#about-addon b').length == 2
class TestLicensePage(TestCase):
@@ -464,33 +462,33 @@ class TestLicensePage(TestCase):
def test_explicit_version(self):
url = reverse('addons.license', args=['a3615', self.version.version])
r = self.client.get(url)
- eq_(r.status_code, 200)
- eq_(r.context['version'], self.version)
+ assert r.status_code == 200
+ assert r.context['version'] == self.version
def test_implicit_version(self):
url = reverse('addons.license', args=['a3615'])
r = self.client.get(url)
- eq_(r.status_code, 200)
- eq_(r.context['version'], self.addon.current_version)
+ assert r.status_code == 200
+ assert r.context['version'] == self.addon.current_version
def test_no_license(self):
self.version.update(license=None)
url = reverse('addons.license', args=['a3615'])
r = self.client.get(url)
- eq_(r.status_code, 404)
+ assert r.status_code == 404
def test_no_version(self):
self.addon.versions.all().delete()
url = reverse('addons.license', args=['a3615'])
r = self.client.get(url)
- eq_(r.status_code, 404)
+ assert r.status_code == 404
def test_duplicate_version_number(self):
Version.objects.create(addon=self.addon, version=self.version.version)
url = reverse('addons.license', args=['a3615', self.version.version])
r = self.client.get(url)
- eq_(r.status_code, 200)
- eq_(r.context['version'], self.addon.current_version)
+ assert r.status_code == 200
+ assert r.context['version'] == self.addon.current_version
def test_cat_sidebar(self):
check_cat_sidebar(reverse('addons.license', args=['a3615']),
@@ -520,23 +518,23 @@ class TestDetailPage(TestCase):
def test_site_title(self):
r = self.client.get(self.url)
- eq_(pq(r.content)('h1.site-title').text(), 'Add-ons')
+ assert pq(r.content)('h1.site-title').text() == 'Add-ons'
def test_addon_headings(self):
r = self.client.get(self.url)
doc = pq(r.content)
- eq_(doc('h2:first').text(), 'About this Add-on')
- eq_(doc('.metadata .home').text(), 'Add-on home page')
+ assert doc('h2:first').text() == 'About this Add-on'
+ assert doc('.metadata .home').text() == 'Add-on home page'
def test_anonymous_extension(self):
response = self.client.get(self.url)
- eq_(response.status_code, 200)
- eq_(response.context['addon'].id, 3615)
+ assert response.status_code == 200
+ assert response.context['addon'].id == 3615
def test_anonymous_persona(self):
response = self.client.get(reverse('addons.detail', args=['a15663']))
- eq_(response.status_code, 200)
- eq_(response.context['addon'].id, 15663)
+ assert response.status_code == 200
+ assert response.context['addon'].id == 15663
def test_review_microdata_personas(self):
a = Addon.objects.get(id=15663)
@@ -558,7 +556,7 @@ class TestDetailPage(TestCase):
url = self.addon.get_url_path()
m = 'meta[content=noindex]'
- eq_(self.addon.status, amo.STATUS_PUBLIC)
+ assert self.addon.status == amo.STATUS_PUBLIC
settings.ENGAGE_ROBOTS = True
doc = pq(self.client.get(url).content)
assert not doc(m)
@@ -584,8 +582,8 @@ class TestDetailPage(TestCase):
r = self.client.get(self.url)
doc = pq(r.content)
- eq_(doc('#more-about').length, 0)
- eq_(doc('.article.userinput').length, 0)
+ assert doc('#more-about').length == 0
+ assert doc('.article.userinput').length == 0
def test_beta(self):
"""Test add-on with a beta channel."""
@@ -598,7 +596,7 @@ class TestDetailPage(TestCase):
mybetafile.save()
self.addon.update(status=amo.STATUS_PUBLIC)
beta = get_pq_content()
- eq_(beta('#beta-channel').length, 1)
+ assert beta('#beta-channel').length == 1
# Beta channel section should link to beta versions listing
versions_url = reverse('addons.beta-versions', args=[self.addon.slug])
@@ -608,15 +606,15 @@ class TestDetailPage(TestCase):
# Now hide it. Beta is only shown for STATUS_PUBLIC.
self.addon.update(status=amo.STATUS_UNREVIEWED)
beta = get_pq_content()
- eq_(beta('#beta-channel').length, 0)
+ assert beta('#beta-channel').length == 0
@amo.tests.mobile_test
def test_unreviewed_disabled_button(self):
self.addon.update(status=amo.STATUS_UNREVIEWED)
r = self.client.get(self.url)
doc = pq(r.content)
- eq_(doc('.button.add').length, 1)
- eq_(doc('.button.disabled').length, 0)
+ assert doc('.button.add').length == 1
+ assert doc('.button.disabled').length == 0
def test_type_redirect(self):
"""
@@ -628,8 +626,8 @@ class TestDetailPage(TestCase):
prefixer.app = amo.THUNDERBIRD.short
response = self.client.get(reverse('addons.detail', args=['a4594']),
follow=False)
- eq_(response.status_code, 301)
- eq_(response['Location'].find(amo.THUNDERBIRD.short), -1)
+ assert response.status_code == 301
+ assert response['Location'].find(amo.THUNDERBIRD.short) == -1
assert (response['Location'].find(amo.FIREFOX.short) >= 0)
def test_compatible_app_redirect(self):
@@ -645,21 +643,22 @@ class TestDetailPage(TestCase):
prefixer = amo.urlresolvers.get_url_prefix()
prefixer.app = not_comp_app.short
r = self.client.get(reverse('addons.detail', args=[self.addon.slug]))
- eq_(r.status_code, 301)
- eq_(r['Location'].find(not_comp_app.short), -1)
+ assert r.status_code == 301
+ assert r['Location'].find(not_comp_app.short) == -1
assert r['Location'].find(comp_app.short) >= 0
# compatible app => 200
prefixer = amo.urlresolvers.get_url_prefix()
prefixer.app = comp_app.short
r = self.client.get(reverse('addons.detail', args=[self.addon.slug]))
- eq_(r.status_code, 200)
+ assert r.status_code == 200
def test_external_urls(self):
"""Check that external URLs are properly escaped."""
response = self.client.get(self.url)
doc = pq(response.content)
- eq_(doc('aside a.home[href^="%s"]' % settings.REDIRECT_URL).length, 1)
+ assert doc(
+ 'aside a.home[href^="%s"]' % settings.REDIRECT_URL).length == 1
def test_no_privacy_policy(self):
"""Make sure privacy policy is not shown when not present."""
@@ -667,14 +666,14 @@ class TestDetailPage(TestCase):
self.addon.save()
response = self.client.get(self.url)
doc = pq(response.content)
- eq_(doc('.privacy-policy').length, 0)
+ assert doc('.privacy-policy').length == 0
def test_privacy_policy(self):
self.addon.privacy_policy = 'foo bar'
self.addon.save()
response = self.client.get(self.url)
doc = pq(response.content)
- eq_(doc('.privacy-policy').length, 1)
+ assert doc('.privacy-policy').length == 1
privacy_url = reverse('addons.privacy', args=[self.addon.slug])
assert doc('.privacy-policy').attr('href').endswith(privacy_url)
@@ -699,13 +698,13 @@ class TestDetailPage(TestCase):
r = self.client.get(reverse('addons.privacy', args=[self.addon.slug]))
doc = pq(r.content)
- eq_(norm(doc(".policy-statement strong")),
+ assert norm(doc(".policy-statement strong")) == (
" what the hell..")
- eq_(norm(doc(".policy-statement ul")),
+ assert norm(doc(".policy-statement ul")) == (
"- papparapara
- todotodotodo
")
- eq_(doc(".policy-statement ol a").text(),
+ assert doc(".policy-statement ol a").text() == (
"firefox")
- eq_(norm(doc(".policy-statement ol li:first")),
+ assert norm(doc(".policy-statement ol li:first")) == (
"- papparapara2
")
def test_evil_html_is_not_rendered_in_privacy(self):
@@ -733,23 +732,23 @@ class TestDetailPage(TestCase):
def test_button_src_default(self):
r = self.client.get(self.url, follow=True)
- eq_((pq(r.content)('#addon .button').attr('href')
- .endswith('?src=dp-btn-primary')), True)
+ assert (pq(r.content)('#addon .button').attr(
+ 'href').endswith('?src=dp-btn-primary'))
def test_button_src_trickle(self):
r = self.client.get(self.url + '?src=trickleortreat', follow=True)
- eq_((pq(r.content)('#addon .button').attr('href')
- .endswith('?src=trickleortreat')), True)
+ assert (pq(r.content)('#addon .button').attr(
+ 'href').endswith('?src=trickleortreat'))
def test_version_button_src_default(self):
r = self.client.get(self.url, follow=True)
- eq_((pq(r.content)('#detail-relnotes .button').attr('href')
- .endswith('?src=dp-btn-version')), True)
+ assert (pq(r.content)('#detail-relnotes .button').attr(
+ 'href').endswith('?src=dp-btn-version'))
def test_version_button_src_trickle(self):
r = self.client.get(self.url + '?src=trickleortreat', follow=True)
- eq_((pq(r.content)('#detail-relnotes .button').attr('href')
- .endswith('?src=trickleortreat')), True)
+ assert (pq(r.content)('#detail-relnotes .button').attr(
+ 'href').endswith('?src=trickleortreat'))
def test_version_more_link(self):
doc = pq(self.client.get(self.url).content)
@@ -763,13 +762,13 @@ class TestDetailPage(TestCase):
self.addon.versions.all().delete()
# Try accessing the details page.
response = self.client.get(self.url)
- eq_(response.status_code, 404)
+ assert response.status_code == 404
def test_no_listed_authors(self):
r = self.client.get(reverse('addons.detail', args=['a59']))
# We shouldn't show an avatar since this has no listed_authors.
doc = pq(r.content)
- eq_(0, len(doc('.avatar')))
+ assert 0 == len(doc('.avatar'))
def test_authors_xss(self):
name = ''
@@ -784,11 +783,11 @@ class TestDetailPage(TestCase):
def test_display_compatible_apps(self):
"""Show compatiblity info for extensions but not for search engines."""
r = self.client.get(self.addon.get_url_path())
- eq_(pq(r.content)('#detail-relnotes .compat').length, 1)
+ assert pq(r.content)('#detail-relnotes .compat').length == 1
a = Addon.objects.filter(type=amo.ADDON_SEARCH)[0]
r = self.client.get(a.get_url_path())
- eq_(pq(r.content)('#detail-relnotes .compat').length, 0)
+ assert pq(r.content)('#detail-relnotes .compat').length == 0
def test_show_profile(self):
selector = '.author a[href="%s"]' % self.addon.meet_the_dev_url()
@@ -804,7 +803,7 @@ class TestDetailPage(TestCase):
no_restart = 'No Restart'
f = self.addon.current_version.all_files[0]
- eq_(f.no_restart, False)
+ assert not f.no_restart
r = self.client.get(self.url)
assert no_restart not in r.content
@@ -816,13 +815,13 @@ class TestDetailPage(TestCase):
def test_disabled_user_message(self):
self.addon.update(disabled_by_user=True)
res = self.client.get(self.url)
- eq_(res.status_code, 404)
+ assert res.status_code == 404
assert 'removed by its author' in res.content
def test_disabled_status_message(self):
self.addon.update(status=amo.STATUS_DISABLED)
res = self.client.get(self.url)
- eq_(res.status_code, 404)
+ assert res.status_code == 404
assert 'disabled by an administrator' in res.content
def test_deleted_status_message(self):
@@ -830,11 +829,11 @@ class TestDetailPage(TestCase):
addon.update(status=amo.STATUS_DELETED)
url = reverse('addons.detail', args=[addon.slug])
res = self.client.get(url)
- eq_(res.status_code, 404)
+ assert res.status_code == 404
def test_more_url(self):
response = self.client.get(self.url)
- eq_(pq(response.content)('#more-webpage').attr('data-more-url'),
+ assert pq(response.content)('#more-webpage').attr('data-more-url') == (
self.addon.get_url_path(more=True))
def test_unlisted_addon_returns_404(self):
@@ -864,98 +863,98 @@ class TestImpalaDetailPage(TestCase):
return pq(self.client.get(self.url).content)
def test_adu_stats_private(self):
- eq_(self.addon.public_stats, False)
+ assert not self.addon.public_stats
adu = self.get_pq()('#daily-users')
- eq_(adu.length, 1)
- eq_(adu.find('a').length, 0)
+ assert adu.length == 1
+ assert adu.find('a').length == 0
def test_adu_stats_public(self):
self.addon.update(public_stats=True)
- eq_(self.addon.show_adu(), True)
+ assert self.addon.show_adu() == True
adu = self.get_pq()('#daily-users')
# Check that ADU does link to public statistics dashboard.
- eq_(adu.find('a').attr('href'),
+ assert adu.find('a').attr('href') == (
reverse('stats.overview', args=[self.addon.slug]))
# Check formatted count.
- eq_(adu.text().split()[0], numberfmt(self.addon.average_daily_users))
+ assert adu.text().split()[0] == numberfmt(
+ self.addon.average_daily_users)
# Check if we hide link when there are no ADU.
self.addon.update(average_daily_users=0)
- eq_(self.get_pq()('#daily-users').length, 0)
+ assert self.get_pq()('#daily-users').length == 0
def test_adu_stats_regular(self):
self.client.login(username='regular@mozilla.com', password='password')
# Should not be a link to statistics dashboard for regular users.
adu = self.get_pq()('#daily-users')
- eq_(adu.length, 1)
- eq_(adu.find('a').length, 0)
+ assert adu.length == 1
+ assert adu.find('a').length == 0
def test_adu_stats_admin(self):
self.client.login(username='del@icio.us', password='password')
# Check link to statistics dashboard for add-on authors.
- eq_(self.get_pq()('#daily-users a.stats').attr('href'),
+ assert self.get_pq()('#daily-users a.stats').attr('href') == (
reverse('stats.overview', args=[self.addon.slug]))
def test_downloads_stats_private(self):
self.addon.update(type=amo.ADDON_SEARCH)
- eq_(self.addon.public_stats, False)
+ assert not self.addon.public_stats
adu = self.get_pq()('#weekly-downloads')
- eq_(adu.length, 1)
- eq_(adu.find('a').length, 0)
+ assert adu.length == 1
+ assert adu.find('a').length == 0
def test_downloads_stats_public(self):
self.addon.update(public_stats=True, type=amo.ADDON_SEARCH)
- eq_(self.addon.show_adu(), False)
+ assert self.addon.show_adu() == False
dls = self.get_pq()('#weekly-downloads')
# Check that weekly downloads links to statistics dashboard.
- eq_(dls.find('a').attr('href'),
+ assert dls.find('a').attr('href') == (
reverse('stats.overview', args=[self.addon.slug]))
# Check formatted count.
- eq_(dls.text().split()[0], numberfmt(self.addon.weekly_downloads))
+ assert dls.text().split()[0] == numberfmt(self.addon.weekly_downloads)
# Check if we hide link when there are no weekly downloads.
self.addon.update(weekly_downloads=0)
- eq_(self.get_pq()('#weekly-downloads').length, 0)
+ assert self.get_pq()('#weekly-downloads').length == 0
def test_downloads_stats_regular(self):
self.addon.update(type=amo.ADDON_SEARCH)
self.client.login(username='regular@mozilla.com', password='password')
# Should not be a link to statistics dashboard for regular users.
dls = self.get_pq()('#weekly-downloads')
- eq_(dls.length, 1)
- eq_(dls.find('a').length, 0)
+ assert dls.length == 1
+ assert dls.find('a').length == 0
def test_downloads_stats_admin(self):
self.addon.update(public_stats=True, type=amo.ADDON_SEARCH)
self.client.login(username='del@icio.us', password='password')
# Check link to statistics dashboard for add-on authors.
- eq_(self.get_pq()('#weekly-downloads a.stats').attr('href'),
+ assert self.get_pq()('#weekly-downloads a.stats').attr('href') == (
reverse('stats.overview', args=[self.addon.slug]))
def test_dependencies(self):
- eq_(self.get_pq()('.dependencies').length, 0)
+ assert self.get_pq()('.dependencies').length == 0
req = Addon.objects.get(id=592)
AddonDependency.objects.create(addon=self.addon, dependent_addon=req)
- eq_(self.addon.all_dependencies, [req])
+ assert self.addon.all_dependencies == [req]
cache.clear()
d = self.get_pq()('.dependencies .hovercard')
- eq_(d.length, 1)
- eq_(d.find('h3').text(), unicode(req.name))
- eq_(d.find('a').attr('href')
- .endswith('?src=dp-dl-dependencies'), True)
- eq_(d.find('.install-button a').attr('href')
- .endswith('?src=dp-hc-dependencies'), True)
+ assert d.length == 1
+ assert d.find('h3').text() == unicode(req.name)
+ assert d.find('a').attr('href').endswith('?src=dp-dl-dependencies')
+ assert d.find('.install-button a').attr('href').endswith(
+ '?src=dp-hc-dependencies')
def test_no_restart(self):
f = self.addon.current_version.all_files[0]
- eq_(f.no_restart, False)
- eq_(self.get_pq()('.no-restart').length, 0)
+ assert not f.no_restart
+ assert self.get_pq()('.no-restart').length == 0
f.update(no_restart=True)
- eq_(self.get_pq()('.no-restart').length, 1)
+ assert self.get_pq()('.no-restart').length == 1
def test_license_link_builtin(self):
g = 'http://google.com'
@@ -965,20 +964,20 @@ class TestImpalaDetailPage(TestCase):
license.name = 'License to Kill'
license.url = g
license.save()
- eq_(license.builtin, 1)
- eq_(license.url, g)
+ assert license.builtin == 1
+ assert license.url == g
a = self.get_pq()('.secondary.metadata .source-license a')
- eq_(a.attr('href'), g)
- eq_(a.attr('target'), '_blank')
- eq_(a.text(), 'License to Kill')
+ assert a.attr('href') == g
+ assert a.attr('target') == '_blank'
+ assert a.text() == 'License to Kill'
def test_license_link_custom(self):
version = self.addon._current_version
- eq_(version.license.url, None)
+ assert version.license.url is None
a = self.get_pq()('.secondary.metadata .source-license a')
- eq_(a.attr('href'), version.license_url())
- eq_(a.attr('target'), None)
- eq_(a.text(), 'Custom License')
+ assert a.attr('href') == version.license_url()
+ assert a.attr('target') is None
+ assert a.text() == 'Custom License'
def get_more_pq(self):
return pq(self.client.get_ajax(self.more_url).content)
@@ -986,12 +985,12 @@ class TestImpalaDetailPage(TestCase):
def test_other_addons(self):
"""Ensure listed add-ons by the same author show up."""
other = Addon.objects.get(id=592)
- eq_(list(Addon.objects.listed(amo.FIREFOX).exclude(id=self.addon.id)),
- [other])
+ assert list(Addon.objects.listed(amo.FIREFOX).exclude(
+ id=self.addon.id)) == [other]
add_addon_author(other, self.addon)
doc = self.get_more_pq()('#author-addons')
- test_hovercards(self, doc, [other], src='dp-dl-othersby')
+ _test_hovercards(self, doc, [other], src='dp-dl-othersby')
def test_other_addons_no_unlisted(self):
"""An unlisted add-on by the same author should not show up."""
@@ -999,16 +998,16 @@ class TestImpalaDetailPage(TestCase):
other.update(status=amo.STATUS_UNREVIEWED, disabled_by_user=True)
add_addon_author(other, self.addon)
- eq_(self.get_more_pq()('#author-addons').length, 0)
+ assert self.get_more_pq()('#author-addons').length == 0
def test_other_addons_by_others(self):
"""Add-ons by different authors should not show up."""
author = UserProfile.objects.get(pk=999)
AddonUser.objects.create(addon=self.addon, user=author, listed=True)
- eq_(self.get_more_pq()('#author-addons').length, 0)
+ assert self.get_more_pq()('#author-addons').length == 0
def test_other_addons_none(self):
- eq_(self.get_more_pq()('#author-addons').length, 0)
+ assert self.get_more_pq()('#author-addons').length == 0
def test_categories(self):
cat = self.addon.all_categories[0]
@@ -1040,7 +1039,7 @@ class TestPersonaDetailPage(TestPersonas, TestCase):
def test_persona_images(self):
r = self.client.get(self.url)
doc = pq(r.content)
- eq_(doc('h2.addon img').attr('src'), self.persona.icon_url)
+ assert doc('h2.addon img').attr('src') == self.persona.icon_url
style = doc('#persona div[data-browsertheme]').attr('style')
assert self.persona.preview_url in style, (
'style attribute %s does not link to %s' % (
@@ -1050,13 +1049,13 @@ class TestPersonaDetailPage(TestPersonas, TestCase):
other = addon_factory(type=amo.ADDON_PERSONA)
self.create_addon_user(other)
r = self.client.get(self.url)
- eq_(pq(r.content)('#more-artist .more-link').length, 1)
+ assert pq(r.content)('#more-artist .more-link').length == 1
def test_not_personas(self):
other = addon_factory(type=amo.ADDON_EXTENSION)
self.create_addon_user(other)
r = self.client.get(self.url)
- eq_(pq(r.content)('#more-artist .more-link').length, 0)
+ assert pq(r.content)('#more-artist .more-link').length == 0
def test_new_more_personas(self):
other = addon_factory(type=amo.ADDON_PERSONA)
@@ -1065,7 +1064,7 @@ class TestPersonaDetailPage(TestPersonas, TestCase):
self.persona.save()
r = self.client.get(self.url)
profile = UserProfile.objects.get(id=999).get_url_path()
- eq_(pq(r.content)('#more-artist .more-link').attr('href'),
+ assert pq(r.content)('#more-artist .more-link').attr('href') == (
profile + '?src=addon-detail')
def test_other_personas(self):
@@ -1076,18 +1075,18 @@ class TestPersonaDetailPage(TestPersonas, TestCase):
other = addon_factory(type=amo.ADDON_PERSONA)
self.create_addon_user(other)
- eq_(other.status, amo.STATUS_PUBLIC)
- eq_(other.disabled_by_user, False)
+ assert other.status == amo.STATUS_PUBLIC
+ assert not other.disabled_by_user
# TODO(cvan): Uncomment this once Personas detail page is impalacized.
- #doc = self.get_more_pq()('#author-addons')
- #test_hovercards(self, doc, [other], src='dp-dl-othersby')
+ # doc = self.get_more_pq()('#author-addons')
+ # _test_hovercards(self, doc, [other], src='dp-dl-othersby')
r = self.client.get(self.url)
- eq_(list(r.context['author_personas']), [other])
+ assert list(r.context['author_personas']) == [other]
a = pq(r.content)('#more-artist a[data-browsertheme]')
- eq_(a.length, 1)
- eq_(a.attr('href'), other.get_url_path())
+ assert a.length == 1
+ assert a.attr('href') == other.get_url_path()
def _test_by(self):
"""Test that the by... bit works."""
@@ -1119,47 +1118,47 @@ class TestStatus(TestCase):
def test_incomplete(self):
self.addon.update(status=amo.STATUS_NULL)
- eq_(self.client.get(self.url).status_code, 404)
+ assert self.client.get(self.url).status_code == 404
def test_unreviewed(self):
self.addon.update(status=amo.STATUS_UNREVIEWED)
- eq_(self.client.get(self.url).status_code, 200)
+ assert self.client.get(self.url).status_code == 200
def test_pending(self):
self.addon.update(status=amo.STATUS_PENDING)
- eq_(self.client.get(self.url).status_code, 404)
+ assert self.client.get(self.url).status_code == 404
def test_nominated(self):
self.addon.update(status=amo.STATUS_NOMINATED)
- eq_(self.client.get(self.url).status_code, 200)
+ assert self.client.get(self.url).status_code == 200
def test_public(self):
self.addon.update(status=amo.STATUS_PUBLIC)
- eq_(self.client.get(self.url).status_code, 200)
+ assert self.client.get(self.url).status_code == 200
def test_deleted(self):
self.addon.update(status=amo.STATUS_DELETED)
- eq_(self.client.get(self.url).status_code, 404)
+ assert self.client.get(self.url).status_code == 404
def test_disabled(self):
self.addon.update(status=amo.STATUS_DISABLED)
- eq_(self.client.get(self.url).status_code, 404)
+ assert self.client.get(self.url).status_code == 404
def test_lite(self):
self.addon.update(status=amo.STATUS_LITE)
- eq_(self.client.get(self.url).status_code, 200)
+ assert self.client.get(self.url).status_code == 200
def test_lite_and_nominated(self):
self.addon.update(status=amo.STATUS_LITE_AND_NOMINATED)
- eq_(self.client.get(self.url).status_code, 200)
+ assert self.client.get(self.url).status_code == 200
def test_purgatory(self):
self.addon.update(status=amo.STATUS_PURGATORY)
- eq_(self.client.get(self.url).status_code, 200)
+ assert self.client.get(self.url).status_code == 200
def test_disabled_by_user(self):
self.addon.update(disabled_by_user=True)
- eq_(self.client.get(self.url).status_code, 404)
+ assert self.client.get(self.url).status_code == 404
def test_persona(self):
for status in Persona.STATUS_CHOICES.keys():
@@ -1167,7 +1166,7 @@ class TestStatus(TestCase):
continue
self.persona.status = status
self.persona.save()
- eq_(self.client.head(self.persona_url).status_code,
+ assert self.client.head(self.persona_url).status_code == (
200 if status in [amo.STATUS_PUBLIC, amo.STATUS_PENDING]
else 404)
@@ -1178,7 +1177,7 @@ class TestStatus(TestCase):
self.persona.status = status
self.persona.disabled_by_user = True
self.persona.save()
- eq_(self.client.head(self.persona_url).status_code, 404)
+ assert self.client.head(self.persona_url).status_code == 404
class TestTagsBox(TestCase):
@@ -1189,7 +1188,7 @@ class TestTagsBox(TestCase):
r = self.client.get_ajax(reverse('addons.detail_more', args=[8680]),
follow=True)
doc = pq(r.content)
- eq_('SEO', doc('#tagbox ul').children().text())
+ assert 'SEO' == doc('#tagbox ul').children().text()
class TestEulaPolicyRedirects(TestCase):
@@ -1199,7 +1198,7 @@ class TestEulaPolicyRedirects(TestCase):
See that we get a 301 to the zamboni style URL
"""
response = self.client.get('/en-US/firefox/addons/policy/0/592/42')
- eq_(response.status_code, 301)
+ assert response.status_code == 301
assert (response['Location'].find('/addon/592/eula/42') != -1)
def test_policy_legacy_url(self):
@@ -1207,7 +1206,7 @@ class TestEulaPolicyRedirects(TestCase):
See that we get a 301 to the zamboni style URL
"""
response = self.client.get('/en-US/firefox/addons/policy/0/592/')
- eq_(response.status_code, 301)
+ assert response.status_code == 301
assert (response['Location'].find('/addon/592/privacy/') != -1)
@@ -1224,7 +1223,7 @@ class TestEula(TestCase):
def test_current_version(self):
r = self.client.get(self.url)
- eq_(r.context['version'], self.addon.current_version)
+ assert r.context['version'] == self.addon.current_version
def test_simple_html_is_rendered(self):
self.addon.eula = """
@@ -1247,12 +1246,12 @@ class TestEula(TestCase):
r = self.client.get(self.url)
doc = pq(r.content)
- eq_(norm(doc('.policy-statement strong')),
+ assert norm(doc('.policy-statement strong')) == (
' what the hell..')
- eq_(norm(doc('.policy-statement ul')),
+ assert norm(doc('.policy-statement ul')) == (
'- papparapara
- todotodotodo
')
- eq_(doc('.policy-statement ol a').text(), 'firefox')
- eq_(norm(doc('.policy-statement ol li:first')),
+ assert doc('.policy-statement ol a').text() == 'firefox'
+ assert norm(doc('.policy-statement ol li:first')) == (
'- papparapara2
')
def test_evil_html_is_not_rendered(self):
@@ -1275,7 +1274,7 @@ class TestEula(TestCase):
old = self.addon.versions.order_by('created')[0]
assert old != self.addon.current_version
r = self.client.get(self.get_url([old.all_files[0].id]))
- eq_(r.context['version'], old)
+ assert r.context['version'] == old
def test_redirect_no_eula(self):
self.addon.update(eula=None)
@@ -1323,7 +1322,7 @@ class TestPrivacyPolicy(TestCase):
self.url = reverse('addons.privacy', args=[self.addon.slug])
def test_redirect_no_eula(self):
- eq_(self.addon.privacy_policy, None)
+ assert self.addon.privacy_policy is None
r = self.client.get(self.url, follow=True)
self.assert3xx(r, self.addon.get_url_path())
@@ -1341,7 +1340,7 @@ class TestAddonSharing(TestCase):
r = self.client.get(reverse('addons.share', args=['a3615']),
{'service': 'facebook'})
url = absolutify(unicode(addon.get_url_path()))
- eq_(r.status_code, 302)
+ assert r.status_code == 302
assert iri_to_uri(addon.name) in r['Location']
assert iri_to_uri(url) in r['Location']
@@ -1358,11 +1357,11 @@ class TestReportAbuse(TestCase):
def test_abuse_anonymous(self, clean):
clean.return_value = ""
self.client.post(self.full_page, {'text': 'spammy'})
- eq_(len(mail.outbox), 1)
+ assert len(mail.outbox) == 1
assert 'spammy' in mail.outbox[0].body
report = AbuseReport.objects.get(addon=3615)
- eq_(report.message, 'spammy')
- eq_(report.reporter, None)
+ assert report.message == 'spammy'
+ assert report.reporter is None
def test_abuse_anonymous_fails(self):
r = self.client.post(self.full_page, {'text': 'spammy'})
@@ -1371,11 +1370,11 @@ class TestReportAbuse(TestCase):
def test_abuse_logged_in(self):
self.client.login(username='regular@mozilla.com', password='password')
self.client.post(self.full_page, {'text': 'spammy'})
- eq_(len(mail.outbox), 1)
+ assert len(mail.outbox) == 1
assert 'spammy' in mail.outbox[0].body
report = AbuseReport.objects.get(addon=3615)
- eq_(report.message, 'spammy')
- eq_(report.reporter.email, 'regular@mozilla.com')
+ assert report.message == 'spammy'
+ assert report.reporter.email == 'regular@mozilla.com'
def test_abuse_name(self):
addon = Addon.objects.get(pk=3615)
@@ -1398,7 +1397,7 @@ class TestReportAbuse(TestCase):
r = self.client.post(reverse('addons.abuse', args=['a15663']),
{'text': 'spammy'})
self.assert3xx(r, shared_url)
- eq_(len(mail.outbox), 1)
+ assert len(mail.outbox) == 1
assert 'spammy' in mail.outbox[0].body
assert AbuseReport.objects.get(addon=15663)
@@ -1413,7 +1412,7 @@ class TestMobileHome(TestMobile):
def test_addons(self):
r = self.client.get('/', follow=True)
- eq_(r.status_code, 200)
+ assert r.status_code == 200
app, lang = r.context['APP'], r.context['LANG']
featured, popular = r.context['featured'], r.context['popular']
# Careful here: we can't be sure of the number of featured addons,
@@ -1422,8 +1421,8 @@ class TestMobileHome(TestMobile):
# featured IDs could correspond to a Persona, and they're filtered out
# in the mobilized version of addons.views.home.
assert all(a.is_featured(app, lang) for a in featured)
- eq_(len(popular), 3)
- eq_([a.id for a in popular],
+ assert len(popular) == 3
+ assert [a.id for a in popular] == (
[a.id for a in sorted(popular, key=lambda x: x.average_daily_users,
reverse=True)])
@@ -1441,12 +1440,12 @@ class TestMobileDetails(TestPersonas, TestMobile):
def test_extension(self):
r = self.client.get(self.url)
- eq_(r.status_code, 200)
+ assert r.status_code == 200
self.assertTemplateUsed(r, 'addons/mobile/details.html')
def test_persona(self):
r = self.client.get(self.persona_url, follow=True)
- eq_(r.status_code, 200)
+ assert r.status_code == 200
self.assertTemplateUsed(r, 'addons/mobile/persona_detail.html')
assert 'review_form' not in r.context
assert 'reviews' not in r.context
@@ -1456,7 +1455,7 @@ class TestMobileDetails(TestPersonas, TestMobile):
other = addon_factory(type=amo.ADDON_PERSONA)
self.create_addon_user(other)
r = self.client.get(self.persona_url, follow=True)
- eq_(pq(r.content)('#more-artist .more-link').length, 1)
+ assert pq(r.content)('#more-artist .more-link').length == 1
def test_new_more_personas(self):
other = addon_factory(type=amo.ADDON_PERSONA)
@@ -1465,12 +1464,12 @@ class TestMobileDetails(TestPersonas, TestMobile):
self.persona.persona.save()
r = self.client.get(self.persona_url, follow=True)
profile = UserProfile.objects.get(id=999).get_url_path()
- eq_(pq(r.content)('#more-artist .more-link').attr('href'),
+ assert pq(r.content)('#more-artist .more-link').attr('href') == (
profile + '?src=addon-detail')
def test_persona_mobile_url(self):
r = self.client.get('/en-US/mobile/addon/15679/')
- eq_(r.status_code, 200)
+ assert r.status_code == 200
def test_extension_release_notes(self):
r = self.client.get(self.url)
@@ -1478,23 +1477,24 @@ class TestMobileDetails(TestPersonas, TestMobile):
assert relnotes.text().startswith(self.ext.current_version.version), (
'Version number missing')
version_url = self.ext.current_version.get_url_path()
- eq_(relnotes.attr('href'), version_url)
+ assert relnotes.attr('href') == version_url
self.client.get(version_url, follow=True)
- eq_(r.status_code, 200)
+ assert r.status_code == 200
def test_extension_adu(self):
doc = pq(self.client.get(self.url).content)('table')
- eq_(doc('.adu td').text(), numberfmt(self.ext.average_daily_users))
+ assert doc('.adu td').text() == numberfmt(self.ext.average_daily_users)
self.ext.update(average_daily_users=0)
doc = pq(self.client.get(self.url).content)('table')
- eq_(doc('.adu').length, 0)
+ assert doc('.adu').length == 0
def test_extension_downloads(self):
doc = pq(self.client.get(self.url).content)('table')
- eq_(doc('.downloads td').text(), numberfmt(self.ext.weekly_downloads))
+ assert doc('.downloads td').text() == numberfmt(
+ self.ext.weekly_downloads)
self.ext.update(weekly_downloads=0)
doc = pq(self.client.get(self.url).content)('table')
- eq_(doc('.downloads').length, 0)
+ assert doc('.downloads').length == 0
def test_button_caching(self):
"""The button popups should be cached for a long time."""
@@ -1511,7 +1511,7 @@ class TestMobileDetails(TestPersonas, TestMobile):
def test_unicode_redirect(self):
url = '/en-US/firefox/addon/2848?xx=\xc2\xbcwhscheck\xc2\xbe'
response = test.Client().get(url)
- eq_(response.status_code, 301)
+ assert response.status_code == 301
class TestAddonViewSet(TestCase):