find&replace eq_ with assert - just /olympia/addons/
This commit is contained in:
Родитель
0b3b7c979b
Коммит
7b6ebbfb71
|
@ -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
|
||||
|
|
|
@ -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 '
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
@ -82,7 +81,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):
|
||||
"""
|
||||
|
@ -92,25 +91,25 @@ 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):
|
||||
form = forms.AddonFormDetails(
|
||||
{'homepage': 'whatever://something'}, 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()
|
||||
|
@ -124,7 +123,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.'])
|
||||
|
||||
|
||||
|
@ -161,24 +160,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('<script>alert("foo")</script>, 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:
|
||||
|
@ -193,10 +192,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')
|
||||
|
@ -204,12 +203,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')
|
||||
|
@ -217,12 +216,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):
|
||||
|
@ -237,7 +236,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))
|
||||
|
@ -249,8 +248,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):
|
||||
|
@ -324,7 +324,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):
|
||||
|
|
|
@ -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), '<h5 class="flag">Not Reviewed</h5>')
|
||||
assert flag(ctx, a) == '<h5 class="flag">Not Reviewed</h5>'
|
||||
|
||||
# featured
|
||||
featured = Addon.objects.get(pk=1003)
|
||||
eq_(flag(ctx, featured), '<h5 class="flag">Featured</h5>')
|
||||
assert flag(ctx, featured) == '<h5 class="flag">Featured</h5>'
|
||||
|
||||
# category featured
|
||||
featured = Addon.objects.get(pk=1001)
|
||||
eq_(flag(ctx, featured), '<h5 class="flag">Featured</h5>')
|
||||
assert flag(ctx, featured) == '<h5 class="flag">Featured</h5>'
|
||||
|
||||
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()
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче