コード例 #1
0
 def test_profile_middleware_no_profile(self):
     """User without profile and isn't banned"""
     req = self.request('/projects/import', method='post', data=self.data)
     req.user = get(User, profile=None)
     resp = ImportWizardView.as_view()(req)
     self.assertEqual(resp.status_code, 302)
     self.assertEqual(resp['location'], '/projects/foobar/')
コード例 #2
0
 def test_profile_middleware_no_profile(self):
     """User without profile and isn't banned"""
     req = self.request('/projects/import', method='post', data=self.data)
     req.user = get(User, profile=None)
     resp = ImportWizardView.as_view()(req)
     self.assertEqual(resp.status_code, 302)
     self.assertEqual(resp['location'], '/projects/foobar/')
コード例 #3
0
 def test_profile_middleware_spam(self, form):
     """User will be banned"""
     form.side_effect = ProjectSpamError
     req = self.request('/projects/import', method='post', data=self.data)
     req.user = get(User)
     resp = ImportWizardView.as_view()(req)
     self.assertEqual(resp.status_code, 302)
     self.assertEqual(resp['location'], '/')
     self.assertTrue(req.user.profile.banned)
コード例 #4
0
 def test_profile_middleware_spam(self, form):
     """User will be banned"""
     form.side_effect = ProjectSpamError
     req = self.request('/projects/import', method='post', data=self.data)
     req.user = get(User)
     resp = ImportWizardView.as_view()(req)
     self.assertEqual(resp.status_code, 302)
     self.assertEqual(resp['location'], '/')
     self.assertTrue(req.user.profile.banned)
コード例 #5
0
 def test_profile_middleware_banned(self):
     """User is banned"""
     req = self.request('/projects/import', method='post', data=self.data)
     req.user = get(User)
     req.user.profile.banned = True
     req.user.profile.save()
     self.assertTrue(req.user.profile.banned)
     resp = ImportWizardView.as_view()(req)
     self.assertEqual(resp.status_code, 302)
     self.assertEqual(resp['location'], '/')
コード例 #6
0
 def test_profile_middleware_banned(self):
     """User is banned"""
     req = self.request('/projects/import', method='post', data=self.data)
     req.user = get(User)
     req.user.profile.banned = True
     req.user.profile.save()
     self.assertTrue(req.user.profile.banned)
     resp = ImportWizardView.as_view()(req)
     self.assertEqual(resp.status_code, 302)
     self.assertEqual(resp['location'], '/')