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_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_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