Example #1
0
 def test_insert_no_image(self):
     dupe = initial(self.f)
     dupe.update(id='', image='', locale='en-US')
     data = formset(initial(self.f), dupe, initial_count=1)
     self.client.post(self.url, data)
     assert MonthlyPick.objects.count() == 2
     assert MonthlyPick.objects.all()[1].image == ''
 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)
     assert r.status_code == 200
Example #3
0
 def test_insert_long_blurb(self):
     dupe = initial(self.f)
     dupe.update(id='', blurb='x' * 201, locale='en-US')
     data = formset(initial(self.f), dupe, initial_count=1)
     r = self.client.post(self.url, data)
     assert r.context['form'].errors[1]['blurb'][0] == (
         'Ensure this value has at most 200 characters (it has 201).')
Example #4
0
 def test_unique_apps(self):
     form = self.client.get(
         self.url).context['compat_form'].initial_forms[0]
     dupe = initial(form)
     del dupe['id']
     data = self.formset(initial(form), dupe, initial_count=1)
     response = self.client.post(self.url, data)
     assert response.status_code == 200
Example #5
0
 def test_success_insert(self):
     dupe = initial(self.f)
     del dupe['id']
     dupe['locale'] = 'fr'
     data = formset(initial(self.f), dupe, initial_count=1)
     self.client.post(self.url, data)
     assert FeaturedCollection.objects.count() == 2
     assert FeaturedCollection.objects.all()[1].locale == 'fr'
Example #6
0
 def test_success_insert_no_locale(self):
     dupe = initial(self.f)
     del dupe['id']
     del dupe['locale']
     data = formset(initial(self.f), dupe, initial_count=1)
     self.client.post(self.url, data)
     assert MonthlyPick.objects.count() == 2
     assert MonthlyPick.objects.all()[1].locale == ''
Example #7
0
 def test_no_changing_platform(self):
     ctx = self.client.get(self.url).context
     compat = initial(ctx['compat_form'].forms[0])
     files = initial(ctx['file_form'].forms[0])
     files['platform'] = amo.PLATFORM_LINUX.id
     self.initial = formset(compat, **formset(files, prefix='files'))
     response = self.client.post(self.url, self.formset())
     assert response.status_code == 302
     file_ = self.get_version().files.all()[0]
     assert amo.PLATFORM_ALL.id == file_.platform
Example #8
0
 def test_disabled_autocomplete_errors(self):
     """If any collection errors, autocomplete field should be enabled."""
     data = initial(self.f)
     data['collection'] = 999
     response = self.client.post(self.url, formset(data, initial_count=1))
     doc = pq(response.content)
     assert not doc('#features .collection-ac[disabled]')
Example #9
0
 def test_bad_locale(self):
     data = initial(self.f)
     data['locale'] = 'klingon'
     response = self.client.post(self.url, formset(data, initial_count=1))
     assert response.context['form'].errors[0]['locale'] == (
         ['Select a valid choice. klingon is not one of the available '
          'choices.'])
 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))
     assert r.status_code == 302
     av = self.version.apps.all()[0]
     assert av.min == av.max
 def get_form(self, url=None):
     if not url:
         url = self.url
     av = self.version.apps.get()
     assert av.min.version == '2.0'
     assert av.max.version == '4.0'
     f = self.client.get(url).context['compat_form'].initial_forms[0]
     return initial(f)
 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))
     assert r.status_code == 200
     assert r.context['compat_form'].forms[0].non_field_errors() == (
         ['Invalid version range.'])
Example #13
0
 def test_required_app(self):
     data = initial(self.f)
     del data['application']
     response = self.client.post(self.url, formset(data, initial_count=1))
     assert response.status_code == 200
     assert response.context['form'].errors[0]['application'] == (
         ['This field is required.'])
     assert response.context['form'].errors[0]['collection'] == (
         ['Invalid collection for this application.'])
 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)
Example #15
0
 def test_same_min_max(self):
     form = self.client.get(
         self.url).context['compat_form'].initial_forms[0]
     data = initial(form)
     data['min'] = data['max']
     response = self.client.post(
         self.url, self.formset(data, initial_count=1))
     assert response.status_code == 302
     av = self.version.apps.all()[0]
     assert av.min == av.max
Example #16
0
 def test_proper_min_max(self):
     form = self.client.get(
         self.url).context['compat_form'].initial_forms[0]
     data = initial(form)
     data['min'], data['max'] = data['max'], data['min']
     response = self.client.post(
         self.url, self.formset(data, initial_count=1))
     assert response.status_code == 200
     assert response.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=288, max=298),
                      initial_count=1)
     r = self.client.post(self.url, d)
     assert r.status_code == 302
     apps = self.get_version().compatible_apps.keys()
     assert sorted(apps) == sorted([amo.FIREFOX, amo.THUNDERBIRD])
     assert list(ActivityLog.objects.all().values_list('action')) == (
         [(amo.LOG.MAX_APPVERSION_UPDATED.id,)])
 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))
     assert r.status_code == 200
     assert r.context['compat_form'].non_form_errors() == (
         ['Need at least one compatible application.'])
     assert self.version.apps.get() == old_av
Example #19
0
 def test_add_appversion(self):
     form = self.client.get(
         self.url).context['compat_form'].initial_forms[0]
     data = self.formset(
         initial(form), {'application': 18, 'min': 288, 'max': 298},
         initial_count=1)
     response = self.client.post(self.url, data)
     assert response.status_code == 302
     apps = self.get_version().compatible_apps.keys()
     assert sorted(apps) == sorted([amo.FIREFOX, amo.THUNDERBIRD])
     assert list(ActivityLog.objects.all().values_list('action')) == (
         [(amo.LOG.MAX_APPVERSION_UPDATED.id,)])
Example #20
0
 def test_add_appversion(self):
     form = self.client.get(
         self.url).context['compat_form'].initial_forms[0]
     data = self.formset(
         initial(form),
         {'application': amo.ANDROID.id, 'min': self.android_30.id,
          'max': self.android_32pre.id},
         initial_count=1)
     response = self.client.post(self.url, data)
     assert response.status_code == 302
     apps = [app.id for app in self.get_version().compatible_apps.keys()]
     assert sorted(apps) == sorted([amo.FIREFOX.id, amo.ANDROID.id])
     assert list(ActivityLog.objects.all().values_list('action')) == (
         [(amo.LOG.MAX_APPVERSION_UPDATED.id,)])
Example #21
0
    def test_require_appversion(self):
        old_av = self.version.apps.get()
        form = self.client.get(
            self.url).context['compat_form'].initial_forms[0]
        data = initial(form)
        data['DELETE'] = True
        response = self.client.post(
            self.url, self.formset(data, initial_count=1))
        assert response.status_code == 200

        compat_formset = response.context['compat_form']
        assert compat_formset.non_form_errors() == (
            ['Need at least one compatible application.'])
        assert self.version.apps.get() == old_av

        # Make sure the user can re-submit again from the page showing the
        # validation error: we should display all previously present compat
        # forms, with the DELETE bit off.
        assert compat_formset.data == compat_formset.forms[0].data
        assert compat_formset.forms[0]['DELETE'].value() is False
 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):
     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'))
Example #24
0
 def test_success_delete(self):
     data = initial(self.f)
     data['DELETE'] = True
     self.client.post(self.url, formset(data, initial_count=1))
     assert FeaturedCollection.objects.count() == 0
Example #25
0
 def test_success_update(self):
     data = initial(self.f)
     data['locale'] = 'fr'
     response = self.client.post(self.url, formset(data, initial_count=1))
     assert response.status_code == 302
     assert FeaturedCollection.objects.all()[0].locale == 'fr'
Example #26
0
 def test_success_delete(self):
     d = initial(self.f)
     d.update(DELETE=True)
     self.client.post(self.url, formset(d, initial_count=1))
     assert MonthlyPick.objects.count() == 0
Example #27
0
 def test_bad_collection(self):
     data = initial(self.f)
     data['collection'] = 999
     response = self.client.post(self.url, formset(data, initial_count=1))
     assert response.context['form'].errors[0]['collection'] == (
         ['Invalid collection for this application.'])
Example #28
0
 def test_required_collection(self):
     data = initial(self.f)
     del data['collection']
     response = self.client.post(self.url, formset(data, initial_count=1))
     assert response.context['form'].errors[0]['collection'] == (
         ['This field is required.'])
Example #29
0
 def test_success_update(self):
     data = initial(self.f)
     data['locale'] = 'fr'
     response = self.client.post(self.url, formset(data, initial_count=1))
     assert response.status_code == 302
     assert FeaturedCollection.objects.all()[0].locale == 'fr'
Example #30
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))
     assert r.status_code == 302
     assert MonthlyPick.objects.all()[0].locale == 'fr'
Example #31
0
 def test_required_collection(self):
     data = initial(self.f)
     del data['collection']
     response = self.client.post(self.url, formset(data, initial_count=1))
     assert response.context['form'].errors[0]['collection'] == (
         ['This field is required.'])
Example #32
0
 def test_success_delete(self):
     d = initial(self.f)
     d.update(DELETE=True)
     self.client.post(self.url, formset(d, initial_count=1))
     assert MonthlyPick.objects.count() == 0
Example #33
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))
     assert r.status_code == 302
     assert MonthlyPick.objects.all()[0].locale == 'fr'
Example #34
0
 def test_bad_collection(self):
     data = initial(self.f)
     data['collection'] = 999
     response = self.client.post(self.url, formset(data, initial_count=1))
     assert response.context['form'].errors[0]['collection'] == (
         ['Invalid collection for this application.'])
 def setUp(self):
     super().setUp()
     ctx = self.client.get(self.url).context
     compat = initial(ctx['compat_form'].forms[0])
     self.initial = formset(compat)
 def setUp(self):
     super(TestVersionEditDetails, self).setUp()
     ctx = self.client.get(self.url).context
     compat = initial(ctx['compat_form'].forms[0])
     self.initial = formset(compat)
Example #37
0
 def test_success_delete(self):
     data = initial(self.f)
     data['DELETE'] = True
     self.client.post(self.url, formset(data, initial_count=1))
     assert FeaturedCollection.objects.count() == 0
Example #38
0
 def test_bad_app(self):
     data = initial(self.f)
     data['application'] = 999
     response = self.client.post(self.url, formset(data, initial_count=1))
     assert response.context['form'].errors[0]['application'] == [
         'Select a valid choice. 999 is not one of the available choices.']
Example #39
0
 def test_bad_app(self):
     data = initial(self.f)
     data['application'] = 999
     response = self.client.post(self.url, formset(data, initial_count=1))
     assert response.context['form'].errors[0]['application'] == [
         'Select a valid choice. 999 is not one of the available choices.']
 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):
     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'))