def test_get_new_aids_with_matching_aids(yesterday): """Matching aids are found.""" alert = AlertFactory(querystring='text=test') AidFactory.create_batch(5, name='Test', date_published=yesterday) aids = alert.get_new_aids() assert len(aids) == 5
def test_get_new_aids_with_no_old_aids(last_month): """Matching aids are older than the requested threshold.""" alert = AlertFactory(querystring='text=test') AidFactory.create_batch(5, name='Test', date_published=last_month) aids = alert.get_new_aids() assert len(aids) == 0
def test_get_new_aids_with_no_matching_aids(yesterday): """Existing aids do not match.""" alert = AlertFactory(querystring='text=Gloubiboulga') AidFactory.create_batch(5, name='Test', date_published=yesterday) aids = alert.get_new_aids() assert len(aids) == 0
def test_command_with_unvalidated_address(mailoutbox): AlertFactory( validated=False, querystring='text=Schtroumpf') AidFactory.create_batch(5, name='Schtroumpf') call_command('send_alerts') assert len(mailoutbox) == 0
def test_get_new_aids_with_unpublished_aids(yesterday): """Matching aids are not published.""" alert = AlertFactory(querystring='text=test') AidFactory.create_batch(5, name='Test', date_published=yesterday, status='draft') aids = alert.get_new_aids() assert len(aids) == 0
def test_command_output_format(mailoutbox): AlertFactory(title='Gloubiboukmark', querystring='text=Schtroumpf') AidFactory.create(name='Schtroumpf 1') AidFactory.create(name='Schtroumpf 2') AidFactory.create(name='Schtroumpf 3') AidFactory.create(name='Schtroumpf 4') call_command('send_alerts') content = mailoutbox[0].body assert 'Gloubiboukmark' in content assert 'Schtroumpf 1' in content assert 'Schtroumpf 2' in content assert 'Schtroumpf 3' in content # Only the first three aids are in the mail assert 'Schtroumpf 4' not in content assert 'encore d\'autres aides disponibles !' in content
def test_command_output_format(mailoutbox): AlertFactory( title='Gloubiboukmark', querystring='text=Schtroumpf') AidFactory.create(name='Schtroumpf 1') AidFactory.create(name='Schtroumpf 2') AidFactory.create(name='Schtroumpf 3') AidFactory.create(name='Schtroumpf 4') call_command('send_alerts') content = mailoutbox[0].body assert 'Gloubiboukmark' in content assert 'Schtroumpf 1' in content assert 'Schtroumpf 2' in content assert 'Schtroumpf 3' in content # Only the first three aids are in the mail assert 'Schtroumpf 4' not in content assert 'encore d\'autres aides disponibles !' in content # The "extra search" link should include these parameters assert 'published_after=' in content assert 'action=alert' in content
def test_get_absolute_url(): alert = AlertFactory(querystring='text=test') alert_absolute_url = alert.get_absolute_url() assert alert_absolute_url.startswith('/aides/')
def test_get_new_aids_with_no_aids(last_month): """No aids exist, so no aids can be found.""" alert = AlertFactory(querystring='text=test') aids = alert.get_new_aids() assert len(aids) == 0
def test_command_with_matching_aids(mailoutbox): alert = AlertFactory(querystring='text=Schtroumpf') AidFactory.create_batch(5, name='Schtroumpf') call_command('send_alerts') assert len(mailoutbox) == 1 assert list(mailoutbox[0].to) == [alert.email]
def test_command_with_an_alert_but_no_matching_aids(mailoutbox): AlertFactory(querystring='text=Schtroumpf') AidFactory.create_batch(5, name='Gloubiboulga') call_command('send_alerts') assert len(mailoutbox) == 0
def test_command_with_an_alert_but_no_aids(mailoutbox): AlertFactory(querystring='text=Schtroumpf') call_command('send_alerts') assert len(mailoutbox) == 0