csv_import: do not send creation email when simulating (#53453)
This commit is contained in:
parent
c51adcfee8
commit
7eee08d081
|
@ -369,6 +369,7 @@ class UserCsvImporter(object):
|
|||
self._missing_roles = set()
|
||||
self.csv_importer = CsvImporter()
|
||||
self.max_user_id = User.objects.aggregate(max=models.Max('id'))['max'] or -1
|
||||
self.simulate = simulate
|
||||
|
||||
def parse_csv():
|
||||
if not self.csv_importer.run(fd_or_str, encoding):
|
||||
|
@ -777,7 +778,7 @@ class UserCsvImporter(object):
|
|||
return True
|
||||
|
||||
def registration_option(self, cell, user):
|
||||
if cell.value == REGISTRATION_RESET_EMAIL:
|
||||
if cell.value == REGISTRATION_RESET_EMAIL and not self.simulate:
|
||||
send_password_reset_mail(
|
||||
user,
|
||||
template_names=[
|
||||
|
|
|
@ -533,7 +533,10 @@ def test_csv_registration_options(profile, user_csv_importer_factory):
|
|||
content = '''email key,first_name,last_name,@registration
|
||||
tnoel@entrouvert.com,Thomas,Noël,'''
|
||||
|
||||
importer = user_csv_importer_factory(content + 'send-email')
|
||||
assert importer.run(simulate=True)
|
||||
assert not mail.outbox
|
||||
|
||||
importer = user_csv_importer_factory(content + 'send-email')
|
||||
assert importer.run()
|
||||
thomas = User.objects.get(email='tnoel@entrouvert.com')
|
||||
|
|
Loading…
Reference in New Issue