Ejemplo n.º 1
0
def test_get_tuples_of_financial_years():
    assert list(get_tuples_of_financial_years(
        lambda year: 'http://example.com?year={}'.format(year),
        start=2040,
        end=2041,
    )) == [
        ('financial year', 2040, 'http://example.com?year=2040', '2040 to 2041'),
        ('financial year', 2041, 'http://example.com?year=2041', '2041 to 2042'),
    ]
Ejemplo n.º 2
0
def organisation_dashboard(org_id):
    year, current_financial_year = requested_and_current_financial_year(request)
    services = current_organisation.services_and_usage(
        financial_year=year
    )['services']
    return render_template(
        'views/organisations/organisation/index.html',
        services=services,
        years=get_tuples_of_financial_years(
            partial(url_for, '.organisation_dashboard', org_id=current_organisation.id),
            start=current_financial_year - 1,
            end=current_financial_year + 1,
        ),
        selected_year=year,
        search_form=SearchByNameForm() if len(services) > 7 else None,
        **{
            f'total_{key}': sum(service[key] for service in services)
            for key in ('emails_sent', 'sms_cost', 'letter_cost')
        }
    )
Ejemplo n.º 3
0
def test_get_tuples_of_financial_years_defaults_to_2015():
    assert 2015 in list(
        get_tuples_of_financial_years(
            lambda year: 'http://example.com?year={}'.format(year),
            end=2040,
        ))[0]