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), '
Not Reviewed
') + assert flag(ctx, a) == '
Not Reviewed
' # featured featured = Addon.objects.get(pk=1003) - eq_(flag(ctx, featured), '
Featured
') + assert flag(ctx, featured) == '
Featured
' # category featured featured = Addon.objects.get(pk=1001) - eq_(flag(ctx, featured), '
Featured
') + assert flag(ctx, featured) == '
Featured
' def test_contribution_box(self): a = Addon.objects.get(pk=7661) @@ -77,7 +76,7 @@ class TestHelpers(TestCase): s = contribution(c, a, contribution_src='browse') doc = PyQuery(s) - eq_(doc('input[name=source]').attr('value'), 'browse') + assert doc('input[name=source]').attr('value') == 'browse' def test_mobile_persona_preview(self): ctx = {'APP': amo.FIREFOX, 'LANG': 'en-US'} @@ -87,7 +86,7 @@ class TestHelpers(TestCase): bt = doc('.persona-preview div[data-browsertheme]') assert bt assert persona.preview_url in bt.attr('style') - eq_(persona.json_data, bt.attr('data-browsertheme')) + assert persona.json_data == bt.attr('data-browsertheme') assert bt.find('p') def _test_mobile_persona_ctx(self): @@ -119,4 +118,4 @@ class TestHelpers(TestCase): assert doc('.confirm-buttons .cancel') more = doc('.more') assert more - eq_(more.attr('href'), persona.addon.get_url_path()) + assert more.attr('href') == persona.addon.get_url_path() diff --git a/src/olympia/addons/tests/test_models.py b/src/olympia/addons/tests/test_models.py index 2caa05b56d..626ba34602 100644 --- a/src/olympia/addons/tests/test_models.py +++ b/src/olympia/addons/tests/test_models.py @@ -15,7 +15,6 @@ from django.utils import translation import jingo from mock import Mock, patch -from nose.tools import assert_not_equal, eq_, ok_ from olympia import amo from olympia.amo.tests import TestCase @@ -46,20 +45,20 @@ class TestCleanSlug(TestCase): # Make sure there's at least an addon with the "addon" slug, subsequent # ones should be "addon-1", "addon-2" ... a = Addon.objects.create() - eq_(a.slug, "addon") + assert a.slug == "addon" # Start with a first clash. This should give us "addon-1". # We're not saving yet, we're testing the slug creation without an id. b = Addon() b.clean_slug() - eq_(b.slug, 'addon1') + assert b.slug == 'addon1' # Now save the instance to the database for future clashes. b.save() # Test on another object without an id. c = Addon() c.clean_slug() - eq_(c.slug, 'addon2') + assert c.slug == 'addon2' # Even if an addon is deleted, don't clash with its slug. c.status = amo.STATUS_DELETED @@ -70,7 +69,7 @@ class TestCleanSlug(TestCase): # assign the 'addon-2' slug from the deleted addon. d = Addon() d.clean_slug() - eq_(d.slug, 'addon3') + assert d.slug == 'addon3' def test_clean_slug_with_id(self): # Create an addon and save it to have an id. @@ -80,7 +79,7 @@ class TestCleanSlug(TestCase): a.clean_slug() # Slugs created from an id are of the form "id~", eg "123~" to avoid # clashing with URLs. - eq_(a.slug, "%s~" % a.id) + assert a.slug == "%s~" % a.id # And again, this time make it clash. b = Addon.objects.create() @@ -91,27 +90,27 @@ class TestCleanSlug(TestCase): # Now start over for b. b.slug = b.name = "" b.clean_slug() - eq_(b.slug, "%s~1" % b.id) + assert b.slug == "%s~1" % b.id def test_clean_slug_with_name(self): # Make sure there's at least an addon with the "fooname" slug, # subsequent ones should be "fooname-1", "fooname-2" ... a = Addon.objects.create(name="fooname") - eq_(a.slug, "fooname") + assert a.slug == "fooname" b = Addon(name="fooname") b.clean_slug() - eq_(b.slug, "fooname1") + assert b.slug == "fooname1" def test_clean_slug_with_slug(self): # Make sure there's at least an addon with the "fooslug" slug, # subsequent ones should be "fooslug-1", "fooslug-2" ... a = Addon.objects.create(name="fooslug") - eq_(a.slug, "fooslug") + assert a.slug == "fooslug" b = Addon(name="fooslug") b.clean_slug() - eq_(b.slug, "fooslug1") + assert b.slug == "fooslug1" def test_clean_slug_blacklisted_slug(self): blacklisted_slug = 'fooblacklisted' @@ -121,13 +120,13 @@ class TestCleanSlug(TestCase): a.clean_slug() # Blacklisted slugs (like "activate" or IDs) have a "~" appended to # avoid clashing with URLs. - eq_(a.slug, "%s~" % blacklisted_slug) + assert a.slug == "%s~" % blacklisted_slug # Now save the instance to the database for future clashes. a.save() b = Addon(slug=blacklisted_slug) b.clean_slug() - eq_(b.slug, "%s~1" % blacklisted_slug) + assert b.slug == "%s~1" % blacklisted_slug def test_clean_slug_blacklisted_slug_long_slug(self): long_slug = "this_is_a_very_long_slug_that_is_longer_than_thirty_chars" @@ -135,23 +134,23 @@ class TestCleanSlug(TestCase): # If there's no clashing slug, just append a "~". a = Addon.objects.create(slug=long_slug[:30]) - eq_(a.slug, "%s~" % long_slug[:29]) + assert a.slug == "%s~" % long_slug[:29] # If there's a clash, use the standard clash resolution. a = Addon.objects.create(slug=long_slug[:30]) - eq_(a.slug, "%s1" % long_slug[:28]) + assert a.slug == "%s1" % long_slug[:28] def test_clean_slug_long_slug(self): long_slug = "this_is_a_very_long_slug_that_is_longer_than_thirty_chars" # If there's no clashing slug, don't over-shorten it. a = Addon.objects.create(slug=long_slug) - eq_(a.slug, long_slug[:30]) + assert a.slug == long_slug[:30] # Now that there is a clash, test the clash resolution. b = Addon(slug=long_slug) b.clean_slug() - eq_(b.slug, "%s1" % long_slug[:28]) + assert b.slug == "%s1" % long_slug[:28] def test_clean_slug_always_slugify(self): illegal_chars = "some spaces and !?@" @@ -229,7 +228,7 @@ class TestAddonManager(TestCase): assert self.addon in Addon.unfiltered.all() def test_featured(self): - eq_(Addon.objects.featured(amo.FIREFOX).count(), 3) + assert Addon.objects.featured(amo.FIREFOX).count() == 3 def test_listed(self): # We need this for the fixtures, but it messes up the tests. @@ -237,7 +236,7 @@ class TestAddonManager(TestCase): # Now continue as normal. Addon.objects.filter(id=5299).update(disabled_by_user=True) q = Addon.objects.listed(amo.FIREFOX, amo.STATUS_PUBLIC) - eq_(len(q.all()), 4) + assert len(q.all()) == 4 # Pick one of the listed addons. addon = Addon.objects.get(pk=2464) @@ -248,25 +247,24 @@ class TestAddonManager(TestCase): addon.save() # Should be 3 now, since the one is now disabled. - eq_(q.count(), 3) + assert q.count() == 3 # If we search for public or unreviewed we find it. addon.disabled_by_user = False addon.status = amo.STATUS_UNREVIEWED addon.save() - eq_(q.count(), 3) - eq_(Addon.objects.listed(amo.FIREFOX, amo.STATUS_PUBLIC, - amo.STATUS_UNREVIEWED).count(), 4) + assert q.count() == 3 + assert Addon.objects.listed(amo.FIREFOX, amo.STATUS_PUBLIC, + amo.STATUS_UNREVIEWED).count() == 4 # Can't find it without a file. addon.versions.get().files.get().delete() - eq_(q.count(), 3) + assert q.count() == 3 def test_public(self): public = Addon.objects.public() for a in public: - assert_not_equal( - a.id, 3, 'public() must not return unreviewed add-ons') + assert a.id != 3 # 'public() must not return unreviewed add-ons' def test_reviewed(self): for a in Addon.objects.reviewed(): @@ -295,24 +293,26 @@ class TestAddonManager(TestCase): before = Addon.objects.valid_and_disabled_and_pending().count() addon = Addon.objects.get(pk=5299) addon.update(disabled_by_user=True) - eq_(Addon.objects.valid_and_disabled_and_pending().count(), before) + assert Addon.objects.valid_and_disabled_and_pending().count() == before def test_valid_disabled_by_admin(self): before = Addon.objects.valid_and_disabled_and_pending().count() addon = Addon.objects.get(pk=5299) addon.update(status=amo.STATUS_DISABLED) - eq_(Addon.objects.valid_and_disabled_and_pending().count(), before) + assert Addon.objects.valid_and_disabled_and_pending().count() == before def test_invalid_deleted(self): before = Addon.objects.valid_and_disabled_and_pending().count() addon = Addon.objects.get(pk=5299) addon.update(status=amo.STATUS_DELETED) - eq_(Addon.objects.valid_and_disabled_and_pending().count(), before - 1) + assert Addon.objects.valid_and_disabled_and_pending().count() == ( + before - 1) def test_valid_disabled_pending(self): before = Addon.objects.valid_and_disabled_and_pending().count() amo.tests.addon_factory(status=amo.STATUS_PENDING) - eq_(Addon.objects.valid_and_disabled_and_pending().count(), before + 1) + assert Addon.objects.valid_and_disabled_and_pending().count() == ( + before + 1) def test_valid_disabled_version(self): before = Addon.objects.valid_and_disabled_and_pending().count() @@ -320,17 +320,18 @@ class TestAddonManager(TestCase): # Add-on, no version. Doesn't count. addon = amo.tests.addon_factory() addon.update(_current_version=None, _signal=False) - eq_(Addon.objects.valid_and_disabled_and_pending().count(), before) + assert Addon.objects.valid_and_disabled_and_pending().count() == before # Theme, no version. Counts. addon = amo.tests.addon_factory(type=amo.ADDON_PERSONA) addon.update(_current_version=None, _signal=False) - eq_(Addon.objects.valid_and_disabled_and_pending().count(), before + 1) + assert Addon.objects.valid_and_disabled_and_pending().count() == ( + before + 1) def test_new_featured(self): f = Addon.objects.featured(amo.FIREFOX) - eq_(f.count(), 3) - eq_(sorted(x.id for x in f), + assert f.count() == 3 + assert sorted(x.id for x in f) == ( [2464, 7661, 15679]) f = Addon.objects.featured(amo.THUNDERBIRD) assert not f.exists() @@ -414,56 +415,57 @@ class TestAddonModels(TestCase): Tests that we get the current (latest public) version of an addon. """ a = Addon.objects.get(pk=3615) - eq_(a.current_version.id, 81551) + assert a.current_version.id == 81551 def test_current_version_listed(self): a = Addon.objects.get(pk=3723) - eq_(a.current_version.id, 89774) + assert a.current_version.id == 89774 def test_current_version_listed_no_version(self): Addon.objects.filter(pk=3723).update(_current_version=None) Version.objects.filter(addon=3723).delete() a = Addon.objects.get(pk=3723) - eq_(a.current_version, None) + assert a.current_version is None def test_latest_version(self): """ Tests that we get the latest version of an addon. """ a = Addon.objects.get(pk=3615) - eq_(a.latest_version.id, Version.objects.filter(addon=a).latest().id) + assert a.latest_version.id == ( + Version.objects.filter(addon=a).latest().id) def test_latest_version_no_version(self): Addon.objects.filter(pk=3723).update(_current_version=None) Version.objects.filter(addon=3723).delete() a = Addon.objects.get(pk=3723) - eq_(a.latest_version, None) + assert a.latest_version is None def test_latest_version_ignore_beta(self): a = Addon.objects.get(pk=3615) v1 = Version.objects.create(addon=a, version='1.0') File.objects.create(version=v1) - eq_(a.latest_version.id, v1.id) + assert a.latest_version.id == v1.id v2 = Version.objects.create(addon=a, version='2.0beta') File.objects.create(version=v2, status=amo.STATUS_BETA) v2.save() - eq_(a.latest_version.id, v1.id) # Still should be f1 + assert a.latest_version.id == v1.id # Still should be f1 def test_current_version_unsaved(self): a = Addon() a._current_version = Version() - eq_(a.current_version, None) + assert a.current_version is None def test_latest_version_unsaved(self): a = Addon() a._latest_version = Version() - eq_(a.latest_version, None) + assert a.latest_version is None def test_current_beta_version(self): a = Addon.objects.get(pk=5299) - eq_(a.current_beta_version.id, 50000) + assert a.current_beta_version.id == 50000 def _create_new_version(self, addon, status): av = addon.current_version.apps.all()[0] @@ -477,11 +479,11 @@ class TestAddonModels(TestCase): def test_compatible_version(self): a = Addon.objects.get(pk=3615) - eq_(a.status, amo.STATUS_PUBLIC) + assert a.status == amo.STATUS_PUBLIC v = self._create_new_version(addon=a, status=amo.STATUS_PUBLIC) - eq_(a.compatible_version(amo.FIREFOX.id), v) + assert a.compatible_version(amo.FIREFOX.id) == v def test_compatible_version_status(self): """ @@ -489,12 +491,12 @@ class TestAddonModels(TestCase): fully-reviewed add-on. """ a = Addon.objects.get(pk=3615) - eq_(a.status, amo.STATUS_PUBLIC) + assert a.status == amo.STATUS_PUBLIC v = self._create_new_version(addon=a, status=amo.STATUS_LITE) assert a.current_version != v - eq_(a.compatible_version(amo.FIREFOX.id), a.current_version) + assert a.compatible_version(amo.FIREFOX.id) == a.current_version def test_transformer(self): addon = Addon.objects.get(pk=3615) @@ -549,16 +551,16 @@ class TestAddonModels(TestCase): def test_delete_url(self): count = Addon.unfiltered.count() self._delete_url() - eq_(count, Addon.unfiltered.count()) + assert count == Addon.unfiltered.count() def test_delete_reason(self): """Test deleting with a reason gives the reason in the mail.""" reason = u'trêason' a = Addon.objects.get(pk=3615) a.name = u'é' - eq_(len(mail.outbox), 0) + assert len(mail.outbox) == 0 a.delete(msg='bye', reason=reason) - eq_(len(mail.outbox), 1) + assert len(mail.outbox) == 1 assert reason in mail.outbox[0].body def test_delete_incomplete_no_versions(self): @@ -589,22 +591,22 @@ class TestAddonModels(TestCase): """ a = Addon.objects.get(pk=4594) a.delete('bye') - eq_(len(mail.outbox), 1) + assert len(mail.outbox) == 1 def test_incompatible_latest_apps(self): a = Addon.objects.get(pk=3615) - eq_(a.incompatible_latest_apps(), []) + assert a.incompatible_latest_apps() == [] av = ApplicationsVersions.objects.get(pk=47881) av.max = AppVersion.objects.get(pk=97) # Firefox 2.0 av.save() a = Addon.objects.get(pk=3615) - eq_(a.incompatible_latest_apps(), [amo.FIREFOX]) + assert a.incompatible_latest_apps() == [amo.FIREFOX] # Check a search engine addon. a = Addon.objects.get(pk=4594) - eq_(a.incompatible_latest_apps(), []) + assert a.incompatible_latest_apps() == [] def test_incompatible_asterix(self): av = ApplicationsVersions.objects.get(pk=47881) @@ -613,7 +615,7 @@ class TestAddonModels(TestCase): version='5.*') av.save() a = Addon.objects.get(pk=3615) - eq_(a.incompatible_latest_apps(), []) + assert a.incompatible_latest_apps() == [] def test_icon_url(self): """ @@ -637,10 +639,10 @@ class TestAddonModels(TestCase): a = Addon.objects.get(pk=3615) a.update(icon_type='') default = 'icons/default-32.png' - eq_(a.icon_url.endswith(default), True) - eq_(a.get_icon_url(32).endswith(default), True) - eq_(a.get_icon_url(32, use_default=True).endswith(default), True) - eq_(a.get_icon_url(32, use_default=False), None) + assert a.icon_url.endswith(default) == True + assert a.get_icon_url(32).endswith(default) == True + assert a.get_icon_url(32, use_default=True).endswith(default) == True + assert a.get_icon_url(32, use_default=False) is None def test_thumbnail_url(self): """ @@ -694,15 +696,15 @@ class TestAddonModels(TestCase): def test_is_no_restart(self): a = Addon.objects.get(pk=3615) f = a.current_version.all_files[0] - eq_(f.no_restart, False) - eq_(a.is_no_restart(), False) + assert not f.no_restart + assert not a.is_no_restart() f.update(no_restart=True) - eq_(Addon.objects.get(pk=3615).is_no_restart(), True) + assert Addon.objects.get(pk=3615).is_no_restart() == True a.versions.all().delete() a._current_version = None - eq_(a.is_no_restart(), False) + assert a.is_no_restart() == False def test_is_featured(self): """Test if an add-on is globally featured""" @@ -784,7 +786,7 @@ class TestAddonModels(TestCase): after = before # Nothing special; this shouldn't change. - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after def test_newlines_ul(self): before = ("") - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after def test_newlines_ul_tight(self): before = ("There should be one nl between this and the ul.\n" @@ -810,7 +812,7 @@ class TestAddonModels(TestCase): "" "There should be no nl's above this line.") - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after def test_newlines_ul_loose(self): before = ("There should be two nl's between this and the ul.\n\n" @@ -821,7 +823,7 @@ class TestAddonModels(TestCase): "\n" "There should be one nl above this line.") - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after def test_newlines_blockquote_tight(self): before = ("There should be one nl below this.\n" @@ -832,7 +834,7 @@ class TestAddonModels(TestCase): "
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 = ("") after = ("") - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after before = ("") after = ("") - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after before = ("") after = ("") - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after before = ("") after = ("") - eq_(self.newlines_helper(before), after) + assert self.newlines_helper(before) == after # All together now before = ("