コード例 #1
0
    def test_no_reupload_on_pending(self):
        self.addon.update(status=amo.STATUS_PENDING)
        req = req_factory_factory(self.addon.get_dev_url("edit"), user=self.user)
        r = edit_theme(req, self.addon.slug, self.addon)
        doc = pq(r.content)
        assert not doc("a.reupload")

        self.addon.update(status=amo.STATUS_PUBLIC)
        req = req_factory_factory(self.addon.get_dev_url("edit"), user=self.user)
        r = edit_theme(req, self.addon.slug, self.addon)
        doc = pq(r.content)
        assert doc("a.reupload")
コード例 #2
0
    def test_previous_compatible_apps_initially_selected(self):
        addon = addon_factory()
        user = user_factory()
        appversion = AppVersion.objects.create(
            application=amo.ANDROID.id, version='1.0'
        )
        ApplicationsVersions.objects.create(
            version=addon.current_version,
            application=amo.ANDROID.id,
            min=appversion,
            max=appversion,
        )

        upload = FileUpload.objects.create(
            valid=False,
            name='foo.xpi',
            user=user,
            source=amo.UPLOAD_SOURCE_DEVHUB,
            ip_address='127.0.0.64',
        )
        data = {'upload': upload.uuid}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user

        # Without an add-on, we only pre-select the default which is Firefox
        form = forms.NewUploadForm(data, request=request)
        assert form.fields['compatible_apps'].initial == [amo.FIREFOX.id]

        # with an add-on provided we pre-select the applications based on the
        # current version
        form = forms.NewUploadForm(data, request=request, addon=addon)
        assert form.fields['compatible_apps'].initial == [
            amo.FIREFOX.id,
            amo.ANDROID.id,
        ]
コード例 #3
0
ファイル: tests.py プロジェクト: phawit555/addons-server
 def test_perm_unlisted_addons(self):
     self.grant_permission(self.user, 'Addons:ReviewUnlisted')
     request = req_factory_factory('noop', user=self.user)
     assert not check_addons_reviewer(request)
     assert check_unlisted_addons_reviewer(request)
     assert not check_personas_reviewer(request)
     assert is_user_any_kind_of_reviewer(request.user)
コード例 #4
0
ファイル: test_forms.py プロジェクト: diox/olympia
 def test_firefox_default_selected(self):
     upload = FileUpload.objects.create(valid=False)
     data = {'upload': upload.uuid}
     request = req_factory_factory('/', post=True, data=data)
     request.user = user_factory()
     form = forms.NewUploadForm(data, request=request)
     assert form.fields['compatible_apps'].initial == [amo.FIREFOX.id]
コード例 #5
0
 def test_is_reviewer_for_static_theme_reviewer(self):
     self.grant_permission(self.user, 'Addons:ThemeReview')
     request = req_factory_factory('noop', user=self.user)
     assert not is_reviewer(request, self.addon)
     assert is_reviewer(request, self.statictheme)
     assert check_static_theme_reviewer(request)
     assert is_user_any_kind_of_reviewer(request.user)
コード例 #6
0
ファイル: test_forms.py プロジェクト: harshs14/addons-server
    def test_only_valid_uploads(self):
        upload = FileUpload.objects.create(valid=False)
        upload = FileUpload.objects.create(valid=False)
        data = {'upload': upload.uuid, 'compatible_apps': [amo.FIREFOX.id]}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user_factory()
        form = forms.NewUploadForm(data, request=request)
        assert ('There was an error with your upload. Please try again.'
                in form.errors.get('__all__')), form.errors

        # Admin override makes the form ignore the brokenness
        with mock.patch('olympia.access.acl.action_allowed_user') as acl:
            # For the 'Addons:Edit' permission check.
            acl.return_value = True
            data['admin_override_validation'] = True
            form = forms.NewUploadForm(data, request=request)
            assert ('There was an error with your upload. Please try'
                    not in form.errors.get('__all__')), form.errors

        upload.validation = '{"errors": 0}'
        upload.save()
        addon = Addon.objects.create()
        data.pop('admin_override_validation')
        form = forms.NewUploadForm(data, request=request, addon=addon)
        assert ('There was an error with your upload. Please try again.'
                not in form.errors.get('__all__')), form.errors
コード例 #7
0
ファイル: tests.py プロジェクト: phawit555/addons-server
 def test_is_reviewer_for_addon_reviewer(self):
     """An addon reviewer is also a persona reviewer."""
     self.grant_permission(self.user, 'Addons:Review')
     request = req_factory_factory('noop', user=self.user)
     assert is_reviewer(request, self.persona)
     assert is_reviewer(request, self.addon)
     assert is_user_any_kind_of_reviewer(request.user)
コード例 #8
0
 def test_firefox_default_selected(self):
     upload = FileUpload.objects.create(valid=False)
     data = {'upload': upload.uuid}
     request = req_factory_factory('/', post=True, data=data)
     request.user = user_factory()
     form = forms.NewUploadForm(data, request=request)
     assert form.fields['compatible_apps'].initial == [amo.FIREFOX.id]
コード例 #9
0
def test_site_permission_generator_origin_invalid(origin):
    request = req_factory_factory('/', user=user_factory())
    form = forms.SitePermissionGeneratorForm(
        {'site_permissions': _DEFAULT_SITE_PERMISSIONS, 'origin': origin},
        request=request,
    )
    assert not form.is_valid()
コード例 #10
0
ファイル: tests.py プロジェクト: diox/olympia
 def test_is_reviewer_for_static_theme_reviewer(self):
     self.grant_permission(self.user, 'Addons:ThemeReview')
     request = req_factory_factory('noop', user=self.user)
     assert not is_reviewer(request, self.persona)
     assert not is_reviewer(request, self.addon)
     assert is_reviewer(request, self.statictheme)
     assert is_user_any_kind_of_reviewer(request.user)
コード例 #11
0
    def test_throttling(self, parse_addon_mock):
        upload = FileUpload.objects.create(valid=True, name='foo.xpi')
        data = {'upload': upload.uuid, 'compatible_apps': [amo.FIREFOX.id]}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user_factory()
        request.META['REMOTE_ADDR'] = '5.6.7.8'
        with freeze_time('2019-04-08 15:16:23.42') as frozen_time:
            for x in range(0, 6):
                self._add_fake_throttling_action(
                    view_class=VersionView,
                    url='/',
                    user=request.user,
                    remote_addr=get_random_ip(),
                )

            form = forms.NewUploadForm(data, request=request)
            assert not form.is_valid()
            assert form.errors.get('__all__') == [
                'You have submitted too many uploads recently. '
                'Please try again after some time.'
            ]

            frozen_time.tick(delta=timedelta(seconds=61))
            form = forms.NewUploadForm(data, request=request)
            assert form.is_valid()
コード例 #12
0
    def test_compat_apps_widget_custom_label_class_rendered(self):
        """We are setting a custom class at the label
        of the compatibility apps multi-select to correctly render
        images.
        """
        user = user_factory()
        upload = FileUpload.objects.create(
            valid=False,
            name='foo.xpi',
            user=user,
            source=amo.UPLOAD_SOURCE_DEVHUB,
            ip_address='127.0.0.64',
        )
        data = {'upload': upload.uuid}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user
        form = forms.NewUploadForm(data, request=request)
        result = form.fields['compatible_apps'].widget.render(
            name='compatible_apps', value=amo.FIREFOX.id
        )
        assert 'class="app firefox"' in result

        result = form.fields['compatible_apps'].widget.render(
            name='compatible_apps', value=amo.ANDROID.id
        )
        assert 'class="app android"' in result
コード例 #13
0
ファイル: test_forms.py プロジェクト: diox/olympia
    def test_only_valid_uploads(self):
        upload = FileUpload.objects.create(valid=False)
        upload = FileUpload.objects.create(valid=False)
        data = {'upload': upload.uuid, 'compatible_apps': [amo.FIREFOX.id]}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user_factory()
        form = forms.NewUploadForm(data, request=request)
        assert ('There was an error with your upload. Please try again.' in
                form.errors.get('__all__')), form.errors

        # Admin override makes the form ignore the brokenness
        with mock.patch('olympia.access.acl.action_allowed_user') as acl:
            # For the 'Addons:Edit' permission check.
            acl.return_value = True
            data['admin_override_validation'] = True
            form = forms.NewUploadForm(data, request=request)
            assert ('There was an error with your upload. Please try' not in
                    form.errors.get('__all__')), form.errors

        upload.validation = '{"errors": 0}'
        upload.save()
        addon = Addon.objects.create()
        data.pop('admin_override_validation')
        form = forms.NewUploadForm(data, request=request, addon=addon)
        assert ('There was an error with your upload. Please try again.' not in
                form.errors.get('__all__')), form.errors
コード例 #14
0
    def test_valid_upload_from_different_user(self, parse_addon_mock):
        upload = FileUpload.objects.create(
            valid=True,
            name='foo.xpi',
            user=user_factory(),
            source=amo.UPLOAD_SOURCE_DEVHUB,
            ip_address='127.0.0.64',
        )
        data = {'upload': upload.uuid, 'compatible_apps': [amo.FIREFOX.id]}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user_factory()
        form = forms.NewUploadForm(data, request=request)
        assert not form.is_valid()
        assert (
            'There was an error with your upload. Please try again.'
            in form.errors.get('__all__')
        ), (form.errors)

        # Admin override can bypass
        with mock.patch('olympia.access.acl.action_allowed_user') as acl:
            # For the 'Addons:Edit' permission check.
            acl.return_value = True
            data['admin_override_validation'] = True
            form = forms.NewUploadForm(data, request=request)
            assert form.is_valid()

            # Regular users can't override
            acl.return_value = False
            form = forms.NewUploadForm(data, request=request)
            assert not form.is_valid()
            assert (
                'There was an error with your upload. Please try again.'
                in form.errors.get('__all__')
            ), form.errors
コード例 #15
0
 def test_perm_static_themes(self):
     self.grant_permission(self.user, 'Addons:ThemeReview')
     request = req_factory_factory('noop', user=self.user)
     assert not check_addons_reviewer(request)
     assert not check_unlisted_addons_reviewer(request)
     assert check_static_theme_reviewer(request)
     assert is_user_any_kind_of_reviewer(request.user)
コード例 #16
0
 def test_is_reviewer_for_addon_reviewer(self):
     """An addon reviewer is not necessarily a theme reviewer."""
     self.grant_permission(self.user, 'Addons:Review')
     request = req_factory_factory('noop', user=self.user)
     assert is_reviewer(request, self.addon)
     assert not is_reviewer(request, self.statictheme)
     assert is_user_any_kind_of_reviewer(request.user)
コード例 #17
0
    def test_previous_compatible_apps_initially_selected(self):
        addon = addon_factory()

        appversion = AppVersion.objects.create(application=amo.ANDROID.id,
                                               version='1.0')
        ApplicationsVersions.objects.create(
            version=addon.current_version,
            application=amo.ANDROID.id,
            min=appversion,
            max=appversion,
        )

        upload = FileUpload.objects.create(valid=False)
        data = {'upload': upload.uuid}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user_factory()

        # Without an add-on, we only pre-select the default which is Firefox
        form = forms.NewUploadForm(data, request=request)
        assert form.fields['compatible_apps'].initial == [amo.FIREFOX.id]

        # with an add-on provided we select the platforms based on the current
        # version
        form = forms.NewUploadForm(data, request=request, addon=addon)
        assert form.fields['compatible_apps'].initial == [
            amo.FIREFOX.id,
            amo.ANDROID.id,
        ]
コード例 #18
0
 def test_is_reviewer_for_persona_reviewer(self):
     self.grant_permission(self.user, 'Personas:Review')
     request = req_factory_factory('noop', user=self.user)
     assert is_reviewer(request, self.persona)
     assert not is_reviewer(request, self.addon)
     assert not is_reviewer(request, self.statictheme)
     assert is_user_any_kind_of_reviewer(request.user)
コード例 #19
0
ファイル: test_forms.py プロジェクト: diox/olympia
    def test_throttling(self, parse_addon_mock):
        upload = FileUpload.objects.create(valid=True, name='foo.xpi')
        data = {'upload': upload.uuid, 'compatible_apps': [amo.FIREFOX.id]}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user_factory()
        request.META['REMOTE_ADDR'] = '5.6.7.8'
        with freeze_time('2019-04-08 15:16:23.42') as frozen_time:
            for x in range(0, 6):
                self._add_fake_throttling_action(
                    view_class=VersionView,
                    url='/',
                    user=request.user,
                    remote_addr=get_random_ip(),
                )

            form = forms.NewUploadForm(data, request=request)
            assert not form.is_valid()
            assert form.errors.get('__all__') == [
                'You have submitted too many uploads recently. '
                'Please try again after some time.'
            ]

            frozen_time.tick(delta=timedelta(seconds=61))
            form = forms.NewUploadForm(data, request=request)
            assert form.is_valid()
コード例 #20
0
 def test_no_possible_categories(self):
     Category.objects.create(type=amo.ADDON_SEARCH,
                             application=amo.FIREFOX.id)
     addon = Addon.objects.create(type=amo.ADDON_SEARCH)
     request = req_factory_factory('/')
     form = forms.CategoryFormSet(addon=addon, request=request)
     apps = [f.app for f in form.forms]
     assert apps == [amo.FIREFOX]
コード例 #21
0
ファイル: test_views.py プロジェクト: Natim/addons-server
 def get_request(self, data):
     datastr = json.dumps(data)
     req = req_factory_factory(reverse('inbound-email-api'), post=True)
     req.META['REMOTE_ADDR'] = '10.10.10.10'
     req.META['CONTENT_LENGTH'] = len(datastr)
     req.META['CONTENT_TYPE'] = 'application/json'
     req._stream = StringIO.StringIO(datastr)
     return req
コード例 #22
0
ファイル: test_views.py プロジェクト: Osmose/olympia
 def get_request(self, data):
     datastr = json.dumps(data)
     req = req_factory_factory(reverse("inbound-email-api"), post=True)
     req.META["REMOTE_ADDR"] = "10.10.10.10"
     req.META["CONTENT_LENGTH"] = len(datastr)
     req.META["CONTENT_TYPE"] = "application/json"
     req._stream = StringIO.StringIO(datastr)
     return req
コード例 #23
0
 def test_no_perm(self):
     request = req_factory_factory('noop', user=self.user)
     assert not check_addons_reviewer(request)
     assert not check_unlisted_addons_reviewer(request)
     assert not check_static_theme_reviewer(request)
     assert not is_user_any_kind_of_reviewer(request.user)
     assert not is_reviewer(request, self.addon)
     assert not is_reviewer(request, self.statictheme)
コード例 #24
0
ファイル: tests.py プロジェクト: diox/olympia
 def test_perm_static_themes(self):
     self.grant_permission(self.user, 'Addons:ThemeReview')
     request = req_factory_factory('noop', user=self.user)
     assert not check_addons_reviewer(request)
     assert not check_unlisted_addons_reviewer(request)
     assert not check_personas_reviewer(request)
     assert check_static_theme_reviewer(request)
     assert is_user_any_kind_of_reviewer(request.user)
コード例 #25
0
 def test_no_perm(self):
     request = req_factory_factory('noop', user=self.user)
     assert not check_addons_reviewer(request)
     assert not check_unlisted_addons_reviewer(request)
     assert not check_personas_reviewer(request)
     assert not is_any_kind_of_reviewer(request)
     assert not is_reviewer(request, self.addon)
     assert not is_reviewer(request, self.persona)
コード例 #26
0
ファイル: tests.py プロジェクト: diox/olympia
 def test_is_reviewer_for_addon_reviewer(self):
     """An addon reviewer is not necessarily a persona reviewer."""
     self.grant_permission(self.user, 'Addons:Review')
     request = req_factory_factory('noop', user=self.user)
     assert not is_reviewer(request, self.persona)
     assert is_reviewer(request, self.addon)
     assert not is_reviewer(request, self.statictheme)
     assert is_user_any_kind_of_reviewer(request.user)
コード例 #27
0
 def get_request(self, data):
     datastr = json.dumps(data)
     req = req_factory_factory(reverse('inbound-email-api'), post=True)
     req.META['REMOTE_ADDR'] = '10.10.10.10'
     req.META['CONTENT_LENGTH'] = len(datastr)
     req.META['CONTENT_TYPE'] = 'application/json'
     req._stream = StringIO.StringIO(datastr)
     return req
コード例 #28
0
 def test_no_possible_categories(self):
     Category.objects.create(type=amo.ADDON_SEARCH,
                             application=amo.FIREFOX.id)
     addon = Addon.objects.create(type=amo.ADDON_SEARCH)
     request = req_factory_factory('/')
     form = forms.CategoryFormSet(addon=addon, request=request)
     apps = [f.app for f in form.forms]
     assert apps == [amo.FIREFOX]
コード例 #29
0
ファイル: tests.py プロジェクト: diox/olympia
 def test_no_perm(self):
     request = req_factory_factory('noop', user=self.user)
     assert not check_addons_reviewer(request)
     assert not check_unlisted_addons_reviewer(request)
     assert not check_personas_reviewer(request)
     assert not is_user_any_kind_of_reviewer(request.user)
     assert not is_reviewer(request, self.addon)
     assert not is_reviewer(request, self.persona)
     assert not is_reviewer(request, self.statictheme)
コード例 #30
0
 def test_perm_reviewertools_view(self):
     self.grant_permission(self.user, 'ReviewerTools:View')
     request = req_factory_factory('noop', user=self.user)
     assert is_user_any_kind_of_reviewer(request.user, allow_viewers=True)
     assert not is_user_any_kind_of_reviewer(request.user)
     assert not check_unlisted_addons_reviewer(request)
     assert not check_static_theme_reviewer(request)
     assert not is_reviewer(request, self.statictheme)
     assert not check_addons_reviewer(request)
     assert not is_reviewer(request, self.addon)
コード例 #31
0
ファイル: test_views.py プロジェクト: Mitrajit/addons-server
 def get_request(self, data):
     # Request body should be a bytes string, so it needs to be encoded
     # after having built the json representation of it, then fed into
     # BytesIO().
     datastr = json.dumps(data).encode('utf-8')
     req = req_factory_factory(reverse_ns('inbound-email-api'), post=True)
     req.META['REMOTE_ADDR'] = '10.10.10.10'
     req.META['CONTENT_LENGTH'] = len(datastr)
     req.META['CONTENT_TYPE'] = 'application/json'
     req._stream = io.BytesIO(datastr)
     return req
コード例 #32
0
ファイル: test_views.py プロジェクト: iamVP7/addons-server
 def get_request(self, data):
     # Request body should be a bytes string, so it needs to be encoded
     # after having built the json representation of it, then fed into
     # BytesIO().
     datastr = json.dumps(data).encode('utf-8')
     req = req_factory_factory(reverse_ns('inbound-email-api'), post=True)
     req.META['REMOTE_ADDR'] = '10.10.10.10'
     req.META['CONTENT_LENGTH'] = len(datastr)
     req.META['CONTENT_TYPE'] = 'application/json'
     req._stream = six.BytesIO(datastr)
     return req
コード例 #33
0
ファイル: test_forms.py プロジェクト: Mitrajit/addons-server
    def setUp(self):
        super().setUp()
        self.addon = Addon.objects.get(pk=3615)

        self.data = {
            'default_locale': 'en-US',
            'homepage': str(self.addon.homepage),
        }

        self.user = self.addon.authors.all()[0]
        core.set_user(self.user)
        self.request = req_factory_factory('/')
コード例 #34
0
ファイル: test_forms.py プロジェクト: diox/olympia
    def setUp(self):
        super(TestAdditionalDetailsForm, self).setUp()
        self.addon = Addon.objects.get(pk=3615)

        self.data = {
            'default_locale': 'en-US',
            'homepage': str(self.addon.homepage),
        }

        self.user = self.addon.authors.all()[0]
        core.set_user(self.user)
        self.request = req_factory_factory('/')
コード例 #35
0
    def test_perm_post_review(self):
        self.grant_permission(self.user, 'Addons:PostReview')
        request = req_factory_factory('noop', user=self.user)
        assert is_user_any_kind_of_reviewer(request.user)

        assert not check_unlisted_addons_reviewer(request)
        assert not check_static_theme_reviewer(request)
        assert not is_reviewer(request, self.statictheme)

        assert check_addons_reviewer(request)
        assert is_reviewer(request, self.addon)
        assert is_reviewer(request, self.addon, allow_content_reviewers=False)
コード例 #36
0
ファイル: tests.py プロジェクト: diox/olympia
    def test_perm_content_review(self):
        self.grant_permission(self.user, 'Addons:ContentReview')
        request = req_factory_factory('noop', user=self.user)
        assert is_user_any_kind_of_reviewer(request.user)

        assert not check_unlisted_addons_reviewer(request)
        assert not check_personas_reviewer(request)
        assert not is_reviewer(request, self.persona)
        assert not is_reviewer(request, self.statictheme)

        assert check_addons_reviewer(request)
        assert is_reviewer(request, self.addon)
コード例 #37
0
ファイル: tests.py プロジェクト: ryanleesipes/addons-server
    def test_perm_content_review(self):
        self.grant_permission(self.user, 'Addons:ContentReview')
        request = req_factory_factory('noop', user=self.user)
        assert is_user_any_kind_of_reviewer(request.user)

        assert not check_unlisted_addons_reviewer(request)
        assert not check_personas_reviewer(request)
        assert not is_reviewer(request, self.persona)
        assert not is_reviewer(request, self.statictheme)

        assert check_addons_reviewer(request)
        assert is_reviewer(request, self.addon)
コード例 #38
0
 def test_firefox_default_selected(self):
     user = user_factory()
     upload = FileUpload.objects.create(
         valid=False,
         name='foo.xpi',
         user=user,
         source=amo.UPLOAD_SOURCE_DEVHUB,
         ip_address='127.0.0.64',
     )
     data = {'upload': upload.uuid}
     request = req_factory_factory('/', post=True, data=data)
     request.user = user
     form = forms.NewUploadForm(data, request=request)
     assert form.fields['compatible_apps'].initial == [amo.FIREFOX.id]
コード例 #39
0
    def test_perm_post_review(self):
        self.grant_permission(self.user, 'Addons:PostReview')
        request = req_factory_factory('noop', user=self.user)
        assert is_any_kind_of_reviewer(request)

        assert not check_unlisted_addons_reviewer(request)
        assert not check_personas_reviewer(request)
        assert not is_reviewer(request, self.persona)

        # Technically, someone with PostReview has access to reviewer tools,
        # and would be called a reviewer... but those 2 functions predates the
        # introduction of PostReview, so at the moment they don't let you in
        # if you only have that permission.
        assert not check_addons_reviewer(request)
        assert not is_reviewer(request, self.addon)
コード例 #40
0
ファイル: test_forms.py プロジェクト: robin07/addons-server
    def setUp(self):
        super(TestAdditionalDetailsForm, self).setUp()
        self.addon = Addon.objects.get(pk=3615)
        category = Category.objects.get(pk=22)
        category.db_name = 'test'
        category.save()

        self.data = {
            'default_locale': 'en-US',
            'homepage': str(self.addon.homepage),
        }

        self.user = self.addon.authors.all()[0]
        core.set_user(self.user)
        self.request = req_factory_factory('/')
コード例 #41
0
    def setUp(self):
        super(TestTagsForm, self).setUp()
        self.addon = Addon.objects.get(pk=3615)
        category = Category.objects.get(pk=22)
        category.db_name = 'test'
        category.save()

        self.data = {
            'summary': str(self.addon.summary),
            'name': str(self.addon.name),
            'slug': self.addon.slug,
        }

        self.user = self.addon.authors.all()[0]
        amo.set_user(self.user)
        self.request = req_factory_factory('/')
コード例 #42
0
    def setUp(self):
        super(TestTagsForm, self).setUp()
        self.addon = Addon.objects.get(pk=3615)
        category = Category.objects.get(pk=22)
        category.name = 'test'
        category.save()

        self.data = {
            'summary': str(self.addon.summary),
            'name': str(self.addon.name),
            'slug': self.addon.slug,
        }

        self.user = self.addon.authors.all()[0]
        amo.set_user(self.user)
        self.request = req_factory_factory('/')
コード例 #43
0
    def test_perm_content_review(self):
        self.grant_permission(self.user, 'Addons:ContentReview')
        request = req_factory_factory('noop', user=self.user)
        assert is_any_kind_of_reviewer(request)

        assert not check_unlisted_addons_reviewer(request)
        assert not check_personas_reviewer(request)
        assert not is_reviewer(request, self.persona)

        # Technically, someone with ContentReview has access to (some of the)
        # reviewer tools, and could be called a reviewer (though they are more
        # limited than other kind of reviewers...) but those 2 functions
        # predates the introduction of PostReview, so at the moment they don't
        # let you in if you only have that permission.
        assert not check_addons_reviewer(request)
        assert not is_reviewer(request, self.addon)
コード例 #44
0
ファイル: test_forms.py プロジェクト: Mitrajit/addons-server
    def test_check_xpi_called(self, mock_check_xpi_info, mock_parse):
        """Make sure the check_xpi_info helper is called.

        There's some important checks made in check_xpi_info, if we ever
        refactor the form to not call it anymore, we need to make sure those
        checks are run at some point.
        """
        mock_parse.return_value = None
        mock_check_xpi_info.return_value = {'name': 'foo', 'type': 2}
        upload = FileUpload.objects.create(valid=True, name='foo.xpi')
        addon = Addon.objects.create()
        data = {'upload': upload.uuid, 'compatible_apps': [amo.FIREFOX.id]}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user_factory()
        form = forms.NewUploadForm(data, addon=addon, request=request)
        form.clean()
        assert mock_check_xpi_info.called
コード例 #45
0
ファイル: test_forms.py プロジェクト: diox/olympia
    def test_check_xpi_called(self, mock_check_xpi_info, mock_parse):
        """Make sure the check_xpi_info helper is called.

        There's some important checks made in check_xpi_info, if we ever
        refactor the form to not call it anymore, we need to make sure those
        checks are run at some point.
        """
        mock_parse.return_value = None
        mock_check_xpi_info.return_value = {'name': 'foo', 'type': 2}
        upload = FileUpload.objects.create(valid=True, name='foo.xpi')
        addon = Addon.objects.create()
        data = {'upload': upload.uuid, 'compatible_apps': [amo.FIREFOX.id]}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user_factory()
        form = forms.NewUploadForm(data, addon=addon, request=request)
        form.clean()
        assert mock_check_xpi_info.called
コード例 #46
0
ファイル: test_forms.py プロジェクト: diox/olympia
    def test_compat_apps_widget_custom_label_class_rendered(self):
        """We are setting a custom class at the label
        of the compatibility apps multi-select to correctly render
        images.
        """
        upload = FileUpload.objects.create(valid=False)
        data = {'upload': upload.uuid}
        request = req_factory_factory('/', post=True, data=data)
        request.user = user_factory()
        form = forms.NewUploadForm(data, request=request)
        result = form.fields['compatible_apps'].widget.render(
            name='compatible_apps', value=amo.FIREFOX.id)
        assert 'class="app firefox"' in result

        result = form.fields['compatible_apps'].widget.render(
            name='compatible_apps', value=amo.ANDROID.id)
        assert 'class="app android"' in result
コード例 #47
0
 def setUp(self):
     super(FormsTest, self).setUp()
     self.existing_name = 'Delicious Bookmarks'
     self.non_existing_name = 'Does Not Exist'
     self.error_msg = 'This name is already in use. Please choose another.'
     self.request = req_factory_factory('/')
コード例 #48
0
ファイル: tests.py プロジェクト: darktrojan/addons-server
 def test_is_editor_for_addon_reviewer(self):
     """An addon editor is also a persona editor."""
     self.grant_permission(self.user, 'Addons:Review')
     req = req_factory_factory('noop', user=self.user)
     assert is_editor(req, self.persona)
     assert is_editor(req, self.addon)
コード例 #49
0
ファイル: tests.py プロジェクト: diox/olympia
def test_anonymous_user():
    fake_request = req_factory_factory('/')
    assert not action_allowed(fake_request, amo.permissions.ANY_ADMIN)
コード例 #50
0
ファイル: tests.py プロジェクト: Alien426/addons-server
def test_anonymous_user():
    fake_request = req_factory_factory('/')
    assert not action_allowed(fake_request, amo.FIREFOX, 'Admin:%')
コード例 #51
0
ファイル: test_views.py プロジェクト: Osmose/olympia
 def get_validation_request(self, data):
     req = req_factory_factory(url=reverse("inbound-email-api"), post=True, data=data)
     req.META["REMOTE_ADDR"] = "10.10.10.10"
     return req
コード例 #52
0
ファイル: test_views.py プロジェクト: iamVP7/addons-server
 def get_validation_request(self, data):
     req = req_factory_factory(
         url=reverse_ns('inbound-email-api'), post=True, data=data)
     req.META['REMOTE_ADDR'] = '10.10.10.10'
     return req
コード例 #53
0
ファイル: tests.py プロジェクト: darktrojan/addons-server
 def test_no_perm(self):
     req = req_factory_factory('noop', user=self.user)
     assert not check_addons_reviewer(req)
     assert not check_unlisted_addons_reviewer(req)
     assert not check_personas_reviewer(req)
コード例 #54
0
ファイル: tests.py プロジェクト: darktrojan/addons-server
 def test_perm_unlisted_addons(self):
     self.grant_permission(self.user, 'Addons:ReviewUnlisted')
     req = req_factory_factory('noop', user=self.user)
     assert not check_addons_reviewer(req)
     assert check_unlisted_addons_reviewer(req)
     assert not check_personas_reviewer(req)
コード例 #55
0
 def test_desc_too_long_error(self, message_mock):
     data = {"description": "a" * 501}
     req = req_factory_factory(self.addon.get_dev_url("edit"), user=self.user, post=True, data=data)
     r = edit_theme(req, self.addon.slug, self.addon)
     doc = pq(r.content)
     assert "characters" in doc("#trans-description + ul li").text()
コード例 #56
0
ファイル: test_forms.py プロジェクト: Mitrajit/addons-server
 def test_no_possible_categories(self):
     addon = addon_factory(type=amo.ADDON_DICT)
     request = req_factory_factory('/')
     form = forms.CategoryFormSet(addon=addon, request=request)
     apps = [f.app for f in form.forms]
     assert apps == [amo.FIREFOX]
コード例 #57
0
ファイル: tests.py プロジェクト: darktrojan/addons-server
 def test_is_editor_for_persona_reviewer(self):
     self.grant_permission(self.user, 'Personas:Review')
     req = req_factory_factory('noop', user=self.user)
     assert is_editor(req, self.persona)
     assert not is_editor(req, self.addon)