예제 #1
0
 def test_list_unauth(self):
     response = get_response('photo-list', 'get')
     self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
예제 #2
0
 def test_list_auth(self):
     response = get_response('photo-list', 'get', self.user1)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(len(response.data), 1)
예제 #3
0
 def test_me_view_unauth(self):
     response = get_response('me', 'get')
     self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
예제 #4
0
 def test_me_view_auth(self):
     response = get_response('me', 'get', self.user1)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data['email'], '[email protected]')
예제 #5
0
 def test_email_activation_view_wrong(self):
     token = MyToken.objects.get(user=self.user2).token
     response = get_response('email-activation',
                             'post',
                             data={'token': token[1:]})
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
예제 #6
0
 def test_phone_activation_view_wrong(self):
     code = Code.objects.get(user=self.user1).code
     response = get_response('phone-activation',
                             'post',
                             data={'code': str(code)[1:]})
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
예제 #7
0
 def test_email_activation_view(self):
     token = MyToken.objects.get(user=self.user2).token
     response = get_response('email-activation',
                             'post',
                             data={'token': token})
     self.assertEqual(response.status_code, status.HTTP_200_OK)
예제 #8
0
 def test_phone_activation_view(self):
     code = Code.objects.get(user=self.user1).code
     response = get_response('phone-activation',
                             'post',
                             data={'code': code})
     self.assertEqual(response.status_code, status.HTTP_200_OK)
예제 #9
0
 def test_comment_delete_wrong_user(self):
     response = get_response('comment-detail',
                             'delete',
                             self.user3,
                             kwargs={'pk': 1})
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
예제 #10
0
 def test_comment_post_create_blacklist(self):
     response = get_response('comment-post', 'post', self.user2, {
         'id': 1,
         'text': '123'
     })
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
예제 #11
0
 def test_comment_post_create_auth(self):
     response = get_response('comment-post', 'post', self.user1, {
         'id': 1,
         'text': '123'
     })
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
예제 #12
0
 def test_comment_post_create_unpublished(self):
     response = get_response('comment-post', 'post', self.user1, {
         'id': 2,
         'text': '123'
     })
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
예제 #13
0
 def test_comment_delete(self):
     response = get_response('comment-detail',
                             'delete',
                             self.user1,
                             kwargs={'pk': 1})
     self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)