def test_unique_apps(self): f = self.client.get(self.url).context['compat_form'].initial_forms[0] dupe = initial(f) del dupe['id'] d = self.formset(initial(f), dupe, initial_count=1) r = self.client.post(self.url, d) eq_(r.status_code, 200)
def test_success_insert(self): dupe = initial(self.f) del dupe['id'] dupe.update(locale='fr') data = formset(initial(self.f), dupe, initial_count=1) r = self.client.post(self.url, data) eq_(FeaturedCollection.objects.count(), 2) eq_(FeaturedCollection.objects.all()[1].locale, 'fr')
def test_success_insert(self): dupe = initial(self.f) del dupe['id'] dupe.update(locale='fr') data = formset(initial(self.f), dupe, initial_count=1) self.client.post(self.url, data) eq_(FeaturedCollection.objects.count(), 2) eq_(FeaturedCollection.objects.all()[1].locale, 'fr')
def setUp(self): assert self.client.login(username='******', password='******') self.package_addon = reverse('devhub.package_addon') ctx = self.client.get(self.package_addon).context['compat_forms'] self.compat_form = initial(ctx.initial_forms[1])
def _post(self, action): ctx = self.client.get(self.url).context data_formset = formset(initial(ctx['reviews_formset'].forms[0])) data_formset['form-0-action'] = action res = self.client.post(self.url, data_formset) self.assert3xx(res, self.url)
def test_proper_min_max(self): f = self.client.get(self.url).context["compat_form"].initial_forms[0] d = initial(f) d["min"], d["max"] = d["max"], d["min"] r = self.client.post(self.url, self.formset(d, initial_count=1)) eq_(r.status_code, 200) eq_(r.context["compat_form"].forms[0].non_field_errors(), ["Invalid version range."])
def test_add_appversion(self): f = self.client.get(self.url).context["compat_form"].initial_forms[0] d = self.formset(initial(f), dict(application=18, min=28, max=29), initial_count=1) r = self.client.post(self.url, d) eq_(r.status_code, 302) apps = self.get_version().compatible_apps.keys() eq_(sorted(apps), sorted([amo.FIREFOX, amo.THUNDERBIRD]))
def setUp(self): super(TestPackager, self).setUp() self.url = reverse('devhub.package_addon') ctx = self.client.get(self.url).context['compat_forms'] self.compat_form = initial(ctx.initial_forms[1]) if not os.path.isdir(settings.PACKAGER_PATH): os.makedirs(settings.PACKAGER_PATH)
def test_same_min_max(self): f = self.client.get(self.url).context['compat_form'].initial_forms[0] d = initial(f) d['min'] = d['max'] r = self.client.post(self.url, self.formset(d, initial_count=1)) eq_(r.status_code, 302) av = self.version.apps.all()[0] eq_(av.min, av.max)
def test_add_appversion(self): f = self.client.get(self.url).context['compat_form'].initial_forms[0] d = self.formset(initial(f), dict(application=18, min=28, max=29), initial_count=1) r = self.client.post(self.url, d) eq_(r.status_code, 302) apps = self.get_version().compatible_apps.keys() eq_(sorted(apps), sorted([amo.FIREFOX, amo.THUNDERBIRD]))
def test_proper_min_max(self): f = self.client.get(self.url).context['compat_form'].initial_forms[0] d = initial(f) d['min'], d['max'] = d['max'], d['min'] r = self.client.post(self.url, self.formset(d, initial_count=1)) eq_(r.status_code, 200) eq_(r.context['compat_form'].forms[0].non_field_errors(), ['Invalid version range.'])
def test_add_appversion(self): f = self.client.get(self.url).context["compat_form"].initial_forms[0] d = self.formset(initial(f), dict(application=18, min=28, max=29), initial_count=1) r = self.client.post(self.url, d) eq_(r.status_code, 302) apps = self.get_version().compatible_apps.keys() eq_(sorted(apps), sorted([amo.FIREFOX, amo.THUNDERBIRD])) eq_(list(ActivityLog.objects.all().values_list("action")), [(amo.LOG.MAX_APPVERSION_UPDATED.id,)])
def get_form(self, url=None): if not url: url = self.url av = self.version.apps.get() eq_(av.min.version, '2.0') eq_(av.max.version, '3.7a1pre') f = self.client.get(url).context['compat_form'].initial_forms[0] return initial(f)
def get_form(self, url=None): if not url: url = self.url av = self.version.apps.get() eq_(av.min.version, "2.0") eq_(av.max.version, "4.0") f = self.client.get(url).context["compat_form"].initial_forms[0] return initial(f)
def get_form(self, url=None): if not url: url = self.url av = self.version.apps.get() eq_(av.min.version, '2.0') eq_(av.max.version, '4.0') f = self.client.get(url).context['compat_form'].initial_forms[0] return initial(f)
def test_require_appversion(self): old_av = self.version.apps.get() f = self.client.get(self.url).context["compat_form"].initial_forms[0] d = initial(f) d["DELETE"] = True r = self.client.post(self.url, self.formset(d, initial_count=1)) eq_(r.status_code, 200) eq_(r.context["compat_form"].non_form_errors(), ["Need at least one compatible application."]) eq_(self.version.apps.get(), old_av)
def test_require_appversion(self): old_av = self.version.apps.get() f = self.client.get(self.url).context['compat_form'].initial_forms[0] d = initial(f) d['DELETE'] = True r = self.client.post(self.url, self.formset(d, initial_count=1)) eq_(r.status_code, 200) eq_(r.context['compat_form'].non_form_errors(), ['Need at least one compatible application.']) eq_(self.version.apps.get(), old_av)
def test_add_appversion(self): f = self.client.get(self.url).context['compat_form'].initial_forms[0] d = self.formset(initial(f), dict(application=18, min=288, max=298), initial_count=1) r = self.client.post(self.url, d) eq_(r.status_code, 302) apps = self.get_version().compatible_apps.keys() eq_(sorted(apps), sorted([amo.FIREFOX, amo.THUNDERBIRD])) eq_(list(ActivityLog.objects.all().values_list('action')), [(amo.LOG.MAX_APPVERSION_UPDATED.id,)])
def setup_actions(self, action): ctx = self.client.get(self.url).context fs = initial(ctx['reviews_formset'].forms[0]) eq_(len(Review.objects.filter(addon=1865)), 2) data_formset = formset(fs) data_formset['form-0-action'] = action r = self.client.post(reverse('editors.queue_moderated'), data_formset) eq_(r.status_code, 302)
def setUp(self): super(TestEditTechnical, self).setUp() self.dependent_addon = Addon.objects.get(id=5579) AddonDependency.objects.create(addon=self.addon, dependent_addon=self.dependent_addon) self.technical_url = self.get_url('technical') self.technical_edit_url = self.get_url('technical', edit=True) ctx = self.client.get(self.technical_edit_url).context self.dep = initial(ctx['dependency_form'].initial_forms[0]) self.dep_initial = formset(self.dep, prefix='dependencies', initial_count=1)
def test_update_appversion(self): av = self.version.apps.get() eq_(av.min.version, '2.0') eq_(av.max.version, '3.7a1pre') f = self.client.get(self.url).context['compat_form'].initial_forms[0] d = initial(f) d.update(min=self.v1.id, max=self.v4.id) r = self.client.post(self.url, self.formset(d, initial_count=1)) eq_(r.status_code, 302) av = self.version.apps.get() eq_(av.min.version, '1.0') eq_(av.max.version, '4.0')
def test_update_appversion(self): av = self.version.apps.get() eq_(av.min.version, "2.0") eq_(av.max.version, "3.7a1pre") f = self.client.get(self.url).context["compat_form"].initial_forms[0] d = initial(f) d.update(min=self.v1.id, max=self.v4.id) r = self.client.post(self.url, self.formset(d, initial_count=1)) eq_(r.status_code, 302) av = self.version.apps.get() eq_(av.min.version, "1.0") eq_(av.max.version, "4.0")
def setUp(self): super(TestEditBasic, self).setUp() Switch.objects.create(name='marketplace', active=True) 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 = self.get_url('basic') self.edit_url = self.get_url('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 setUp(self): assert self.client.login(username='******', 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 test_edit_preview_delete(self): self.preview_add() self.preview_add() orig_previews = self.get_webapp().previews.all() # Delete second preview. Keep the first. edited = {'DELETE': 'checked', 'upload_hash': 'xxx', 'id': orig_previews[1].id, 'position': 0, 'file_upload': None} ctx = self.client.get(self.edit_url).context first = initial(ctx['preview_form'].forms[0]) first['upload_hash'] = 'xxx' data_formset = self.formset_media(edited, *(first,), initial_count=2) r = self.client.post(self.edit_url, data_formset) self.assertNoFormErrors(r) # First one should still be there. eq_(list(self.get_webapp().previews.all()), [orig_previews[0]])
def test_edit_preview_delete(self): self.preview_add() self.preview_add() orig_previews = self.get_webapp().previews.all() # Delete second preview. Keep the first. edited = { 'DELETE': 'checked', 'upload_hash': 'xxx', 'id': orig_previews[1].id, 'position': 0, 'file_upload': None } ctx = self.client.get(self.edit_url).context first = initial(ctx['preview_form'].forms[0]) first['upload_hash'] = 'xxx' data_formset = self.formset_media(edited, *(first, ), initial_count=2) r = self.client.post(self.edit_url, data_formset) self.assertNoFormErrors(r) # First one should still be there. eq_(list(self.get_webapp().previews.all()), [orig_previews[0]])
def test_edit_preview_delete(self): self.preview_add() self.preview_add() orig_previews = self.get_webapp().previews.all() # Delete second preview. Keep the first. edited = { "DELETE": "checked", "upload_hash": "xxx", "id": orig_previews[1].id, "position": 0, "file_upload": None, } ctx = self.client.get(self.edit_url).context first = initial(ctx["preview_form"].forms[0]) first["upload_hash"] = "xxx" data_formset = self.formset_media(edited, *(first,), initial_count=2) r = self.client.post(self.edit_url, data_formset) self.assertNoFormErrors(r) # First one should still be there. eq_(list(self.get_webapp().previews.all()), [orig_previews[0]])
def setUp(self): super(TestVersionEditDetails, self).setUp() ctx = self.client.get(self.url).context compat = initial(ctx['compat_form'].forms[0]) files = initial(ctx['file_form'].forms[0]) self.initial = formset(compat, **formset(files, prefix='files'))
def setUp(self): super(TestVersionEditFiles, self).setUp() f = self.client.get(self.url).context['compat_form'].initial_forms[0] self.compat = initial(f)
def setUp(self): self.url = reverse('devhub.package_addon') ctx = self.client.get(self.url).context['compat_forms'] self.compat_form = initial(ctx.initial_forms[1])
def new_preview_formset(self, *args, **kw): ctx = self.client.get(self.url).context blank = initial(ctx['form_previews'].forms[-1]) blank.update(**kw) return blank
def test_success_delete(self): d = initial(self.f) d.update(DELETE=True) r = self.client.post(self.url, formset(d, initial_count=1)) eq_(MonthlyPick.objects.count(), 0)
def test_success_delete(self): d = initial(self.f) d.update(DELETE=True) r = self.client.post(self.url, formset(d, initial_count=1)) eq_(FeaturedCollection.objects.count(), 0)
def setUp(self): super(TestEditBasic, self).setUp() self.basic_edit_url = self.get_url('basic', edit=True) ctx = self.client.get(self.basic_edit_url).context self.cat_initial = initial(ctx['cat_form'].initial_forms[0])
def formset_new_form(self, *args, **kw): ctx = self.client.get(self.media_edit_url).context blank = initial(ctx['preview_form'].forms[-1]) blank.update(**kw) return blank
def test_success_update(self): d = initial(self.f) d.update(locale='fr') r = self.client.post(self.url, formset(d, initial_count=1)) eq_(r.status_code, 302) eq_(FeaturedCollection.objects.all()[0].locale, 'fr')
def test_success_delete(self): d = initial(self.f) d.update(DELETE=True) self.client.post(self.url, formset(d, initial_count=1)) eq_(FeaturedCollection.objects.count(), 0)