Example #1
0
    def test_data_coverage_when_quarter_not_requested(self):
        services = [
            Service(
                details({
                    "2012-Q4 Vol.": "2,000",
                    '2012-Q4 Digital vol.': '10',
                    u'2012-Q4 CPT (\xa3)': "2.00",
                    "2013-Q1 Vol.": "***",
                    u'2013-Q1 CPT (\xa3)': "***",
                    '2013-Q1 Digital vol.': '***',
                    u'High-volume?': 'yes'
                })),
            Service(
                details({
                    "2012-Q4 Vol.": "1,000",
                    u'2012-Q4 CPT (\xa3)': "3.00",
                    '2012-Q4 Digital vol.': '10',
                    u'High-volume?': 'yes'
                })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        coverage = dept.data_coverage

        assert_that(float(coverage.percentage), close_to(0.1333333, 0.001))
        assert_that(coverage.requested, is_(45))
        assert_that(coverage.provided, is_(6))
Example #2
0
    def test_dict_generation(self):
        services = [
            Service(
                details({
                    "Name of service": "test_name_2",
                    "Abbr": "tn2",
                    "2013-Q3 Vol.": "6,400,000"
                })),
            Service(
                details({
                    "Name of service": "test_name_3",
                    "Abbr": "tn3",
                    "2012-Q4 Vol.": "6,400,000"
                }))
        ]

        dicts = dict_map([("name", lambda s: s.name),
                          ("abbr", lambda s: s.abbr)], services)

        assert_that(dicts[0],
                    has_entries({
                        'name': 'test_name_2',
                        'abbr': 'tn2'
                    }))
        assert_that(
            dicts[1],
            has_entries({
                'name': 'test_name_3',
                'abbr': 'tn3',
                'historic': 'Apr 2011 to Mar 2012'
            }))
Example #3
0
    def test_data_coverage_excludes_non_high_volume_services(self):
        services = [
            Service(
                details({
                    "2012-Q4 Vol.": "2,000",
                    '2012-Q4 Digital vol.': '10',
                    u'2012-Q4 CPT (\xa3)': "2.00",
                    "2013-Q1 Vol.": "2,000",
                    u'2013-Q1 CPT (\xa3)': "2.00",
                    '2013-Q1 Digital vol.': '10',
                })),
            Service(
                details({
                    "2012-Q4 Vol.": "1,000",
                    u'2012-Q4 CPT (\xa3)': "3.00",
                    '2012-Q4 Digital vol.': '10',
                    u'High-volume?': 'yes'
                })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        coverage = dept.data_coverage

        assert_that(float(coverage.percentage), is_(0.125))
        assert_that(coverage.requested, is_(24))
        assert_that(coverage.provided, is_(3))
Example #4
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_sum_of_total_transactions_when_kpis_are_missing(self):
        services = [Service(details({})),
                    Service(details({'2013-Q2 Vol.': '100'})),
                    Service(details({'2013-Q2 Vol.': '***'}))]

        assert_that(services[0].has_kpis, is_(False))
        assert_that(total_transaction_volume(services), is_(100))
    def test_data_coverage_excludes_non_high_volume_services(self):
        services = [
            Service(details({
                "2012-Q4 Vol.": "2,000",
                '2012-Q4 Digital vol.': '10',
                u'2012-Q4 CPT (\xa3)': "2.00",
                "2013-Q1 Vol.": "2,000",
                u'2013-Q1 CPT (\xa3)': "2.00",
                '2013-Q1 Digital vol.': '10',
            })),
            Service(details({
                "2012-Q4 Vol.": "1,000",
                u'2012-Q4 CPT (\xa3)': "3.00",
                '2012-Q4 Digital vol.': '10',
                u'High-volume?': 'yes'
            })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        coverage = dept.data_coverage

        assert_that(float(coverage.percentage), is_(0.125))
        assert_that(coverage.requested, is_(24))
        assert_that(coverage.provided, is_(3))
    def test_data_coverage_when_quarter_not_requested(self):
        services = [
            Service(details({
                "2012-Q4 Vol.": "2,000",
                '2012-Q4 Digital vol.': '10',
                u'2012-Q4 CPT (\xa3)': "2.00",
                "2013-Q1 Vol.": "***",
                u'2013-Q1 CPT (\xa3)': "***",
                '2013-Q1 Digital vol.': '***',
                u'High-volume?': 'yes'
            })),
            Service(details({
                "2012-Q4 Vol.": "1,000",
                u'2012-Q4 CPT (\xa3)': "3.00",
                '2012-Q4 Digital vol.': '10',
                u'High-volume?': 'yes'
            })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        coverage = dept.data_coverage

        assert_that(float(coverage.percentage), close_to(0.1333333, 0.001))
        assert_that(coverage.requested, is_(45))
        assert_that(coverage.provided, is_(6))
    def test_calculate_cost_change_from_previous_value(self):
        increase_service = Service(details({
            '2013-Q1 Vol.': '200',
            u'2013-Q1 CPT (\xa3)': '2',
            '2012-Q4 Vol.': '100',
            u'2012-Q4 CPT (\xa3)': '1',
        }))
        decrease_service = Service(details({
            '2013-Q1 Vol.': '100',
            u'2013-Q1 CPT (\xa3)': '1',
            '2012-Q4 Vol.': '100',
            u'2012-Q4 CPT (\xa3)': '2',
        }))
        no_previous_vol_service = Service(details({
            '2013-Q1 Vol.': '100',
            u'2013-Q1 CPT (\xa3)': '1',
            '2012-Q4 Vol.': '',
            u'2012-Q4 CPT (\xa3)': '',
        }))
        zero_previous_vol_service = Service(details({
            '2013-Q1 Vol.': '100',
            u'2013-Q1 CPT (\xa3)': '1',
            '2012-Q4 Vol.': '0',
            u'2012-Q4 CPT (\xa3)': '0',
        }))

        assert_that(increase_service.latest_kpi_for('cost_change'), is_(4))
        assert_that(decrease_service.latest_kpi_for('cost_change'), is_(0.5))
        assert_that(no_previous_vol_service.latest_kpi_for('cost_change'), is_(None))
        assert_that(zero_previous_vol_service.latest_kpi_for('cost_change'), is_(None))
    def test_calculate_takeup_change_from_previous_value(self):
        increase_service = Service(details({
            '2013-Q1 Vol.': '200',
            '2013-Q1 Digital vol.': '200',
            '2012-Q4 Vol.': '100',
            '2012-Q4 Digital vol.': '50',
        }))
        decrease_service = Service(details({
            '2013-Q1 Vol.': '100',
            '2013-Q1 Digital vol.': '50',
            '2012-Q4 Vol.': '100',
            '2012-Q4 Digital vol.': '100',
        }))
        no_previous_vol_service = Service(details({
            '2013-Q1 Vol.': '100',
            '2013-Q1 Digital vol.': '100',
            '2012-Q4 Vol.': '',
            '2012-Q4 Digital vol.': '',
        }))
        zero_previous_vol_service = Service(details({
            '2013-Q1 Vol.': '100',
            '2013-Q1 Digital vol.': '100',
            '2012-Q4 Vol.': '0',
            '2012-Q4 Digital vol.': '0',
        }))

        assert_that(increase_service.latest_kpi_for('takeup_change'), is_(2))
        assert_that(decrease_service.latest_kpi_for('takeup_change'), is_(0.5))
        assert_that(no_previous_vol_service.latest_kpi_for('takeup_change'), is_(None))
        assert_that(zero_previous_vol_service.latest_kpi_for('takeup_change'), is_(None))
    def test_calculate_volume_change_from_previous_value(self):
        increase_service = Service(
            details({
                '2013-Q1 Vol.': '200',
                '2012-Q4 Vol.': '100',
            }))
        decrease_service = Service(
            details({
                '2013-Q1 Vol.': '100',
                '2012-Q4 Vol.': '200',
            }))
        no_previous_vol_service = Service(
            details({
                '2013-Q1 Vol.': '100',
                '2012-Q4 Vol.': '',
            }))
        zero_previous_vol_service = Service(
            details({
                '2013-Q1 Vol.': '100',
                '2012-Q4 Vol.': '0',
            }))
        zero_current_vol_service = Service(
            details({
                '2013-Q1 Vol.': '0',
                '2012-Q4 Vol.': '100',
            }))

        assert_that(increase_service.latest_kpi_for('volume_change'), is_(2))
        assert_that(decrease_service.latest_kpi_for('volume_change'), is_(0.5))
        assert_that(no_previous_vol_service.latest_kpi_for('volume_change'),
                    is_(None))
        assert_that(zero_previous_vol_service.latest_kpi_for('volume_change'),
                    is_(None))
        assert_that(zero_current_vol_service.latest_kpi_for('volume_change'),
                    is_(0))
    def test_sum_of_total_transactions(self):
        services = [
            Service(details({'2013-Q1 Vol.': '10'})),
            Service(details({'2013-Q2 Vol.': '20'})),
            Service(details({'2013-Q1 Vol.': '30'}))
        ]

        assert_that(total_transaction_volume(services), is_(60))
    def test_keywords(self):
        service_with_no_keywords = Service(details({'Keywords': None}))
        service_with_one_keywords = Service(details({'Keywords': 'keyword'}))
        service_with_two_keywords = Service(details({'Keywords': 'keyword1, keyword2'}))

        assert_that(service_with_no_keywords.keywords, is_([]))
        assert_that(service_with_one_keywords.keywords, is_(['keyword']))
        assert_that(service_with_two_keywords.keywords, is_(['keyword1', 'keyword2']))
    def test_aggregate_is_sum_of_values_when_high_volume_does_not_matter(self):
        services = [
            Service(details({"2012-Q4 Vol.": "2,000"})),
            Service(details({"2012-Q4 Vol.": "3,000"})),
        ]

        kpi_aggregator = ServiceKpiAggregator(services)

        assert_that(kpi_aggregator.aggregate(['volume_num']), is_([5000]))
    def test_most_up_to_date_volume(self):
        service_with_one_vol = Service(details({'2013-Q1 Vol.': '200'}))
        service_with_two_vols = Service(details({'2013-Q1 Vol.': '200',
                                                 '2013-Q2 Vol.': '250'}))
        service_with_no_vols = Service(details({}))

        assert_that(service_with_one_vol.most_up_to_date_volume, is_(200))
        assert_that(service_with_two_vols.most_up_to_date_volume, is_(250))
        assert_that(service_with_no_vols.most_up_to_date_volume, is_(None))
Example #15
0
    def test_volume_ignores_services_with_no_kpis(self):
        services = [
            Service(details({"2012-Q4 Vol.": "2,000"})),
            Service(details({})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.volume, is_(2000))
Example #16
0
    def test_abbreviation_is_first_services_abbreviation(self):
        services = [
            Service(details({u'Abbr': "ABC"})),
            Service(details({u'Abbr': "ABC"})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.abbr, is_("ABC"))
    def test_link_is_first_services_slugified_abbreviation(self):
        services = [
            Service(details({u'Abbr': "ABC"})),
            Service(details({u'Abbr': "ABC"})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.link, is_("department/abc/by-transactions-per-year/descending"))
    def test_volume_ignores_services_with_no_kpis(self):
        services = [
            Service(details({"2012-Q4 Vol.": "2,000"})),
            Service(details({})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.volume, is_(2000))
    def test_volume_is_total_of_last_available_quarter_for_each_service(self):
        services = [
            Service(details({"2012-Q4 Vol.": "1,000", "2013-Q1 Vol.": "1,500"})),
            Service(details({"2012-Q4 Vol.": "2,000"})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.volume, is_(3500))
    def test_abbreviation_is_first_services_abbreviation(self):
        services = [
            Service(details({u'Abbr': "ABC"})),
            Service(details({u'Abbr': "ABC"})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.abbr, is_("ABC"))
    def test_aggregate_ignores_when_no_kpis(self):
        services = [
            Service(details({"2012-Q4 Vol.": "2,000"})),
            Service(details({})),
        ]

        kpi_aggregator = ServiceKpiAggregator(services)

        assert_that(kpi_aggregator.aggregate(['volume_num']), is_([2000]))
    def test_sum_of_total_transactions_when_kpis_are_missing(self):
        services = [
            Service(details({})),
            Service(details({'2013-Q2 Vol.': '100'})),
            Service(details({'2013-Q2 Vol.': '***'}))
        ]

        assert_that(services[0].has_kpis, is_(False))
        assert_that(total_transaction_volume(services), is_(100))
    def test_aggregate_is_none_when_no_values(self):
        services = [
            Service(details({u'2012-Q4 Digital vol.': "2,000"})),
            Service(details({u'2012-Q4 Digital vol.': "3,000"}))
        ]

        kpi_aggregator = ServiceKpiAggregator(services)

        assert_that(kpi_aggregator.aggregate(['volume_num']), is_([None]))
Example #24
0
    def test_cost_is_none_when_no_kpi_is_available(self):
        services = [
            Service(details({u'High-volume?': 'yes'})),
            Service(details({u'High-volume?': 'yes'})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.cost, is_(None))
Example #25
0
    def test_link_is_first_services_slugified_abbreviation(self):
        services = [
            Service(details({u'Abbr': "ABC"})),
            Service(details({u'Abbr': "ABC"})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.link,
                    is_("department/abc/by-transactions-per-year/descending"))
    def test_has_detailed_page_when_in_csv(self):
        service_with_details = Service(details({"Detailed view?": "yes"}))
        service_without_details = Service(details({"Detailed view?": ""}))
        service_explicitly_without_details = Service(
            details({"Detailed view?": "no"}))

        assert_that(service_with_details.has_details_page, is_(True))
        assert_that(service_without_details.has_details_page, is_(False))
        assert_that(service_explicitly_without_details.has_details_page,
                    is_(False))
Example #27
0
    def test_count_of_high_volume_services(self):
        services = [
            Service(details({u'High-volume?': 'yes'})),
            Service(details({u'High-volume?': 'yes'})),
            Service(details({})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.high_volume_count, is_(2))
    def test_keywords(self):
        service_with_no_keywords = Service(details({'Keywords': None}))
        service_with_one_keywords = Service(details({'Keywords': 'keyword'}))
        service_with_two_keywords = Service(
            details({'Keywords': 'keyword1, keyword2'}))

        assert_that(service_with_no_keywords.keywords, is_([]))
        assert_that(service_with_one_keywords.keywords, is_(['keyword']))
        assert_that(service_with_two_keywords.keywords,
                    is_(['keyword1', 'keyword2']))
    def test_most_up_to_date_volume(self):
        service_with_one_vol = Service(details({'2013-Q1 Vol.': '200'}))
        service_with_two_vols = Service(
            details({
                '2013-Q1 Vol.': '200',
                '2013-Q2 Vol.': '250'
            }))
        service_with_no_vols = Service(details({}))

        assert_that(service_with_one_vol.most_up_to_date_volume, is_(200))
        assert_that(service_with_two_vols.most_up_to_date_volume, is_(250))
        assert_that(service_with_no_vols.most_up_to_date_volume, is_(None))
Example #30
0
    def test_volume_is_total_of_last_available_quarter_for_each_service(self):
        services = [
            Service(details({
                "2012-Q4 Vol.": "1,000",
                "2013-Q1 Vol.": "1,500"
            })),
            Service(details({"2012-Q4 Vol.": "2,000"})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.volume, is_(3500))
    def test_dict_generation(self):
        services = [
            Service(details({"Name of service": "test_name_2", "Abbr": "tn2", "2013-Q3 Vol.": "6,400,000"})),
            Service(details({"Name of service": "test_name_3", "Abbr": "tn3", "2012-Q4 Vol.": "6,400,000"}))
        ]

        dicts = dict_map([("name", lambda s: s.name),
                          ("abbr", lambda s: s.abbr)],
                         services)

        assert_that(dicts[0], has_entries({'name': 'test_name_2', 'abbr': 'tn2'}))
        assert_that(dicts[1], has_entries({'name': 'test_name_3', 'abbr': 'tn3', 'historic': 'Apr 2011 to Mar 2012'}))
    def test_aggregate_is_none_when_no_high_volume_services_and_ignore_non_high_volume(
            self):
        services = [
            Service(details({"2012-q4 vol.": "2,000"})),
            Service(details({"2012-q4 vol.": "3,000"}))
        ]

        kpi_aggregator = ServiceKpiAggregator(services)

        assert_that(
            kpi_aggregator.aggregate(['volume_num'], high_volume_only=True),
            is_([None]))
    def test_cost_is_none_when_no_kpi_is_available(self):
        services = [
            Service(details({
                u'High-volume?': 'yes'
            })),
            Service(details({
                u'High-volume?': 'yes'
            })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.cost, is_(None))
    def test_csv_generation(self):
        services = [
            Service(details({"Name of service": "test_name", "Abbr": "tn"})),
            Service(details({"Name of service": "test_name_2", "Abbr": "tn2"}))
        ]

        table = tabular_map([("name_column", lambda s: s.name),
                             ("abbr", lambda s: s.abbr)],
                            services)

        assert_that(table, is_([["name_column", "abbr"],
                                ["test_name", "tn"],
                                ["test_name_2", "tn2"]]))
    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_count_of_high_volume_services(self):
        services = [
            Service(details({
                u'High-volume?': 'yes'
            })),
            Service(details({
                u'High-volume?': 'yes'
            })),
            Service(details({})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.high_volume_count, is_(2))
    def test_aggregate_is_sum_of_values_when_high_volume_matters(self):
        services = [
            Service(details({
                "2012-Q4 Vol.": "2,000",
                u'High-volume?': 'yes'
            })),
            Service(details({"2012-Q4 Vol.": "3,000"}))
        ]

        kpi_aggregator = ServiceKpiAggregator(services)

        assert_that(
            kpi_aggregator.aggregate(['volume_num'], high_volume_only=True),
            is_([2000]))
    def test_has_detailed_page_when_in_csv(self):
        service_with_details = Service(details({
            "Detailed view?": "yes"
        }))
        service_without_details = Service(details({
             "Detailed view?": ""
        }))
        service_explicitly_without_details = Service(details({
             "Detailed view?": "no"
        }))

        assert_that(service_with_details.has_details_page, is_(True))
        assert_that(service_without_details.has_details_page, is_(False))
        assert_that(service_explicitly_without_details.has_details_page, is_(False))
    def test_takeup_is_none_if_volume_is_none(self):
        services = [
            Service(details({
                '2012-Q4 Digital vol.': '5',
                u'High-volume?': 'yes'
            })),
            Service(details({
                '2012-Q4 Digital vol.': '10',
                u'High-volume?': 'yes'
            })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.takeup, is_(None))
    def test_cost_is_none_when_no_high_volume_services(self):
        services = [
            Service(details({
                "2012-Q4 Vol.": "2,000",
                u'2012-Q4 CPT (\xa3)': "2.00",
            })),
            Service(details({
                "2013-Q1 Vol.": "1,000",
                u'2013-Q1 CPT (\xa3)': "3.00",
            })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.cost, is_(None))
Example #41
0
    def test_takeup_is_none_if_digital_volume_is_none(self):
        services = [
            Service(details({
                '2012-Q4 Vol.': '10',
                u'High-volume?': 'yes'
            })),
            Service(details({
                '2012-Q4 Vol.': '30',
                u'High-volume?': 'yes'
            })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.takeup, is_(None))
    def test_cost(self):
        service = Service(details({
            "2012-Q4 Vol.": "2,000",
            u'2012-Q4 CPT (\xa3)': "2.00"
        }))

        assert_that(service.latest_kpi_for('cost'), is_(4000))
    def test_agency_abbr_is_full_name_if_not_supplied(self):
        service = Service(details({
            "Agency/body": "A and B and C",
            "Agency abbr": "",
        }))

        assert_that(service.agency_abbreviation, is_("A and B and C"))
    def test_cost_ignores_services_with_no_cpt(self):
        services = [
            Service(details({
                "2012-Q4 Vol.": "2,000",
                u'High-volume?': 'yes'
            })),
            Service(details({
                "2013-Q1 Vol.": "1,000",
                u'2013-Q1 CPT (\xa3)': "3.00",
                u'High-volume?': 'yes'
            })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.cost, is_(3000))
Example #45
0
    def test_cost_is_none_when_no_high_volume_services(self):
        services = [
            Service(
                details({
                    "2012-Q4 Vol.": "2,000",
                    u'2012-Q4 CPT (\xa3)': "2.00",
                })),
            Service(
                details({
                    "2013-Q1 Vol.": "1,000",
                    u'2013-Q1 CPT (\xa3)': "3.00",
                })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.cost, is_(None))
    def test_volume_with_one_service(self):
        services = [
            Service(details({"2012-Q4 Vol.": "2,000"}))
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.volume, is_(2000))
    def test_slug(self):
        service = Service(
            details({
                'Abbr': 'abc',
                'Name of service': 'Add Beautiful Code'
            }))

        assert_that(service.slug, is_('abc-add-beautiful-code'))
    def test_cost(self):
        service = Service(
            details({
                "2012-Q4 Vol.": "2,000",
                u'2012-Q4 CPT (\xa3)': "2.00"
            }))

        assert_that(service.latest_kpi_for('cost'), is_(4000))
    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_most_recent_kpi_with_attributes_are_none_if_no_attributes_are_present(self):
        service = Service(details({
            '2012-Q4 Vol.': '10',
            '2013-Q1 Vol.': '3',
        }))

        assert_that(service.find_recent_kpis_with_attributes(['volume_num', 'digital_volume_num']),
                    is_(None))
    def test_volumes(self):
        service = Service(
            details({
                '2012-Q4 Vol.': '10',
                '2012-Q4 Digital vol.': '5'
            }))

        assert_that(service.latest_kpi_for('takeup'), is_(0.5))
    def test_aggregate_is_none_when_no_kpis(self):
        services = [
            Service(details({})),
        ]

        kpi_aggregator = ServiceKpiAggregator(services)

        assert_that(kpi_aggregator.aggregate(['volume_num']), is_([None]))
    def test_takeup_is_volume_divided_by_digital_volume(self):
        services = [
            Service(details({
                '2012-Q4 Vol.': '10',
                '2012-Q4 Digital vol.': '5',
                u'High-volume?': 'yes'
            })),
            Service(details({
                '2012-Q4 Vol.': '30',
                '2012-Q4 Digital vol.': '10',
                u'High-volume?': 'yes'
            })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.takeup, is_(0.375))
Example #54
0
    def test_volume_is_none_if_no_service_has_kpis(self):
        services = [
            Service(details({})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.volume, is_(None))
    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_volume_is_none_if_no_service_has_kpis(self):
        services = [
            Service(details({})),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.volume, is_(None))
    def test_most_recent_kpi_takeup_is_none_if_no_matching_quarters(self):
        service = Service(
            details({
                '2012-Q4 Vol.': '10',
                '2013-Q1 Digital vol.': '5'
            }))

        assert_that(service.latest_kpi_for('takeup'), is_(None))
    def test_cost_is_sum_of_transaction_costs_for_each_transaction_handled(self):
        services = [
            Service(details({
                "2012-Q4 Vol.": "2,000",
                u'2012-Q4 CPT (\xa3)': "2.00",
                u'High-volume?': 'yes'
            })),
            Service(details({
                "2013-Q1 Vol.": "1,000",
                u'2013-Q1 CPT (\xa3)': "3.00",
                u'High-volume?': 'yes'
            })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.cost, is_(7000))
Example #59
0
    def test_cost_ignores_services_with_no_cpt(self):
        services = [
            Service(details({
                "2012-Q4 Vol.": "2,000",
                u'High-volume?': 'yes'
            })),
            Service(
                details({
                    "2013-Q1 Vol.": "1,000",
                    u'2013-Q1 CPT (\xa3)': "3.00",
                    u'High-volume?': 'yes'
                })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.cost, is_(3000))
    def test_takeup_use_data_from_the_same_quarter_for_volume_and_digital_volume(self):
        services = [
            Service(details({
                '2012-Q4 Vol.': '10',
                '2012-Q4 Digital vol.': '5',
                u'High-volume?': 'yes'
            })),
            Service(details({
                '2012-Q4 Vol.': '30',
                '2012-Q4 Digital vol.': '10',
                '2013-Q1 Vol.': '20',
                u'High-volume?': 'yes'
            })),
        ]

        dept = Department("Agency for Beautiful Code", services)

        assert_that(dept.takeup, is_(0.375))