Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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')
Esempio n. 4
0
 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')
Esempio n. 5
0
    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])
Esempio n. 6
0
    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)
Esempio n. 7
0
 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."])
Esempio n. 8
0
 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]))
Esempio n. 9
0
    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)
Esempio n. 10
0
    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)
Esempio n. 11
0
 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)
Esempio n. 12
0
 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]))
Esempio n. 13
0
 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.'])
Esempio n. 14
0
 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)
Esempio n. 15
0
 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,)])
Esempio n. 16
0
 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)
Esempio n. 17
0
 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)
Esempio n. 18
0
 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)
Esempio n. 19
0
 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.'])
Esempio n. 20
0
 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)
Esempio n. 21
0
 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)
Esempio n. 22
0
 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,)])
Esempio n. 23
0
    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)
Esempio n. 24
0
 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)
Esempio n. 25
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')
Esempio n. 26
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")
Esempio n. 27
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']
Esempio n. 28
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']
Esempio n. 29
0
 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']
Esempio n. 30
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]])
Esempio n. 31
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]])
Esempio n. 32
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]])
Esempio n. 33
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'))
Esempio n. 34
0
 def setUp(self):
     super(TestVersionEditFiles, self).setUp()
     f = self.client.get(self.url).context['compat_form'].initial_forms[0]
     self.compat = initial(f)
Esempio n. 35
0
    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])
Esempio n. 36
0
    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
Esempio n. 37
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_(MonthlyPick.objects.count(), 0)
Esempio n. 38
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)
Esempio n. 39
0
    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])
Esempio n. 40
0
    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
Esempio n. 41
0
 def setUp(self):
     super(TestVersionEditFiles, self).setUp()
     f = self.client.get(self.url).context['compat_form'].initial_forms[0]
     self.compat = initial(f)
Esempio n. 42
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])
Esempio n. 43
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
Esempio n. 44
0
 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')
Esempio n. 45
0
 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')
Esempio n. 46
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'))
Esempio n. 47
0
 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)