def test_send_user_info_to_mailchimp_user_updated(mocker, mailchimp_handlers): """ Assert that `send_user_info_to_mailchimp` called with appropriate params and celery task for sync is called specific number of times and is not called for User update. """ mock_task = mocker.patch.object(mailchimp_handlers, 'task_send_user_info_to_mailchimp') user = UserFactory() user.username = '******' user.save() assert mock_task.delay.call_count == 2
def test_successful_handle(self): """ Tests a UserTour is created when a new User is created. Then ensures a new UserTour is not created when the user is updated. """ assert UserTour.objects.count() == 0 user = UserFactory() tour = UserTour.objects.get(user=user) assert tour.course_home_tour_status == UserTour.CourseHomeChoices.NEW_USER_TOUR assert tour.show_courseware_tour is True user.username = '******' user.save() assert UserTour.objects.count() == 1
def test_retired_username(self): """ Ensure that a retired username cannot be registered again. """ user = UserFactory() orig_username = user.username # Fake retirement of the username. user.username = get_retired_username_by_username(orig_username) user.save() # Attempt to create another account with the same username that's been retired. self.url_params['username'] = orig_username response = self.client.post(self.url, self.url_params) self._validate_exiting_username_response(orig_username, response, self.INVALID_ERR_MSG[0], self.INVALID_ERR_MSG[1]) # lint-amnesty, pylint: disable=line-too-long