Esempio n. 1
0
 def test_no_versions_include_deleted_when_checking(self):
     self.addon.current_version.delete()
     view = dec.addon_view(  # Not available on the factory
         self.func, qs=Addon.objects.all, include_deleted_when_checking_versions=True
     )
     res = view(self.request, self.addon.slug)
     assert res == mock.sentinel.OK
Esempio n. 2
0
    def wrapper(request, addon_id=None, *args, **kw):
        # Admins can see stats for every add-on regardless of its status.
        if acl.action_allowed(request, permissions.STATS_VIEW):
            qs = Addon.objects.all
        else:
            qs = Addon.objects.not_disabled_by_mozilla

        return addon_view(f, qs)(request, addon_id=addon_id, *args, **kw)
Esempio n. 3
0
    def wrapper(request, addon_id=None, *args, **kw):
        # Admins can see stats for every add-on regardless of its status.
        if acl.action_allowed(request, permissions.STATS_VIEW):
            qs = Addon.objects.all
        else:
            qs = Addon.objects.valid

        return addon_view(f, qs)(request, addon_id=addon_id, *args, **kw)
Esempio n. 4
0
 def setUp(self):
     super(TestAddonView, self).setUp()
     self.addon = Addon.objects.create(slug='x', type=1)
     self.func = mock.Mock()
     self.func.return_value = mock.sentinel.OK
     self.func.__name__ = 'mock_function'
     self.view = dec.addon_view(self.func)
     self.request = mock.Mock()
     self.slug_path = '/addon/%s/reviews' % self.addon.slug
     self.request.path = self.id_path = '/addon/%s/reviews' % self.addon.id
     self.request.GET = {}
 def setUp(self):
     super(TestAddonView, self).setUp()
     self.addon = Addon.objects.create(slug='x', type=1)
     self.func = mock.Mock()
     self.func.return_value = mock.sentinel.OK
     self.func.__name__ = 'mock_function'
     self.view = dec.addon_view(self.func)
     self.request = mock.Mock()
     self.slug_path = '/addon/%s/reviews' % self.addon.slug
     self.request.path = self.id_path = '/addon/%s/reviews' % self.addon.id
     self.request.GET = {}
Esempio n. 6
0
 def setUp(self):
     super(TestAddonView, self).setUp()
     self.addon = addon_factory()
     self.func = mock.Mock()
     self.func.return_value = mock.sentinel.OK
     self.func.__name__ = 'mock_function'
     self.view = dec.addon_view(self.func)
     self.request = mock.Mock()
     self.slug_path = urllib.quote(
         ('/addon/%s/reviews' % self.addon.slug).encode('utf8'))
     self.request.path = self.id_path = u'/addon/%s/reviews' % self.addon.id
     self.request.GET = {}
 def setUp(self):
     super(TestAddonView, self).setUp()
     self.addon = addon_factory()
     self.func = mock.Mock()
     self.func.return_value = mock.sentinel.OK
     self.func.__name__ = 'mock_function'
     self.view = dec.addon_view(self.func)
     self.request = mock.Mock()
     self.slug_path = urllib.quote(
         ('/addon/%s/reviews' % self.addon.slug).encode('utf8'))
     self.request.path = self.id_path = u'/addon/%s/reviews' % self.addon.id
     self.request.GET = {}
 def setUp(self):
     super(TestAddonView, self).setUp()
     self.addon = addon_factory()
     self.func = mock.Mock()
     self.func.return_value = mock.sentinel.OK
     self.func.__name__ = 'mock_function'
     self.view = dec.addon_view(self.func)
     self.request = mock.Mock()
     self.slug_path = ('http://testserver/addon/%s/reviews' %
                       quote(self.addon.slug.encode('utf-8')))
     self.request.path = self.id_path = (
         u'http://testserver/addon/%s/reviews' % self.addon.id)
     self.request.GET = {}
Esempio n. 9
0
 def setUp(self):
     super(TestAddonView, self).setUp()
     self.addon = addon_factory()
     self.func = mock.Mock()
     self.func.return_value = mock.sentinel.OK
     self.func.__name__ = 'mock_function'
     self.view = dec.addon_view(self.func)
     self.request = mock.Mock()
     self.slug_path = (
         'http://testserver/addon/%s/reviews' %
         quote(self.addon.slug.encode('utf-8')))
     self.request.path = self.id_path = (
         u'http://testserver/addon/%s/reviews' % self.addon.id)
     self.request.GET = {}