コード例 #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'])
コード例 #2
0
ファイル: test_forms.py プロジェクト: j-barron/zamboni
 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)
コード例 #3
0
 def test_multiple(self):
     form = forms.NewWebappForm({
         'free_platforms': ['free-firefoxos', 'free-desktop'],
         'upload':
         self.file.uuid
     })
     assert form.is_valid()
コード例 #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()
コード例 #5
0
ファイル: test_forms.py プロジェクト: j-barron/zamboni
 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'])
コード例 #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()
コード例 #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)
コード例 #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'])
コード例 #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
コード例 #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()
コード例 #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)
コード例 #12
0
ファイル: test_forms.py プロジェクト: waseem18/zamboni
 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()
コード例 #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()
コード例 #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'])
コード例 #15
0
ファイル: test_forms.py プロジェクト: j-barron/zamboni
 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)
コード例 #16
0
ファイル: test_forms.py プロジェクト: vinu76jsr/zamboni
 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'])
コード例 #17
0
ファイル: test_forms.py プロジェクト: j-barron/zamboni
 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'])
コード例 #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'])
コード例 #19
0
ファイル: test_forms.py プロジェクト: waseem18/zamboni
 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'])
コード例 #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()
コード例 #21
0
ファイル: test_forms.py プロジェクト: j-barron/zamboni
 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())
コード例 #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'])