diff --git a/src/authentic2/csv_import.py b/src/authentic2/csv_import.py index 56ece005c..fcd2c05ce 100644 --- a/src/authentic2/csv_import.py +++ b/src/authentic2/csv_import.py @@ -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=[ diff --git a/tests/test_csv_import.py b/tests/test_csv_import.py index 235487cd0..ae9e238d1 100644 --- a/tests/test_csv_import.py +++ b/tests/test_csv_import.py @@ -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')