Exemple #1
0
 def test_incorrect_user(self):
     self.file.user = user_factory()
     self.file.save()
     form = forms.NewWebappForm({'upload': self.file.uuid},
                                request=self.request)
     assert not form.is_valid()
     eq_(form.ERRORS['user'], form.errors['upload'])
Exemple #2
0
 def test_free(self):
     form = forms.NewWebappForm({
         'free_platforms': ['free-firefoxos'],
         'upload': self.file.uuid
     })
     assert form.is_valid()
     eq_(form.get_paid(), amo.ADDON_FREE)
Exemple #3
0
 def test_multiple(self):
     form = forms.NewWebappForm({
         'free_platforms': ['free-firefoxos', 'free-desktop'],
         'upload':
         self.file.uuid
     })
     assert form.is_valid()
Exemple #4
0
 def test_not_packaged(self):
     form = forms.NewWebappForm({
         'free_platforms': ['free-firefoxos'],
         'upload': self.file.uuid
     })
     assert form.is_valid(), form.errors
     assert not form.is_packaged()
Exemple #5
0
 def test_incorrect_user(self):
     self.file.user = UserProfile.objects.create(pk=2, username='******')
     self.file.save()
     form = forms.NewWebappForm({'upload': self.file.uuid},
                                request=self.request)
     assert not form.is_valid()
     eq_(form.ERRORS['user'], form.errors['free_platforms'])
     eq_(form.ERRORS['user'], form.errors['paid_platforms'])
Exemple #6
0
 def test_packaged_allowed_desktop(self):
     form = forms.NewWebappForm({
         'free_platforms': ['free-desktop'],
         'upload': self.file.uuid,
         'packaged': True
     })
     assert form.is_valid(), form.errors
     assert form.is_packaged()
Exemple #7
0
 def test_free(self):
     self.create_flag('allow-b2g-paid-submission')
     form = forms.NewWebappForm({
         'free_platforms': ['free-firefoxos'],
         'upload': self.file.uuid
     })
     assert form.is_valid()
     eq_(form.get_paid(), amo.ADDON_FREE)
Exemple #8
0
 def test_packaged_wrong_device(self):
     form = forms.NewWebappForm({
         'free_platforms': ['free-desktop'],
         'upload': self.file.uuid,
         'packaged': True
     })
     assert not form.is_valid(), form.errors
     eq_(form.ERRORS['packaged'], form.errors['paid_platforms'])
Exemple #9
0
 def test_correct_user(self):
     form = forms.NewWebappForm(
         {
             'free_platforms': ['free-firefoxos'],
             'upload': self.file.uuid
         },
         request=self.request)
     assert form.is_valid(), form.errors
Exemple #10
0
 def test_packaged_allowed_android(self, parse_addon):
     form = forms.NewWebappForm({
         'free_platforms': ['free-android-mobile'],
         'upload': self.file.uuid,
         'packaged': True
     })
     assert form.is_valid(), form.errors
     assert form.is_packaged()
Exemple #11
0
 def test_paid(self):
     self.create_switch('allow-b2g-paid-submission')
     form = forms.NewWebappForm({
         'paid_platforms': ['paid-firefoxos'],
         'upload': self.file.uuid
     })
     assert form.is_valid()
     eq_(form.get_paid(), amo.ADDON_PREMIUM)
Exemple #12
0
 def test_homescreen_device(self):
     form = forms.NewWebappForm(
         {
             'upload': self.file.uuid,
             'free_platforms': ['free-firefoxos'],
             'packaged': True
         },
         request=self.request)
     assert form.is_valid()
Exemple #13
0
 def test_packaged_allowed(self, parse_addon):
     parse_addon.return_value = {}
     form = forms.NewWebappForm({
         'free_platforms': ['free-firefoxos'],
         'upload': self.file.uuid,
         'packaged': True
     })
     assert form.is_valid(), form.errors
     assert form.is_packaged()
Exemple #14
0
 def test_both(self):
     self.create_switch('allow-b2g-paid-submission')
     form = forms.NewWebappForm({
         'paid_platforms': ['paid-firefoxos'],
         'free_platforms': ['free-firefoxos']
     })
     assert not form.is_valid()
     eq_(form.ERRORS['both'], form.errors['free_platforms'])
     eq_(form.ERRORS['both'], form.errors['paid_platforms'])
Exemple #15
0
 def test_paid(self):
     form = forms.NewWebappForm(
         {
             'paid_platforms': ['paid-firefoxos'],
             'upload': self.file.uuid
         },
         request=self.request)
     assert form.is_valid()
     eq_(form.get_paid(), amo.ADDON_PREMIUM)
Exemple #16
0
 def test_packaged_disallowed_behind_flag(self):
     for device in ('free-desktop', 'free-android-mobile',
                    'free-android-tablet'):
         form = forms.NewWebappForm({
             'free_platforms': [device],
             'upload': self.file.uuid,
             'packaged': True
         })
         assert not form.is_valid(), form.errors
         eq_(form.ERRORS['packaged'], form.errors['paid_platforms'])
Exemple #17
0
 def test_both(self):
     form = forms.NewWebappForm(
         {
             'paid_platforms': ['paid-firefoxos'],
             'free_platforms': ['free-firefoxos']
         },
         request=self.request)
     assert not form.is_valid()
     eq_(form.ERRORS['both'], form.errors['free_platforms'])
     eq_(form.ERRORS['both'], form.errors['paid_platforms'])
Exemple #18
0
 def test_no_user(self):
     self.file.user = None
     self.file.save()
     form = forms.NewWebappForm(
         {
             'free_platforms': ['free-firefoxos'],
             'upload': self.file.uuid
         },
         request=self.request)
     assert not form.is_valid()
     eq_(form.ERRORS['user'], form.errors['upload'])
Exemple #19
0
 def test_homescreen_wrong_device(self):
     form = forms.NewWebappForm(
         {
             'upload': self.file.uuid,
             'free_platforms': ['free-firefoxos', 'free-desktop'],
             'packaged': True
         },
         request=self.request)
     assert not form.is_valid()
     eq_(form.ERRORS['homescreen'], form.errors['free_platforms'])
     eq_(form.ERRORS['homescreen'], form.errors['paid_platforms'])
Exemple #20
0
 def test_packaged_allowed_everywhere(self):
     for device in ('free-firefoxos', 'free-desktop', 'free-android-tablet',
                    'free-android-mobile'):
         form = forms.NewWebappForm(
             {
                 'free_platforms': [device],
                 'upload': self.file.uuid,
                 'packaged': True
             },
             request=self.request)
         assert form.is_valid(), form.errors
         assert form.is_packaged()
Exemple #21
0
 def test_platform(self):
     mappings = (
         ({
             'free_platforms': ['free-firefoxos']
         }, [amo.DEVICE_GAIA]),
         ({
             'paid_platforms': ['paid-firefoxos']
         }, [amo.DEVICE_GAIA]),
         ({
             'free_platforms': ['free-firefoxos', 'free-android-mobile']
         }, [amo.DEVICE_GAIA, amo.DEVICE_MOBILE]),
         ({
             'free_platforms':
             ['free-android-mobile', 'free-android-tablet']
         }, [amo.DEVICE_MOBILE, amo.DEVICE_TABLET]),
     )
     for data, res in mappings:
         data['upload'] = self.file.uuid
         form = forms.NewWebappForm(data)
         assert form.is_valid(), form.errors
         self.assertSetEqual(res, form.get_devices())
Exemple #22
0
 def test_not_paid(self):
     form = forms.NewWebappForm({'paid_platforms': ['paid-firefoxos']})
     assert not form.is_valid()
     eq_(form.ERRORS['none'], form.errors['free_platforms'])
     eq_(form.ERRORS['none'], form.errors['paid_platforms'])