def test_post_user_when_data_valid_but_email_already_used_should_not_create_user_and_reply_400(self):
    initial_users_count = len(self.users)
    valid_data_with_used_email = {'first_name': 'Casper', 'last_name': 'Canterville', 'email': 'example@example.com', 'password': 'dummy'}
    request = self.factory.post(reverse('v1:user-list'), data=valid_data_with_used_email, REMOTE_ADDR='0.0.0.0')
    user_detail_view = UserViewSet.as_view({'post': 'create'})
    response = user_detail_view(request)
    self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code)
    new_users_count = User.objects.count()
    self.assertEqual(initial_users_count, new_users_count)
def test_post_user_when_data_valid_but_email_already_used_should_not_create_user_and_reply_400(self):
    initial_users_count = len(self.users)
    valid_data_with_used_email = {'first_name': 'Casper', 'last_name': 'Canterville', 'email': 'example@example.com', 'password': 'dummy'}
    request = self.factory.post(reverse('v1:user-list'), data=valid_data_with_used_email, REMOTE_ADDR='0.0.0.0')
    user_detail_view = UserViewSet.as_view({'post': 'create'})
    response = user_detail_view(request)
    self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code)
    new_users_count = User.objects.count()
    self.assertEqual(initial_users_count, new_users_count)