コード例 #1
0
def test_alert_perimeter(client, mailoutbox):
    """The search perimeter is displayed in the validation email."""

    perimeter = PerimeterFactory.create(name='Bretagne')
    perimeter_id = '{}-{}'.format(perimeter.id, perimeter.code)
    url = reverse('alert_create_view')
    res = client.post(url, data={
        'title': 'Test',
        'email': '*****@*****.**',
        'alert_frequency': 'daily',
        'querystring': 'text=Ademe&perimeter={}'.format(perimeter_id),
        'source': 'aides-territoires'
    })
    assert res.status_code == 302
    assert len(mailoutbox) == 1
    assert perimeter_id in Alert.objects.last().querystring
コード例 #2
0
def test_alert_from_search_page(client, mailoutbox):
    """The search perimeter is displayed in the validation email."""

    perimeter = PerimeterFactory.create(name='Bretagne')
    perimeter_id = '{}-{}'.format(perimeter.id, perimeter.code)
    page = SearchPageFactory(
        title='Minisite',
        search_querystring='perimeter={}'.format(perimeter_id))
    url = reverse('alert_create_view')
    res = client.post(url, data={
        'title': 'Test',
        'email': '*****@*****.**',
        'alert_frequency': 'daily',
        'querystring': '',
        'source': page.slug
    })
    assert res.status_code == 302
    assert len(mailoutbox) == 1
    assert perimeter_id in Alert.objects.last().querystring
コード例 #3
0
def test_alert_perimeter(client, mailoutbox):
    """The search perimeter is displayed in the validation email."""

    perimeter = PerimeterFactory.create(name='Bretagne')
    perimeter_id = '{}-{}'.format(perimeter.id, perimeter.code)
    url = reverse('alert_create_view')
    res = client.post(url,
                      data={
                          'title':
                          'Test',
                          'email':
                          '*****@*****.**',
                          'alert_frequency':
                          'daily',
                          'querystring':
                          'text=Ademe&perimeter={}'.format(perimeter_id),
                      })
    assert res.status_code == 302
    assert len(mailoutbox) == 1

    content = mailoutbox[0].body
    assert 'Bretagne (Région)' in content