def _send_activation_email(user, project, database, base_url): """Send an email to the user just after we have defined their diagnosis.""" advice_modules = {a.advice_id: a for a in _advice_modules(database)} advices = [a for a in project.advices if a.advice_id in advice_modules] if not advices: logging.error( # pragma: no-cover 'Weird: the advices that just got created do not exist in DB.' ) # pragma: no-cover return # pragma: no-cover data = { 'baseUrl': base_url, 'projectId': project.project_id, 'firstName': user.profile.name, 'ofProjectTitle': french.maybe_contract_prefix( 'de ', "d'", french.lower_first_letter( _get_job_name(project.target_job, user.profile.gender))), 'advices': [{ 'adviceId': a.advice_id, 'title': advice_modules[a.advice_id].title } for a in advices], } response = mail.send_template( # https://app.mailjet.com/template/168827/build '168827', user.profile, data, dry_run=not _EMAIL_ACTIVATION_ENABLED) if response.status_code != 200: logging.warning('Error while sending diagnostic email: %s\n%s', response.status_code, response.text)
def test_empty(self): """Next word is empty.""" sentence = french.maybe_contract_prefix('foo ', 'bar ', '') self.assertEqual('foo ', sentence)
def test_upper_case(self): """Next word starts with an upper case vowel.""" sentence = french.maybe_contract_prefix( 'foo ', 'bar ', 'A starts with an uppercase A') self.assertEqual('bar A starts with an uppercase A', sentence)
def test_h(self): """Next word starts with an H.""" sentence = french.maybe_contract_prefix('foo ', 'bar ', 'h starts with an H') self.assertEqual('bar h starts with an H', sentence)
def test_accented_vowel(self): """Next word starts with an accented vowel.""" sentence = french.maybe_contract_prefix('foo ', 'bar ', 'à starts with an A') self.assertEqual('bar à starts with an A', sentence)
def test_consonant(self): """Next word starts with a consonant.""" sentence = french.maybe_contract_prefix('foo ', 'bar ', 'starts with an S') self.assertEqual('foo starts with an S', sentence)