Exemplo n.º 1
0
class TestAllowNone(TestCase):
    def setUp(self):
        self.permission = AllowNone()
        self.anonymous = AnonymousUser()
        self.user = UserProfile()
        self.request = RequestFactory().get('/')
        self.request.user = self.anonymous
        self.request.amo_user = None

    def test_has_permission_anonymous(self):
        eq_(self.permission.has_permission(self.request, 'myview'), False)

    def test_has_permission_user(self):
        self.request.user = Mock()
        self.request_amo_user = Mock()
        eq_(self.permission.has_permission(self.request, 'myview'), False)

    def test_has_object_permission_anonymous(self):
        obj = Mock()
        eq_(self.permission.has_object_permission(self.request, 'myview', obj),
            False)

    def test_has_object_permission_user(self):
        self.request.user = Mock()
        self.request_amo_user = Mock()
        obj = Mock()
        eq_(self.permission.has_object_permission(self.request, 'myview', obj),
            False)
Exemplo n.º 2
0
 def setUp(self):
     self.permission = AllowNone()
     self.anonymous = AnonymousUser()
     self.user = UserProfile()
     self.request = RequestFactory().get('/')
     self.request.user = self.anonymous
     self.request.amo_user = None