示例#1
0
 def setUp(self) -> None:
     self.author = user_recipe.make()
     self.random_user = user_recipe.make()
     self.article = mommy.make(Article, author=self.author)
     self.published_article = mommy.make(Article,
                                         author=self.author,
                                         published=True)
     self.client = APIClient()
示例#2
0
 def test_request_password_change_existing(self, mocked_send_mail):
     user = user_recipe.make()
     url = f'{reverse("accounts-request-password-change")}?email={urllib.parse.quote(user.email)}'
     response = self.client.post(url)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertTrue(ChangePasswordRequest.objects.filter(email=user.email))
     request_id = ChangePasswordRequest.objects.get(
         email=user.email).request_id
     mocked_send_mail.assert_called_once_with(
         user.email,
         f'{settings.HOST}/password-change-new/?request_id={request_id}')
示例#3
0
 def test_change_password(self):
     url = reverse('accounts-set-new-password')
     user = user_recipe.make()
     reset_request = ChangePasswordRequest.objects.create(
         email=user.email, request_id=get_random_string())
     data = {
         'request_id': reset_request.request_id,
         'password': '******'
     }
     response = self.client.post(url, data)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertTrue(
         authenticate(username=user.email, password=data['password']))
     self.assertFalse(
         ChangePasswordRequest.objects.filter(email=user.email))
示例#4
0
 def setUp(self):
     self.client = APIClient()
     self.author = user_recipe.make()
示例#5
0
 def setUp(self) -> None:
     self.client = APIClient()
     self.author = user_recipe.make()
     self.tutorial = mommy.make(Tutorial, author=self.author)
示例#6
0
 def setUp(self) -> None:
     self.user = user_recipe.make()
     self.client = APIClient()