move 'apps/webapps' app to 'mkt/webapps' (bug 733126)

This commit is contained in:
Chris Van 2012-03-13 14:10:35 -07:00
Родитель 21ff9714cf
Коммит 74adb68e15
55 изменённых файлов: 228 добавлений и 936 удалений

Просмотреть файл

@ -8,7 +8,7 @@ from addons.models import Addon
from amo.utils import chunked
from devhub.tasks import convert_purified, flag_binary, get_preview_sizes
from market.tasks import check_paypal, check_paypal_multiple
from webapps.tasks import update_manifests
from mkt.webapps.tasks import update_manifests
tasks = {
# binary-components depend on having a chrome manifest.

Просмотреть файл

@ -1871,4 +1871,4 @@ models.signals.post_delete.connect(update_incompatible_versions,
# webapps.models imports addons.models to get Addon, so we need to keep the
# Webapp import down here.
from webapps.models import Webapp
from mkt.webapps.models import Webapp

Просмотреть файл

@ -272,7 +272,7 @@ class TestCategoryForm(amo.tests.TestCase):
class TestDeviceTypeForm(amo.tests.TestCase):
fixtures = ['webapps/337141-steamcube']
fixtures = ['base/337141-steamcube']
def test_device_types(self):
dtype = DeviceType.objects.create(name='fligphone', class_name='phone')

Просмотреть файл

@ -40,7 +40,7 @@ from translations.models import TranslationSequence, Translation
from users.models import UserProfile
from versions.models import ApplicationsVersions, Version
from versions.compare import version_int
from webapps.models import Webapp
from mkt.webapps.models import Webapp
class TestAddonManager(amo.tests.TestCase):

Просмотреть файл

@ -38,7 +38,7 @@ from translations.helpers import truncate
from users.helpers import users_list
from users.models import UserProfile
from versions.models import Version
from webapps.models import Installed
from mkt.webapps.models import Installed
def norm(s):
@ -771,7 +771,7 @@ class TestPaypalStart(PaypalStart):
@patch.object(waffle, 'switch_is_active', lambda x: True)
@patch.object(settings, 'LOGIN_RATELIMIT_USER', 10)
@patch('webapps.models.create_receipt', lambda x: 'receipt')
@patch('mkt.webapps.models.create_receipt', lambda x: 'receipt')
class TestPaypalStartReceipt(PaypalStart):
def setUp(self):

Просмотреть файл

@ -43,10 +43,10 @@ from sharing.views import share as share_redirect
from stats.models import Contribution
from translations.query import order_by_translation
from versions.models import Version
from webapps.models import Installed, Webapp
from .models import Addon, Persona, FrozenAddon
from .decorators import (addon_view_factory, can_be_purchased, has_purchased,
has_not_purchased)
from mkt.webapps.models import Installed
log = commonware.log.getLogger('z.addons')
paypal_log = commonware.log.getLogger('z.paypal')

Просмотреть файл

@ -277,7 +277,7 @@ class AMOPaths(object):
@staticmethod
def sample_key():
path = 'apps/webapps/tests/sample.key'
path = 'mkt/webapps/tests/sample.key'
return os.path.join(settings.ROOT, path)

Просмотреть файл

@ -22,7 +22,7 @@ from files.models import FileUpload, Platform
from users.models import UserProfile
from versions.forms import XPIForm
from versions.models import Version, ApplicationsVersions
from webapps.models import Webapp
from mkt.webapps.models import Webapp
log = commonware.log.getLogger('z.api')

Просмотреть файл

@ -30,7 +30,6 @@ from amo.forms import AMOModelForm
from amo.urlresolvers import reverse
from amo.utils import raise_required, slugify
from amo.widgets import EmailWidget
from applications.models import Application, AppVersion
from files.models import File, FileUpload, Platform
from files.utils import parse_addon, VERSION_RE
@ -41,7 +40,7 @@ from translations.fields import TransTextarea, TransField
from translations.models import delete_translation, Translation
from translations.forms import TranslationFormMixin
from versions.models import License, Version, ApplicationsVersions
from webapps.models import Webapp
from mkt.webapps.models import Webapp
from . import tasks
paypal_log = commonware.log.getLogger('z.paypal')

Просмотреть файл

@ -49,7 +49,6 @@ from stats.models import Contribution
from translations.models import Translation
from users.models import UserProfile
from versions.models import ApplicationsVersions, License, Version
from webapps.models import Webapp
class MetaTests(amo.tests.TestCase):
@ -83,10 +82,6 @@ class HubTest(amo.tests.TestCase):
return ids
class AppHubTest(HubTest):
fixtures = ['webapps/337141-steamcube', 'base/users']
class TestHome(HubTest):
def test_addons(self):
@ -94,38 +89,6 @@ class TestHome(HubTest):
eq_(r.status_code, 200)
self.assertTemplateUsed(r, 'devhub/index.html')
@mock.patch.object(settings, 'APP_PREVIEW', True)
def test_apps(self):
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
r = self.client.get(self.url, follow=True)
self.assertRedirects(r, reverse('devhub.apps'), 302)
self.assertTemplateUsed(r, 'devhub/addons/dashboard.html')
class TestAppBreadcrumbs(AppHubTest):
def setUp(self):
super(TestAppBreadcrumbs, self).setUp()
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
@mock.patch.object(settings, 'APP_PREVIEW', True)
def test_impala_breadcrumbs(self):
r = self.client.get(reverse('devhub.apps'))
eq_(r.status_code, 200)
eq_(pq(r.content)('#breadcrumbs').length, 0)
@mock.patch.object(settings, 'APP_PREVIEW', True)
def test_legacy_breadcrumbs(self):
webapp = Webapp.objects.get(id=337141)
AddonUser.objects.create(user=self.user_profile, addon=webapp)
r = self.client.get(webapp.get_dev_url('edit'))
eq_(r.status_code, 200)
expected = [
('My Apps', reverse('devhub.apps')),
(unicode(webapp.name), None),
]
amo.tests.check_links(expected, pq(r.content)('#breadcrumbs li'))
class TestNav(HubTest):
@ -206,15 +169,6 @@ class TestDashboard(HubTest):
eq_(doc('#copyright').length, 1)
eq_(doc('#footer-links .mobile-link').length, 0)
def test_apps_layout(self):
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
doc = pq(self.client.get(self.apps_url).content)
eq_(doc('title').text(),
'Manage My Apps :: Developer Hub :: Apps Marketplace')
eq_(doc('#social-footer').length, 0)
eq_(doc('#copyright').length, 1)
eq_(doc('#footer-links .mobile-link').length, 0)
def get_action_links(self, addon_id):
r = self.client.get(self.url)
doc = pq(r.content)
@ -278,20 +232,6 @@ class TestDashboard(HubTest):
assert not item.find('p.incomplete'), (
'Unexpected message about incomplete add-on')
def test_public_app(self):
waffle.models.Switch.objects.create(name='marketplace', active=True)
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
app = Addon.objects.get(id=self.clone_addon(1)[0])
app.update(type=amo.ADDON_WEBAPP)
doc = pq(self.client.get(self.apps_url).content)
item = doc('.item[data-addonid=%s]' % app.id)
assert item.find('p.downloads'), 'Expected weekly downloads'
assert not item.find('p.users'), 'Unexpected ADU'
assert item.find('.price'), 'Expected price'
assert item.find('.item-details'), 'Expected item details'
assert not item.find('p.incomplete'), (
'Unexpected message about incomplete add-on')
def test_incomplete_addon(self):
waffle.models.Switch.objects.create(name='marketplace', active=True)
addon = Addon.objects.get(id=self.clone_addon(1)[0])
@ -304,14 +244,6 @@ class TestDashboard(HubTest):
assert item.find('p.incomplete'), (
'Expected message about incompleted add-on')
def test_incomplete_app(self):
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
app = Addon.objects.get(id=self.clone_addon(1)[0])
app.update(type=amo.ADDON_WEBAPP, status=amo.STATUS_NULL)
doc = pq(self.client.get(self.apps_url).content)
assert doc('.item[data-addonid=%s] p.incomplete' % app.id), (
'Expected message about incompleted add-on')
def test_dev_news(self):
self.clone_addon(1) # We need one to see this module
for i in xrange(7):
@ -349,70 +281,6 @@ class TestDashboard(HubTest):
strip_whitespace(datetime_filter(addon.last_updated)))
class TestAppDashboard(AppHubTest):
def setUp(self):
super(TestAppDashboard, self).setUp()
self.url = reverse('devhub.apps')
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
def test_dashboard(self):
eq_(self.client.get(self.url).status_code, 200)
def test_no_apps(self):
r = self.client.get(self.url)
eq_(pq(r.content)('#dashboard .item').length, 0)
def test_pagination(self):
# Create 10 add-ons.
self.clone_addon(10, addon_id=337141)
r = self.client.get(self.url)
doc = pq(r.content)('#dashboard')
eq_(doc('.item').length, 10)
eq_(doc('#sorter').length, 1)
eq_(doc('.paginator').length, 0)
class TestAppDashboardSorting(AppHubTest):
def setUp(self):
super(TestAppDashboardSorting, self).setUp()
self.clone_addon(3, addon_id=337141)
self.my_apps = self.user_profile.addons
self.url = reverse('devhub.apps')
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
def test_pagination(self):
doc = pq(self.client.get(self.url).content)('#dashboard')
eq_(doc('.item').length, 3)
eq_(doc('#sorter').length, 1)
eq_(doc('.paginator').length, 0)
# We want more than 10 apps so that the paginator shows up.
self.clone_addon(8, addon_id=337141)
doc = pq(self.client.get(self.url).content)('#dashboard')
eq_(doc('.item').length, 10)
eq_(doc('#sorter').length, 1)
eq_(doc('.paginator').length, 1)
doc = pq(self.client.get(self.url, dict(page=2)).content)('#dashboard')
eq_(doc('.item').length, 1)
eq_(doc('#sorter').length, 1)
eq_(doc('.paginator').length, 1)
def test_default_sort(self):
test_default_sort(self, 'name', 'name', reverse=False)
def test_newest_sort(self):
test_listing_sort(self, 'created', 'created')
def test_downloads_sort(self):
test_listing_sort(self, 'downloads', 'weekly_downloads')
def test_rating_sort(self):
test_listing_sort(self, 'rating', 'bayesian_rating')
class TestUpdateCompatibility(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'base/addon_4594_a9',
'base/addon_3615']
@ -783,14 +651,6 @@ class TestEditPayments(amo.tests.TestCase):
eq_(doc('.intro').length, 2)
eq_(doc('.intro.full-intro').length, 0)
@mock.patch.dict(jingo.env.globals['waffle'], {'switch': lambda x: True})
def test_voluntary_contributions_apps(self):
self.addon.update(type=amo.ADDON_WEBAPP)
r = self.client.get(self.url)
doc = pq(r.content)
eq_(doc('.intro').length, 1)
eq_(doc('.intro.full-intro').length, 1)
class TestDisablePayments(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'base/addon_3615']
@ -1090,14 +950,6 @@ class TestMarketplace(MarketplaceMixin, amo.tests.TestCase):
eq_(res.status_code, 302)
eq_(len(self.addon._upsell_to.all()), 1)
def test_set_upsell_wrong_type(self):
self.setup_premium()
self.other_addon.update(type=amo.ADDON_WEBAPP)
res = self.client.post(self.url, data=self.get_data())
eq_(res.status_code, 200)
eq_(len(res.context['form'].errors['free']), 1)
eq_(len(self.addon._upsell_to.all()), 0)
def test_set_upsell_required(self):
self.setup_premium()
data = self.get_data()
@ -1300,18 +1152,6 @@ class TestMarketplace(MarketplaceMixin, amo.tests.TestCase):
self.setup_premium()
assert 'no-edit' not in self.client.get(self.url).content
def test_webapp(self):
self.addon.update(type=amo.ADDON_WEBAPP)
self.setup_premium()
res = self.client.post(self.url, data={
'paypal_id': 'b@b.com',
'support_email': 'c@c.com',
'price': self.price_two.pk,
})
eq_(res.status_code, 302)
self.addon = Addon.objects.get(pk=self.addon.pk)
eq_(self.addon.support_email, 'c@c.com')
def test_wizard_denied(self):
self.addon.update(status=amo.STATUS_PUBLIC)
for x in xrange(1, 5):
@ -1384,12 +1224,6 @@ class TestIssueRefund(amo.tests.TestCase):
def test_addons_issue(self, refund, enqueue_refund):
self._test_issue(refund, enqueue_refund)
@mock.patch('stats.models.Contribution.enqueue_refund')
@mock.patch('paypal.refund')
def test_apps_issue(self, refund, enqueue_refund):
self.addon.update(type=amo.ADDON_WEBAPP, app_slug='ballin')
self._test_issue(refund, enqueue_refund)
@mock.patch('amo.messages.error')
@mock.patch('paypal.refund')
def test_only_one_issue(self, refund, error):
@ -1442,12 +1276,6 @@ class TestIssueRefund(amo.tests.TestCase):
def test_addons_decline(self, refund, enqueue_refund):
self._test_decline(refund, enqueue_refund)
@mock.patch('stats.models.Contribution.enqueue_refund')
@mock.patch('paypal.refund')
def test_apps_decline(self, refund, enqueue_refund):
self.addon.update(type=amo.ADDON_WEBAPP, app_slug='ballin')
self._test_decline(refund, enqueue_refund)
@mock.patch('stats.models.Contribution.enqueue_refund')
@mock.patch('paypal.refund')
def test_non_refundable_txn(self, refund, enqueue_refund):
@ -1848,28 +1676,6 @@ class TestProfile(TestProfileBase):
self.check(the_reason='to be hot', the_future='cold stuff')
class TestAppProfile(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'webapps/337141-steamcube']
def setUp(self):
self.client.login(username='admin@mozilla.com', password='password')
self.webapp = Addon.objects.get(id=337141)
self.url = self.webapp.get_dev_url('profile')
def test_nav_link(self):
r = self.client.get(self.url)
eq_(pq(r.content)('#edit-addon-nav li.selected a').attr('href'),
self.url)
def test_labels(self):
r = self.client.get(self.url)
eq_(r.status_code, 200)
eq_(r.context['webapp'], True)
doc = pq(r.content)
eq_(doc('label[for=the_reason] .optional').length, 1)
eq_(doc('label[for=the_future] .optional').length, 1)
class TestSubmitBase(amo.tests.TestCase):
fixtures = ['base/addon_3615', 'base/addon_5579', 'base/users']
@ -1904,15 +1710,6 @@ class TestSubmitStep1(TestSubmitBase):
"Looks like link %r to %r is still a placeholder" %
(href, ln.text))
def test_step1_apps_submit(self):
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
response = self.client.get(reverse('devhub.submit_apps.1'))
eq_(response.status_code, 200)
doc = pq(response.content)
assert doc('#site-nav').hasClass('app-nav'), 'Expected apps devhub nav'
eq_(doc('#breadcrumbs a').eq(0).attr('href'), reverse('devhub.apps'))
assert doc('h2.is_webapp'), 'Webapp submit has add-on heading'
class TestSubmitStep2(amo.tests.TestCase):
# More tests in TestCreateAddon.
@ -1927,28 +1724,11 @@ class TestSubmitStep2(amo.tests.TestCase):
r = self.client.get(reverse('devhub.submit.2'))
eq_(r.status_code, 200)
@mock.patch.object(waffle, 'flag_is_active')
def test_step_2_apps_with_cookie(self, fia):
fia.return_value = True
r = self.client.post(reverse('devhub.submit_apps.1'))
self.assertRedirects(r, reverse('devhub.submit_apps.2'))
r = self.client.get(reverse('devhub.submit_apps.2'))
eq_(r.status_code, 200)
def test_step_2_no_cookie(self):
# We require a cookie that gets set in step 1.
r = self.client.get(reverse('devhub.submit.2'), follow=True)
self.assertRedirects(r, reverse('devhub.submit.1'))
@mock.patch.object(waffle, 'flag_is_active')
def test_step_2_apps_no_cookie(self, fia):
fia.return_value = True
# We require a cookie that gets set in step 1.
r = self.client.get(reverse('devhub.submit_apps.2'), follow=True)
self.assertRedirects(r, reverse('devhub.submit_apps.1'))
class TestSubmitStep3(TestSubmitBase):
@ -1995,27 +1775,6 @@ class TestSubmitStep3(TestSubmitBase):
assert not log_items.filter(action=amo.LOG.EDIT_DESCRIPTIONS.id), (
"Creating a description needn't be logged.")
@mock.patch.object(waffle, 'flag_is_active')
def test_submit_apps_success(self, fia):
fia.return_value = True
self.get_addon().update(type=amo.ADDON_WEBAPP)
assert self.get_addon().is_webapp()
# Post and be redirected.
d = self.get_dict()
r = self.client.post(reverse('devhub.submit_apps.3', args=['a3615']),
d)
eq_(r.status_code, 302)
eq_(self.get_step().step, 4)
addon = self.get_addon()
self.assertRedirects(r, reverse('devhub.submit_apps.4',
args=[addon.slug]))
eq_(addon.name, 'Test name')
eq_(addon.app_slug, 'testname')
eq_(addon.description, 'desc')
eq_(addon.summary, 'Hello!')
def test_submit_name_unique(self):
# Make sure name is unique.
r = self.client.post(self.url, self.get_dict(name='Cooliris'))
@ -2034,52 +1793,6 @@ class TestSubmitStep3(TestSubmitBase):
error = 'This name is already in use. Please choose another.'
self.assertFormError(r, 'form', 'name', error)
def _setup_webapp(self):
# Used unique name tests for webapps
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
app = amo.tests.addon_factory(type=amo.ADDON_WEBAPP, name='Cool App')
self.assertTrue(app.is_webapp())
eq_(ReverseNameLookup(webapp=True).get(app.name), app.id)
self.get_addon().update(type=amo.ADDON_WEBAPP)
def test_submit_app_name_unique(self):
self._setup_webapp()
url = reverse('devhub.submit_apps.3', args=['a3615'])
r = self.client.post(url, self.get_dict(name='Cool App'))
error = 'This name is already in use. Please choose another.'
self.assertFormError(r, 'form', 'name', error)
def test_submit_app_name_unique_strip(self):
# Make sure we can't sneak in a name by adding a space or two.
self._setup_webapp()
url = reverse('devhub.submit_apps.3', args=['a3615'])
r = self.client.post(url, self.get_dict(name=' Cool App '))
error = 'This name is already in use. Please choose another.'
self.assertFormError(r, 'form', 'name', error)
def test_submit_app_name_unique_case(self):
# Make sure unique names aren't case sensitive.
self._setup_webapp()
url = reverse('devhub.submit_apps.3', args=['a3615'])
r = self.client.post(url, self.get_dict(name='cool app'))
error = 'This name is already in use. Please choose another.'
self.assertFormError(r, 'form', 'name', error)
def test_submit_name_required(self):
# Make sure name is required.
r = self.client.post(self.url, self.get_dict(name=''))
eq_(r.status_code, 200)
self.assertFormError(r, 'form', 'name', 'This field is required.')
def test_submit_app_name_required(self):
# Make sure name is required.
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
self.get_addon().update(type=amo.ADDON_WEBAPP)
r = self.client.post(reverse('devhub.submit_apps.3', args=['a3615']),
self.get_dict(name=''))
eq_(r.status_code, 200)
self.assertFormError(r, 'form', 'name', 'This field is required.')
def test_submit_name_length(self):
# Make sure the name isn't too long.
d = self.get_dict(name='a' * 51)
@ -2088,16 +1801,6 @@ class TestSubmitStep3(TestSubmitBase):
error = 'Ensure this value has at most 50 characters (it has 51).'
self.assertFormError(r, 'form', 'name', error)
def test_submit_app_name_length(self):
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
self.get_addon().update(type=amo.ADDON_WEBAPP)
d = self.get_dict(name='a' * 129)
r = self.client.post(reverse('devhub.submit_apps.3', args=['a3615']),
d)
eq_(r.status_code, 200)
error = 'Ensure this value has at most 128 characters (it has 129).'
self.assertFormError(r, 'form', 'name', error)
def test_submit_slug_invalid(self):
# Submit an invalid slug.
d = self.get_dict(slug='slug!!! aksl23%%')
@ -2175,37 +1878,6 @@ class TestSubmitStep3(TestSubmitBase):
eq_(version, self.addon.current_version.version)
def test_homepage_url_invalid(self):
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
self.addon.update(type=amo.ADDON_WEBAPP)
d = self.get_dict(homepage='a')
r = self.client.post(self.url, d)
self.assertFormError(r, 'form', 'homepage', 'Enter a valid URL.')
def test_support_url_invalid(self):
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
self.addon.update(type=amo.ADDON_WEBAPP)
d = self.get_dict(support_url='a')
r = self.client.post(self.url, d)
self.assertFormError(r, 'form', 'support_url', 'Enter a valid URL.')
def test_support_email_url_invalid(self):
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
self.addon.update(type=amo.ADDON_WEBAPP)
d = self.get_dict(support_email='a')
r = self.client.post(self.url, d)
self.assertFormError(r, 'form', 'support_email',
'Enter a valid e-mail address.')
def test_device_type_invalid(self):
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
waffle.models.Switch.objects.create(name='marketplace', active=True)
self.addon.update(type=amo.ADDON_WEBAPP)
d = self.get_dict(device_types=666)
res = self.client.post(self.url, d)
self.assertFormError(res, 'device_form', 'device_types',
'Select a valid choice. 666 is not one of the available choices.')
class TestSubmitStep4(TestSubmitBase):
@ -2235,22 +1907,6 @@ class TestSubmitStep4(TestSubmitBase):
eq_(r.status_code, 302)
eq_(self.get_step().step, 5)
@mock.patch.object(waffle, 'flag_is_active')
def test_apps_post(self, fia):
fia.return_value = True
self.get_addon().update(type=amo.ADDON_WEBAPP)
assert self.get_addon().is_webapp(), "Unexpected: Addon not webapp"
data_formset = self.formset_media(icon_type='')
r = self.client.post(reverse('devhub.submit_apps.4', args=['a3615']),
data_formset)
eq_(r.status_code, 302)
assert_raises(SubmitStep.DoesNotExist, self.get_step)
self.assertRedirects(r, reverse('devhub.submit_apps.5',
args=[self.get_addon().slug]))
eq_(self.get_addon().status, amo.WEBAPPS_UNREVIEWED_STATUS)
def formset_new_form(self, *args, **kw):
ctx = self.client.get(self.url).context
@ -2583,22 +2239,6 @@ class TestSubmitStep7(TestSubmitBase):
res = self.client.get(self.url)
eq_(pq(res.content)('#editor-pitch').length, 1)
def test_app_editor_pitch(self):
self.addon.update(type=amo.ADDON_WEBAPP)
res = self.client.get(self.url)
eq_(pq(res.content)('#editor-pitch').length, 0)
@mock.patch.dict(jingo.env.globals['waffle'], {'switch': lambda x: True})
def test_marketplace(self):
res = self.client.get(self.url)
eq_(pq(res.content)('#marketplace-enroll').length, 1)
@mock.patch.dict(jingo.env.globals['waffle'], {'switch': lambda x: True})
def test_marketplace_not(self):
self.addon.update(type=amo.ADDON_SEARCH)
res = self.client.get(self.url)
eq_(pq(res.content)('#marketplace-enroll').length, 0)
class TestResumeStep(TestSubmitBase):
@ -2635,11 +2275,6 @@ class TestSubmitBump(TestSubmitBase):
r = self.client.post(self.url, {'step': 4})
eq_(r.status_code, 403)
def test_apps_bump_acl(self):
r = self.client.post(reverse('devhub.submit_apps.bump',
args=['a3615']))
eq_(r.status_code, 403)
def test_bump_submit_and_redirect(self):
assert self.client.login(username='admin@mozilla.com',
password='password')
@ -2647,16 +2282,6 @@ class TestSubmitBump(TestSubmitBase):
self.assertRedirects(r, reverse('devhub.submit.4', args=['a3615']))
eq_(self.get_step().step, 4)
def test_apps_bump_submit_and_redirect(self):
assert self.client.login(username='admin@mozilla.com',
password='password')
self.get_addon().update(type=amo.ADDON_WEBAPP)
url = reverse('devhub.submit_apps.bump', args=['a3615'])
r = self.client.post(url, {'step': 4}, follow=True)
self.assertRedirects(r, reverse('devhub.submit_apps.4',
args=['a3615']))
eq_(self.get_step().step, 4)
class TestSubmitSteps(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'base/addon_3615']
@ -3433,105 +3058,6 @@ class TestCreateAddon(BaseUploadTest, UploadAddon, amo.tests.TestCase):
[u'xpi_name-0.1-linux.xpi', u'xpi_name-0.1-mac.xpi'])
class BaseWebAppTest(BaseUploadTest, UploadAddon, amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'base/platforms']
def setUp(self):
super(BaseWebAppTest, self).setUp()
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
self.manifest = os.path.join(settings.ROOT, 'apps', 'devhub', 'tests',
'addons', 'mozball.webapp')
self.upload = self.get_upload(abspath=self.manifest)
self.url = reverse('devhub.submit_apps.2')
assert self.client.login(username='regular@mozilla.com',
password='password')
self.client.post(reverse('devhub.submit_apps.1'))
def post_addon(self):
eq_(Addon.objects.count(), 0)
self.post()
return Addon.objects.get()
class TestCreateWebApp(BaseWebAppTest):
def test_page_title(self):
eq_(pq(self.client.get(self.url).content)('title').text(),
'Step 2 :: Developer Hub :: Apps Marketplace')
def test_post_app_redirect(self):
r = self.post()
addon = Addon.objects.get()
self.assertRedirects(r, reverse('devhub.submit_apps.3',
args=[addon.slug]))
def test_addon_from_uploaded_manifest(self):
addon = self.post_addon()
eq_(addon.type, amo.ADDON_WEBAPP)
eq_(addon.guid, None)
eq_(unicode(addon.name), 'MozillaBall')
eq_(addon.slug, 'app-%s' % addon.id)
eq_(addon.app_slug, 'mozillaball')
eq_(addon.summary, u'Exciting Open Web development action!')
eq_(Translation.objects.get(id=addon.summary.id, locale='it'),
u'Azione aperta emozionante di sviluppo di fotoricettore!')
def test_version_from_uploaded_manifest(self):
addon = self.post_addon()
eq_(addon.current_version.version, '1.0')
def test_file_from_uploaded_manifest(self):
addon = self.post_addon()
files = addon.current_version.files.all()
eq_(len(files), 1)
eq_(files[0].status, amo.STATUS_PUBLIC)
class TestCreateWebAppFromManifest(BaseWebAppTest):
def setUp(self):
super(TestCreateWebAppFromManifest, self).setUp()
Addon.objects.create(type=amo.ADDON_WEBAPP,
app_domain='existing-app.com')
def upload_webapp(self, manifest_url, **post_kw):
self.upload.update(name=manifest_url) # simulate JS upload
return self.post(**post_kw)
def post_manifest(self, manifest_url):
rs = self.client.post(reverse('devhub.upload_manifest'),
dict(manifest=manifest_url))
if 'json' in rs['content-type']:
rs = json.loads(rs.content)
return rs
@mock.patch.object(settings, 'WEBAPPS_UNIQUE_BY_DOMAIN', True)
def test_duplicate_domain(self):
rs = self.upload_webapp('http://existing-app.com/my.webapp',
expect_errors=True)
eq_(rs.context['new_addon_form'].errors.as_text(),
'* upload\n '
'* An app already exists on this domain, only one '
'app per domain is allowed.')
@mock.patch.object(settings, 'WEBAPPS_UNIQUE_BY_DOMAIN', False)
def test_allow_duplicate_domains(self):
self.upload_webapp('http://existing-app.com/my.webapp') # no errors
@mock.patch.object(settings, 'WEBAPPS_UNIQUE_BY_DOMAIN', True)
def test_duplicate_domain_from_js(self):
data = self.post_manifest('http://existing-app.com/my.webapp')
eq_(data['validation']['errors'], 1)
eq_(data['validation']['messages'][0]['message'],
'An app already exists on this domain, '
'only one app per domain is allowed.')
@mock.patch.object(settings, 'WEBAPPS_UNIQUE_BY_DOMAIN', False)
def test_allow_duplicate_domains_from_js(self):
rs = self.post_manifest('http://existing-app.com/my.webapp')
eq_(rs.status_code, 302)
class TestDeleteAddon(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'base/addon_3615']
@ -3554,38 +3080,6 @@ class TestDeleteAddon(amo.tests.TestCase):
eq_(Addon.objects.count(), 0)
class TestDeleteApp(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'webapps/337141-steamcube']
def setUp(self):
self.webapp = Webapp.objects.get(id=337141)
self.url = self.webapp.get_dev_url('delete')
self.versions_url = self.webapp.get_dev_url('versions')
self.client.login(username='admin@mozilla.com', password='password')
waffle.models.Flag.objects.create(name='accept-webapps', everyone=True)
def test_delete_nonincomplete(self):
# When soft deletes work, this test should be killed.
r = self.client.post(self.url, dict(password='password'))
self.assertRedirects(r, self.versions_url)
eq_(Addon.objects.count(), 1, 'App should not have been deleted.')
def test_bad_password_incomplete(self):
self.webapp.update(status=amo.STATUS_NULL)
r = self.client.post(self.url, dict(password='turd'))
self.assertRedirects(r, self.versions_url)
eq_(Addon.objects.count(), 1, 'App should not have been deleted.')
def test_delete_incomplete(self):
# When we can reauth with Persona, incomplete apps will be deletable.
# (Future cvan: Pour some out for BrowserID.)
raise SkipTest
self.webapp.update(status=amo.STATUS_NULL)
r = self.client.post(self.url, dict(password='password'))
self.assertRedirects(r, reverse('devhub.apps'))
eq_(Addon.objects.count(), 0, 'App should have been deleted.')
class TestRequestReview(amo.tests.TestCase):
fixtures = ['base/users', 'base/platforms']

Просмотреть файл

@ -76,166 +76,6 @@ class TestEdit(amo.tests.TestCase):
return result
class TestEditListingWebapp(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'webapps/337141-steamcube']
def setUp(self):
self.client.login(username='admin@mozilla.com', password='password')
self.webapp = Addon.objects.get(id=337141)
self.url = self.webapp.get_dev_url()
@mock.patch.object(settings, 'APP_PREVIEW', False)
def test_apps_context(self):
r = self.client.get(self.url)
eq_(r.context['webapp'], True)
eq_(pq(r.content)('title').text(),
'Edit Listing :: %s :: Apps Marketplace' % self.webapp.name)
def test_nav_links(self):
r = self.client.get(self.url)
doc = pq(r.content)('#edit-addon-nav')
eq_(doc.length, 1)
eq_(doc('.view-stats').length, 0)
class TestEditBasicWebapp(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'webapps/337141-steamcube']
def setUp(self):
assert self.client.login(username='admin@mozilla.com',
password='password')
Switch.objects.create(name='marketplace', active=True)
self.webapp = self.get_webapp()
self.cat = Category.objects.create(name='Games', type=amo.ADDON_WEBAPP)
self.dtype = DeviceType.objects.create(name='fligphone',
class_name='phone')
AddonCategory.objects.create(addon=self.webapp, category=self.cat)
AddonDeviceType.objects.create(addon=self.webapp,
device_type=self.dtype)
self.url = get_section_url(self.webapp, 'basic')
self.edit_url = get_section_url(self.webapp, 'basic', edit=True)
ctx = self.client.get(self.edit_url).context
self.cat_initial = initial(ctx['cat_form'].initial_forms[0])
del self.cat_initial['application']
def get_webapp(self):
return Addon.objects.get(id=337141)
def get_dict(self, **kw):
fs = formset(self.cat_initial, initial_count=1)
result = {'device_types': self.dtype, 'name': 'new name',
'slug': 'test_slug', 'summary': 'new summary'}
result.update(**kw)
result.update(fs)
return result
def test_apps_context(self):
r = self.client.get(self.url)
eq_(r.context['webapp'], True)
def test_appslug_visible(self):
r = self.client.get(self.url)
eq_(r.status_code, 200)
eq_(pq(r.content)('#slug_edit').remove('a').text(),
u'/\u2026/%s' % self.webapp.app_slug)
def test_edit_name_required(self):
r = self.client.post(self.edit_url, self.get_dict(name=''))
self.assertFormError(r, 'form', 'name', 'This field is required.')
def test_edit_name_max_length(self):
r = self.client.post(self.edit_url, self.get_dict(name='x' * 129))
self.assertFormError(r, 'form', 'name',
'Ensure this value has at most 128 characters '
'(it has 129).')
def test_edit_slug_success(self):
webapp = self.webapp
data = self.get_dict()
r = self.client.post(self.edit_url, data)
eq_(r.status_code, 200)
eq_(self.get_webapp().app_slug, data['slug'])
# Make sure only the app_slug changed.
eq_(self.get_webapp().slug, webapp.slug)
def test_edit_slug_dupe(self):
webapp = self.webapp
Addon.objects.create(type=amo.ADDON_WEBAPP, app_slug='dupe')
data = self.get_dict(slug='dupe')
r = self.client.post(self.edit_url, data)
self.assertFormError(r, 'form', 'slug',
'This slug is already in use.')
# Nothing changed.
eq_(self.get_webapp().slug, webapp.slug)
eq_(self.get_webapp().app_slug, webapp.app_slug)
def test_categories_listed(self):
r = self.client.post(self.url)
ul = pq(r.content)('#addon-categories-edit ul')
li = ul.find('li')
eq_(li.length, 1)
eq_(li.text(), unicode(self.cat.name))
def test_edit_categories_add(self):
new = Category.objects.create(name='Books', type=amo.ADDON_WEBAPP)
self.cat_initial['categories'] = [self.cat.id, new.id]
self.client.post(self.edit_url, self.get_dict())
app_cats = self.get_webapp().categories.values_list('id', flat=True)
eq_(sorted(app_cats), self.cat_initial['categories'])
def test_edit_categories_addandremove(self):
new = Category.objects.create(name='Books', type=amo.ADDON_WEBAPP)
self.cat_initial['categories'] = [new.id]
self.client.post(self.edit_url, self.get_dict())
app_cats = self.get_webapp().categories.values_list('id', flat=True)
eq_(sorted(app_cats), self.cat_initial['categories'])
def test_edit_categories_required(self):
del self.cat_initial['categories']
r = self.client.post(self.edit_url, formset(self.cat_initial,
initial_count=1))
assert_required(r.context['cat_form'].errors[0]['categories'][0])
def test_edit_categories_max(self):
new1 = Category.objects.create(name='Books', type=amo.ADDON_WEBAPP)
new2 = Category.objects.create(name='Lifestyle', type=amo.ADDON_WEBAPP)
self.cat_initial['categories'] = [self.cat.id, new1.id, new2.id]
r = self.client.post(self.edit_url, formset(self.cat_initial,
initial_count=1))
eq_(r.context['cat_form'].errors[0]['categories'],
['You can have only 2 categories.'])
def test_devices_listed(self):
r = self.client.post(self.url, self.get_dict())
ul = pq(r.content)('#addon-device-types-edit ul')
li = ul.find('li')
eq_(li.length, 1)
eq_(li.text(), self.dtype.name)
def _test_edit_devices_add(self):
new = DeviceType.objects.create(name='iSlate', class_name='slate')
data = self.get_dict()
data['device_types'] = [self.dtype.id, new.id]
self.client.post(self.edit_url, data)
devicetypes = self.get_webapp().device_types
eq_([d.id for d in devicetypes], list(data['device_types']))
def test_edit_devices_addandremove(self):
new = DeviceType.objects.create(name='iSlate', class_name='slate')
data = self.get_dict()
data['device_types'] = [new.id]
self.client.post(self.edit_url, data)
devicetypes = self.get_webapp().device_types
eq_([d.id for d in devicetypes], list(data['device_types']))
def test_edit_devices_add_required(self):
data = self.get_dict()
data['device_types'] = []
r = self.client.post(self.edit_url, data)
self.assertFormError(r, 'device_type_form', 'device_types',
'This field is required.')
class TestEditBasic(TestEdit):
def setUp(self):

Просмотреть файл

@ -345,31 +345,3 @@ class TestEditAuthor(TestOwnership):
doc = pq(res.content)
assert not 'Support' in doc('#id_form-0-role').text(), (
"Hey, the Support role shouldn't be here!")
class TestEditWebappAuthors(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'webapps/337141-steamcube']
def setUp(self):
self.client.login(username='admin@mozilla.com', password='password')
self.webapp = Addon.objects.get(id=337141)
self.url = self.webapp.get_dev_url('owner')
def test_apps_context(self):
r = self.client.get(self.url)
eq_(r.context['webapp'], True)
assert 'license_form' not in r.context, 'Unexpected license form'
assert 'policy_form' not in r.context, 'Unexpected policy form'
doc = pq(r.content)
eq_(doc('#edit-addon-nav ul').eq(0).find('a').eq(1).attr('href'),
self.url)
def test_success_add_owner(self):
u = UserProfile.objects.get(id=999)
u = dict(user=u.email, listed=True, role=amo.AUTHOR_ROLE_OWNER,
position=0)
r = self.client.post(self.url, formset(u, initial_count=0))
self.assertRedirects(r, self.url, 302)
owners = (AddonUser.objects.filter(addon=self.webapp.id)
.values_list('user', flat=True))
eq_(list(owners), [31337, 999])

Просмотреть файл

@ -1,113 +0,0 @@
from nose.tools import eq_
from pyquery import PyQuery as pq
import waffle
from addons.models import Addon
import amo
import amo.tests
from payments.models import InappConfig
class TestInappConfig(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'webapps/337141-steamcube']
def setUp(self):
waffle.models.Switch.objects.create(name='in-app-payments',
active=True)
assert self.client.login(username='admin@mozilla.com',
password='password')
self.webapp = Addon.objects.get(id=337141)
self.url = self.webapp.get_dev_url('in_app_config')
def config(self, public_key='pub-key', private_key='priv-key',
status=amo.INAPP_STATUS_ACTIVE,
postback_url='/postback', chargeback_url='/chargeback'):
return InappConfig.objects.create(public_key=public_key,
private_key=private_key,
addon=self.webapp,
status=status,
postback_url=postback_url,
chargeback_url=chargeback_url)
def post(self, data, expect_error=False):
resp = self.client.post(self.url, data, follow=True)
if not expect_error:
self.assertNoFormErrors(resp)
eq_(resp.status_code, 200)
return resp
def test_key_generation(self):
self.post(dict(chargeback_url='/chargeback', postback_url='/postback'))
inapp = InappConfig.objects.get(addon=self.webapp)
eq_(inapp.chargeback_url, '/chargeback')
eq_(inapp.postback_url, '/postback')
eq_(inapp.status, amo.INAPP_STATUS_ACTIVE)
assert inapp.public_key, 'public key was not generated'
assert inapp.private_key, 'private key was not generated'
def test_hide_inactive_keys(self):
old_inapp = self.config(status=amo.INAPP_STATUS_INACTIVE)
resp = self.client.get(self.url)
doc = pq(resp.content)
assert doc('#in-app-public-key').hasClass('not-generated')
assert doc('#in-app-private-key').hasClass('not-generated')
def test_when_not_configured(self):
resp = self.client.get(self.url)
doc = pq(resp.content)
assert doc('#in-app-public-key').hasClass('not-generated')
assert doc('#in-app-private-key').hasClass('not-generated')
def test_regenerate_keys_when_inactive(self):
old_inapp = self.config(status=amo.INAPP_STATUS_INACTIVE)
self.post(dict(chargeback_url='/chargeback', postback_url='/postback'))
inapp = InappConfig.objects.get(addon=self.webapp,
status=amo.INAPP_STATUS_ACTIVE)
assert inapp.private_key != old_inapp.private_key, (
'%s != %s' % (inapp.private_key, old_inapp.private_key))
def test_bad_urls(self):
resp = self.post(dict(chargeback_url='chargeback',
postback_url='postback'),
expect_error=True)
error = ('This URL is relative to your app domain so it must start '
'with a slash.')
eq_(resp.context['inapp_form'].errors,
{'postback_url': [error], 'chargeback_url': [error]})
def test_keys_are_preserved_on_edit(self):
self.config(public_key='exisiting-pub-key',
private_key='exisiting-priv-key')
self.post(dict(chargeback_url='/new/chargeback',
postback_url='/new/postback'))
inapp = InappConfig.objects.filter(addon=self.webapp)[0]
eq_(inapp.chargeback_url, '/new/chargeback')
eq_(inapp.postback_url, '/new/postback')
eq_(inapp.status, amo.INAPP_STATUS_ACTIVE)
eq_(inapp.public_key, 'exisiting-pub-key')
eq_(inapp.private_key, 'exisiting-priv-key')
def test_show_secret(self):
inapp = self.config()
resp = self.client.get(self.webapp.get_dev_url('in_app_secret'))
eq_(resp.content, inapp.private_key)
def test_deny_secret_to_no_auth(self):
self.config()
self.client.logout()
# Paranoid sanity check!
resp = self.client.get(self.webapp.get_dev_url('in_app_secret'))
eq_(resp.status_code, 302)
def test_deny_secret_to_non_owner(self):
self.config()
assert self.client.login(username='regular@mozilla.com',
password='password')
# Paranoid sanity check!
resp = self.client.get(self.webapp.get_dev_url('in_app_secret'))
eq_(resp.status_code, 403)
def test_deny_inactive_secrets(self):
self.config(status=amo.INAPP_STATUS_INACTIVE)
resp = self.client.get(self.webapp.get_dev_url('in_app_secret'))
eq_(resp.status_code, 404)

Просмотреть файл

@ -323,75 +323,6 @@ class TestVersion(amo.tests.TestCase):
set(['checkbox']))
class TestAppStatus(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'webapps/337141-steamcube']
def setUp(self):
self.client.login(username='admin@mozilla.com', password='password')
self.webapp = Addon.objects.get(id=337141)
self.url = self.webapp.get_dev_url('versions')
@mock.patch.object(settings, 'APP_PREVIEW', False)
def test_apps_context(self):
r = self.client.get(self.url)
eq_(r.status_code, 200)
eq_(r.context['webapp'], True)
title = 'Manage App Status'
doc = pq(r.content)
eq_(doc('title').text(),
'%s :: %s :: Apps Marketplace' % (title, self.webapp.name))
eq_(doc('h2').text(), title)
def test_nav_link(self):
r = self.client.get(self.url)
eq_(pq(r.content)('#edit-addon-nav li.selected a').attr('href'),
self.url)
def test_items(self):
doc = pq(self.client.get(self.url).content)
eq_(doc('#version-status').length, 1)
eq_(doc('#version-list').length, 0)
eq_(doc('#delete-addon').length, 0)
eq_(doc('#modal-delete').length, 0)
eq_(doc('#modal-disable').length, 1)
def test_soft_delete_items(self):
waffle.models.Switch.objects.create(name='soft_delete', active=True)
doc = pq(self.client.get(self.url).content)
eq_(doc('#version-status').length, 1)
eq_(doc('#version-list').length, 0)
eq_(doc('#delete-addon').length, 1)
eq_(doc('#modal-delete').length, 1)
eq_(doc('#modal-disable').length, 1)
def test_delete_link(self):
# When we can reauth with Persona, unskip this.
raise SkipTest
# Delete link is visible for only incomplete apps.
self.webapp.update(status=amo.STATUS_NULL)
doc = pq(self.client.get(self.url).content)
eq_(doc('#delete-addon').length, 1)
eq_(doc('#modal-delete').length, 1)
def test_no_version_list(self):
r = self.client.get(self.url)
doc = pq(r.content)
eq_(doc('#version-list').length, 0)
def test_pending(self):
self.webapp.update(status=amo.STATUS_PENDING)
r = self.client.get(self.url)
eq_(r.status_code, 200)
eq_(pq(r.content)('#version-status .status-none').length, 1)
def test_public(self):
eq_(self.webapp.status, amo.STATUS_PUBLIC)
r = self.client.get(self.url)
eq_(r.status_code, 200)
eq_(pq(r.content)('#version-status .status-fully-approved').length, 1)
class TestVersionEdit(amo.tests.TestCase):
fixtures = ['base/apps', 'base/users', 'base/addon_3615',
'base/thunderbird', 'base/platforms']

Просмотреть файл

@ -6,7 +6,7 @@ from lib.misc.urlconf_decorator import decorate
from addons.urls import ADDON_ID
from amo.decorators import write
from devhub.decorators import use_apps
from webapps.urls import APP_SLUG
from mkt.webapps.urls import APP_SLUG
from . import views
PACKAGE_NAME = '(?P<package_name>[_\w]+)'

Просмотреть файл

@ -55,7 +55,7 @@ from stats.models import Contribution
from translations.models import delete_translation
from users.models import UserProfile
from versions.models import Version
from webapps.models import Webapp
from mkt.webapps.models import Webapp
from zadmin.models import ValidationResult
from . import forms, tasks, feeds, signals

Просмотреть файл

@ -18,7 +18,7 @@ import commonware.log
from editors.models import (ViewPendingQueue, ViewFullReviewQueue,
ViewPreliminaryQueue, ViewFastTrackQueue)
from editors.sql_table import SQLTable
from webapps.models import Webapp
from mkt.webapps.models import Webapp
@register.function

Просмотреть файл

@ -29,7 +29,7 @@ from reviews.models import Review, ReviewFlag
from users.models import UserProfile
from versions.models import Version, AppVersion, ApplicationsVersions
from zadmin.models import set_config
from webapps.models import Webapp
from mkt.webapps.models import Webapp
from . test_models import create_addon_file

Просмотреть файл

@ -35,7 +35,7 @@ from editors.helpers import (ViewPendingQueueTable, ViewFullReviewQueueTable,
from reviews.forms import ReviewFlagFormSet
from reviews.models import Review, ReviewFlag
from users.models import UserProfile
from webapps.models import Webapp
from mkt.webapps.models import Webapp
from zadmin.models import get_config, set_config

Просмотреть файл

@ -152,7 +152,7 @@ def create_addon_purchase(sender, instance, **kw):
data = {'addon': instance.addon, 'user': instance.user}
purchase, created = AddonPurchase.objects.safer_get_or_create(**data)
purchase.update(type=amo.CONTRIB_PURCHASE)
from webapps.models import Installed # Circular import.
from mkt.webapps.models import Installed # Circular import.
Installed.objects.safer_get_or_create(user=instance.user,
addon=instance.addon)

Просмотреть файл

@ -36,7 +36,7 @@ class TestCronDeletes(amo.tests.TestCase):
class TestPendingRefunds(amo.tests.TestCase):
fixtures = ['webapps/337141-steamcube', 'base/users']
fixtures = ['base/337141-steamcube', 'base/users']
def create_refund(self, webapp=None):
webapp = webapp if webapp else self.webapp

Просмотреть файл

@ -4,7 +4,7 @@ from nose.tools import eq_, raises
import amo
import amo.tests
from payments.models import InappConfig, TooManyKeyGenAttempts
from webapps.models import Webapp
from mkt.webapps.models import Webapp
class TestInapp(amo.tests.TestCase):

Просмотреть файл

@ -9,7 +9,7 @@ from amo.urlresolvers import reverse
import amo.tests
from reviews import feeds
from translations.models import Translation
from webapps.models import Webapp
from mkt.webapps.models import Webapp
class FeedTest(amo.tests.TestCase):
@ -53,7 +53,7 @@ class FeedTest(amo.tests.TestCase):
class TestAppsFeed(amo.tests.TestCase):
fixtures = ['webapps/337141-steamcube']
fixtures = ['base/337141-steamcube']
def setUp(self):
self.app = Webapp.objects.get(id=337141)

Просмотреть файл

@ -26,7 +26,7 @@ from search.views import DEFAULT_NUM_PERSONAS
from tags.models import Tag
from versions.compare import num as vnum, version_int as vint, MAXVERSION
from versions.models import ApplicationsVersions
from webapps.tests.test_views import PaidAppMixin
from mkt.webapps.tests.test_views import PaidAppMixin
def test_parse_bad_type():

Просмотреть файл

@ -21,7 +21,7 @@ from amo.helpers import loc, locale_url, urlparams
from amo.utils import MenuItem, sorted_groupby
from bandwagon.models import Collection
from versions.compare import dict_from_int, version_int, version_dict
from webapps.models import Webapp
from mkt.webapps.models import Webapp
from . import forms
from .client import SearchError, CollectionsClient, PersonasClient

Просмотреть файл

@ -35,7 +35,7 @@ from stats.models import Contribution
from users.models import BlacklistedPassword, UserProfile, UserNotification
import users.notifications as email
from users.utils import EmailResetCode, UnsubscribeCode
from webapps.models import Installed
from mkt.webapps.models import Installed
def check_sidebar_links(self, expected):
@ -102,8 +102,8 @@ class TestAjax(UserViewBase):
data = json.loads(r.content)
eq_(data,
{'status': 0,
'message': 'A user with that email address does not exist, or the '
'user has not yet accepted the developer agreement.'})
'message': 'A user with that email address does not exist, or the'
' user has not yet accepted the developer agreement.'})
def test_ajax_failure_no_email(self):
r = self.client.get(reverse('users.ajax'), {'q': ''}, follow=True)
@ -1329,15 +1329,6 @@ class TestPurchases(amo.tests.TestCase):
]
check_sidebar_links(self, expected)
@patch.object(settings, 'APP_PREVIEW', True)
def test_in_apps_sidebar(self):
expected = [
('My Profile', self.user_profile.get_url_path()),
('Account Settings', reverse('users.edit')),
('My Purchases', self.url),
]
check_sidebar_links(self, expected)
def test_not_purchase(self):
self.client.logout()
eq_(self.client.get(self.url).status_code, 302)
@ -1743,25 +1734,6 @@ class TestPreapproval(amo.tests.TestCase):
eq_(doc('#preapproval').attr('action'),
reverse('users.payments.preapproval'))
@patch.object(settings, 'APP_PREVIEW', True)
def test_sidebar(self):
waffle.models.Switch.objects.create(name='marketplace', active=True)
self.url = self.get_url()
expected = [
('My Profile', self.user.get_url_path()),
('Account Settings', reverse('users.edit')),
('My Purchases', reverse('users.purchases')),
('Payment Profile', self.url),
]
check_sidebar_links(self, expected)
@patch.object(settings, 'APP_PREVIEW', True)
def test_sidebar_complete(self):
r = self.client.get(self.get_url('complete'))
eq_(r.status_code, 200)
eq_(pq(r.content)('#secondary-nav .selected').attr('href'),
self.get_url())
@patch('paypal.get_preapproval_key')
def test_fake_preapproval(self, get_preapproval_key):
get_preapproval_key.return_value = {'preapprovalKey': 'xyz'}

Просмотреть файл

@ -77,4 +77,4 @@ VALIDATOR_TIMEOUT = -1
# exists in your site.
# TASK_USER_ID = 1
WEBAPPS_RECEIPT_KEY = os.path.join(ROOT, 'apps/webapps/tests/sample.key')
WEBAPPS_RECEIPT_KEY = os.path.join(ROOT, 'mkt/webapps/tests/sample.key')

Просмотреть файл

@ -264,7 +264,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'amo.context_processors.i18n',
'amo.context_processors.global_settings',
'amo.context_processors.static_url',
'webapps.context_processors.is_webapps',
'jingo_minify.helpers.build_ids',
)
@ -376,7 +375,6 @@ INSTALLED_APPS = (
'translations',
'users',
'versions',
'webapps',
'zadmin',
'cake',

Просмотреть файл

@ -39,6 +39,7 @@ INSTALLED_APPS += (
'mkt.submit',
'mkt.experiments',
'devhub', # Put here so helpers.py doesn't get loaded first.
'webapps',
)
SUPPORTED_NONAPPS += (
# this line is here until bug 735120 is fixed.
@ -58,6 +59,7 @@ MIDDLEWARE_CLASSES += (
TEMPLATE_CONTEXT_PROCESSORS = list(TEMPLATE_CONTEXT_PROCESSORS)
TEMPLATE_CONTEXT_PROCESSORS.remove('amo.context_processors.global_settings')
TEMPLATE_CONTEXT_PROCESSORS += [
'webapps.context_processors.is_webapps',
'mkt.site.context_processors.global_settings',
'mkt.experiments.context_processors.fragment',
]

Просмотреть файл

@ -12,7 +12,7 @@ import waffle
import amo
from amo.helpers import urlparams
import amo.tests
from amo.tests import close_to_now, formset, initial
from amo.tests import formset, initial
from amo.tests.test_helpers import get_image_path
from amo.urlresolvers import reverse
from addons.models import (Addon, AddonCategory, AddonDeviceType, AddonUser,
@ -27,7 +27,7 @@ from mkt.submit.models import AppSubmissionChecklist
import paypal
from translations.models import Translation
from users.models import UserProfile
from webapps.models import Webapp
from mkt.webapps.models import Webapp
class TestSubmit(amo.tests.TestCase):

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,197 @@
[
{
"pk": 337141,
"model": "addons.addon",
"fields": {
"dev_agreement": false,
"eula": null,
"last_updated": "2011-10-18 16:28:24",
"view_source": true,
"enable_thankyou": false,
"total_downloads": 0,
"premium_type": 0,
"app_slug": "something-something",
"developer_comments": null,
"_current_version": 1268829,
"average_daily_downloads": 0,
"_backup_version": null,
"manifest_url": "http://micropipes.com/temp/steamcube.webapp",
"app_domain": "micropipes.com",
"admin_review_type": 1,
"the_future": null,
"trusted": false,
"total_contributions": null,
"locale_disambiguation": null,
"guid": null,
"weekly_downloads": 9999,
"support_url": null,
"disabled_by_user": false,
"paypal_id": "",
"average_rating": 0.0,
"wants_contributions": false,
"average_daily_users": 0,
"bayesian_rating": 0.0,
"share_count": 0,
"ts_slowness": null,
"homepage": null,
"support_email": null,
"public_stats": false,
"status": 4,
"privacy_policy": null,
"description": null,
"default_locale": "en-US",
"target_locale": null,
"suggested_amount": null,
"get_satisfaction_product": null,
"prerelease": false,
"thankyou_note": null,
"admin_review": false,
"auto_repackage": true,
"slug": "app-337141",
"external_software": false,
"highest_status": 4,
"get_satisfaction_company": null,
"name": 2425897,
"created": "2011-10-18 16:28:24",
"type": 11,
"icon_type": "image/png",
"annoying": 0,
"modified": "2011-10-18 16:29:46",
"summary": 2425898,
"nomination_message": null,
"site_specific": false,
"charity": null,
"total_reviews": 0,
"the_reason": null,
"hotness": 0.0
}
},
{
"pk": 1268829,
"model": "versions.version",
"fields": {
"has_info_request": false,
"license": null,
"created": "2011-10-18 16:28:24",
"has_editor_comment": false,
"releasenotes": null,
"approvalnotes": "",
"modified": "2011-10-18 16:28:24",
"version": "1.0",
"version_int": 1000000200100,
"reviewed": null,
"nomination": null,
"addon": 337141
}
},
{
"pk": 2527085,
"model": "translations.translation",
"fields": {
"localized_string_clean": null,
"created": "2011-10-18 16:28:24",
"locale": "en-us",
"modified": "2011-10-18 16:28:57",
"id": 2425897,
"localized_string": "Something Something!"
}
},
{
"pk": 2527086,
"model": "translations.translation",
"fields": {
"localized_string_clean": "A simple 2.5D brain teaser block puzzle game. Find out how far can you get before time runs out?",
"created": "2011-10-18 16:28:24",
"locale": "en-US",
"modified": "2011-10-18 16:28:57",
"id": 2425898,
"localized_string": "A simple 2.5D brain teaser block puzzle game. Find out how far can you get before time runs out?"
}
},
{
"pk": 2527087,
"model": "translations.translation",
"fields": {
"localized_string_clean": "",
"created": "2011-10-18 16:28:57",
"locale": "en-us",
"modified": "2011-10-18 16:28:57",
"id": 2425899,
"localized_string": ""
}
},
{
"pk": 2425898,
"model": "translations.translation",
"fields": {
"localized_string_clean": "",
"created": "2011-07-26 14:16:26",
"locale": "en-us",
"modified": "2011-07-26 14:16:26",
"id": 2326782,
"localized_string": null
}
},
{
"pk": 31337,
"model": "auth.user",
"fields": {
"username": "steamcube@mozilla.com",
"first_name": "Leet",
"last_name": "User",
"is_active": true,
"is_superuser": false,
"is_staff": false,
"last_login": "2010-05-20 13:00:37",
"groups": [],
"user_permissions": [],
"password": "",
"email": "steamcube@mozilla.com",
"date_joined": "2007-03-05 13:09:56"
}
},
{
"pk": 31337,
"model": "users.userprofile",
"fields": {
"sandboxshown": true,
"display_collections_fav": false,
"display_collections": false,
"averagerating": "3.11",
"confirmationcode": "",
"notifycompat": true,
"picture_type": "",
"occupation": "",
"homepage": "",
"email": "steamcube@mozilla.com",
"location": "",
"bio": null,
"firstname": "Leet",
"deleted": false,
"lastname": "User",
"emailhidden": true,
"user": 31337,
"password": "sha512$7b5436061f8c0902088c292c057be69fdb17312e2f71607c9c51641f5d876522$08d1d370d89e2ae92755fd03464a7276ca607c431d04a52d659f7a184f3f9918073637d82fc88981c7099c7c46a1137b9fdeb675304eb98801038905a9ee0600",
"nickname": "31337",
"username": "31337",
"display_name": "31337 \u0627\u0644\u062a\u0637\u0628",
"resetcode_expires": null,
"resetcode": "",
"created": "2007-03-05 13:09:56",
"notes": null,
"modified": "2010-05-19 16:41:22",
"notifyevents": true
}
},
{
"pk": 2818,
"model": "addons.addonuser",
"fields": {
"position": 0,
"addon": 337141,
"role": 5,
"listed": true,
"user": 31337
}
}
]

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,4 +1,4 @@
{% if webapp or WEBAPPS %}
{% set webapp, WEBAPPS = True, True %}
{% endif %}
{% extends "webapps/base.html" if WEBAPPS else "impala/base.html" %}
{% extends 'impala/base.html' %}