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()
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}')
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))
def setUp(self): self.client = APIClient() self.author = user_recipe.make()
def setUp(self) -> None: self.client = APIClient() self.author = user_recipe.make() self.tutorial = mommy.make(Tutorial, author=self.author)
def setUp(self) -> None: self.user = user_recipe.make() self.client = APIClient()