コード例 #1
0
ファイル: test_permissions.py プロジェクト: Fjoerfoks/zamboni
class TestAllowAuthor(TestCase):
    fixtures = fixture('user_2519', 'webapp_337141')

    def setUp(self):
        self.permission = AllowAuthor()
        app = Webapp.objects.get(pk=337141)
        self.authors = app.authors.all()
        self.view = Mock()
        self.view.get_authors.return_value = self.authors

    def create_request(self, user_profile):
        request = RequestFactory().get('/')
        request.user = user_profile
        return request

    def test_has_permission_anonymous(self):
        request = self.create_request(user_profile=None)
        eq_(self.permission.has_permission(request, self.view), False)

    def test_has_permission_user(self):
        request = self.create_request(user_profile=self.authors[0])
        eq_(self.permission.has_permission(request, self.view), True)

    def test_has_permission_different_user(self):
        other_user_profile = UserProfile.objects.get(pk=2519)
        request = self.create_request(user_profile=other_user_profile)
        eq_(self.permission.has_permission(request, self.view), False)
コード例 #2
0
class TestAllowAuthor(TestCase):
    fixtures = fixture('user_2519', 'webapp_337141')

    def setUp(self):
        self.permission = AllowAuthor()
        app = Webapp.objects.get(pk=337141)
        self.authors = app.authors.all()
        self.view = Mock()
        self.view.get_authors.return_value = self.authors

    def create_request(self, user_profile):
        request = RequestFactory().get('/')
        request.user = user_profile
        return request

    def test_has_permission_anonymous(self):
        request = self.create_request(user_profile=None)
        eq_(self.permission.has_permission(request, self.view), False)

    def test_has_permission_user(self):
        request = self.create_request(user_profile=self.authors[0])
        eq_(self.permission.has_permission(request, self.view), True)

    def test_has_permission_different_user(self):
        other_user_profile = UserProfile.objects.get(pk=2519)
        request = self.create_request(user_profile=other_user_profile)
        eq_(self.permission.has_permission(request, self.view), False)
コード例 #3
0
ファイル: test_permissions.py プロジェクト: Fjoerfoks/zamboni
 def setUp(self):
     self.permission = AllowAuthor()
     app = Webapp.objects.get(pk=337141)
     self.authors = app.authors.all()
     self.view = Mock()
     self.view.get_authors.return_value = self.authors
コード例 #4
0
 def setUp(self):
     self.permission = AllowAuthor()
     app = Webapp.objects.get(pk=337141)
     self.authors = app.authors.all()
     self.view = Mock()
     self.view.get_authors.return_value = self.authors