Exemplo n.º 1
0
    def test_building_a_list_of_departments_from_services(self):
        services = [
            Service(
                details({
                    u'Abbr': 'ABC',
                    u'Department': "Agency for Beautiful Code"
                })),
            Service(
                details({
                    u'Abbr': 'MSW',
                    u'Department': "Ministry of Silly Walks"
                })),
            Service(
                details({
                    u'Abbr': 'ABC',
                    u'Department': "Agency for Beautiful Code"
                })),
        ]

        departments = Department.from_services(services)

        assert_that(len(departments), is_(2))
        assert_that(departments[0].name, is_("Agency for Beautiful Code"))
        assert_that(departments[0].services, contains(services[0],
                                                      services[2]))
    def test_name_with_quotes_as_slug(self):
        services = [
            Service(details({u'Abbr': 'ABC', u'Department': "Attorney General's Office"})),
        ]

        department = Department.from_services(services)[0]

        assert_that(department.name_slug, is_('attorney-generals-office'))
    def test_name_as_slug(self):
        services = [
            Service(details({u'Abbr': 'ABC', u'Department': 'Agency for Beautiful Code'})),
        ]

        department = Department.from_services(services)[0]

        assert_that(department.name_slug, is_('agency-for-beautiful-code'))
Exemplo n.º 4
0
    def test_name_with_quotes_as_slug(self):
        services = [
            Service(
                details({
                    u'Abbr': 'ABC',
                    u'Department': "Attorney General's Office"
                })),
        ]

        department = Department.from_services(services)[0]

        assert_that(department.name_slug, is_('attorney-generals-office'))
Exemplo n.º 5
0
    def test_name_as_slug(self):
        services = [
            Service(
                details({
                    u'Abbr': 'ABC',
                    u'Department': 'Agency for Beautiful Code'
                })),
        ]

        department = Department.from_services(services)[0]

        assert_that(department.name_slug, is_('agency-for-beautiful-code'))
    def test_building_a_list_of_departments_from_services(self):
        services = [
            Service(details({u'Abbr': 'ABC', u'Department': "Agency for Beautiful Code"})),
            Service(details({u'Abbr': 'MSW', u'Department': "Ministry of Silly Walks"})),
            Service(details({u'Abbr': 'ABC', u'Department': "Agency for Beautiful Code"})),
        ]

        departments = Department.from_services(services)

        assert_that(len(departments), is_(2))
        assert_that(departments[0].name, is_("Agency for Beautiful Code"))
        assert_that(departments[0].services,
                    contains(services[0], services[2]))
               vars={'service': service,
                     'department': Department(service.department, [service]),
                     'latest_quarter': latest_quarter })

    sort_orders = [
        ("by-name", lambda service: service.name_of_service),
        ("by-department", lambda service: service.abbr.lower()),
        ("by-total-cost", lambda service: service.latest_kpi_for('cost')),
        ("by-cost-per-transaction", lambda service: service.latest_kpi_for('cost_per_number')),
        ("by-digital-takeup", lambda service: service.latest_kpi_for('takeup')),
        ("by-transactions-per-year", lambda service: service.latest_kpi_for('volume_num')),
    ]
    generate_sorted_pages(high_volume_services, 'high-volume-services', 'high-volume-services',
                          sort_orders)

    departments = Department.from_services(services)
    department_sort_orders = [
        ("by-department", lambda department: department.name),
        ("by-digital-takeup", lambda department: department.takeup),
        ("by-cost", lambda department: department.cost),
        ("by-data-coverage", lambda department: department.data_coverage.percentage if department.data_coverage else None),
        ("by-transactions-per-year", lambda department: department.volume),
    ]
    generate_sorted_pages(departments, 'all-services', 'all-services', department_sort_orders)

    services_sort_orders = [
        ("by-name", lambda service: service.name_of_service),
        ("by-agency", lambda service: service.agency_abbreviation.lower()),
        ("by-category", lambda service: service.category),
        ("by-transactions-per-year", lambda service: service.most_up_to_date_volume),
    ]