コード例 #1
0
    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))
コード例 #2
0
    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))
コード例 #3
0
    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))
コード例 #4
0
    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))
コード例 #5
0
    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))
コード例 #6
0
    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))
コード例 #7
0
    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))
コード例 #8
0
    def test_calculate_cost_per_transaction_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_per_change'), is_(2))
        assert_that(decrease_service.latest_kpi_for('cost_per_change'),
                    is_(0.5))
        assert_that(no_previous_vol_service.latest_kpi_for('cost_per_change'),
                    is_(None))
        assert_that(
            zero_previous_vol_service.latest_kpi_for('cost_per_change'),
            is_(None))
コード例 #9
0
    def test_cost_is_non_when_no_cpt(self):
        service = Service(details({
            "2012-Q4 Vol.": "2,000",
        }))

        assert_that(service.latest_kpi_for('cost'), is_(None))
コード例 #10
0
    def test_kpi_with_missing_property(self):
        service = Service(details({'2012-Q4 Vol.': '5'}))

        assert_that(service.latest_kpi_for('volume_change'), is_(None))
コード例 #11
0
    def test_no_kpi_for_quarter_with_noVolume(self):
        service = Service(details({'2012-Q4 Digital vol.': '5'}))

        assert_that(service.latest_kpi_for('volume_num'), is_(None))
コード例 #12
0
    def test_no_kpis(self):
        service = Service(details({}))

        assert_that(service.latest_kpi_for('takeup'), is_(None))
コード例 #13
0
    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))
コード例 #14
0
    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))
コード例 #15
0
    def test_transactions_count(self):
        service = Service(details({'2013-Q1 Vol.': '10'}))

        assert_that(service.latest_kpi_for('volume_num'), is_(10))
コード例 #16
0
    def test_transactions_count(self):
        service = Service(details({'2013-Q1 Vol.': '10'}))

        assert_that(service.latest_kpi_for('volume_num'), is_(10))
コード例 #17
0
    def test_cost_is_non_when_no_cpt(self):
        service = Service(details({
            "2012-Q4 Vol.": "2,000",
        }))

        assert_that(service.latest_kpi_for('cost'), is_(None))
コード例 #18
0
    def test_no_kpis(self):
        service = Service(details({}))

        assert_that(service.latest_kpi_for('takeup'), is_(None))
コード例 #19
0
    def test_kpi_with_missing_property(self):
        service = Service(details({
           '2012-Q4 Vol.': '5'
        }))

        assert_that(service.latest_kpi_for('volume_change'), is_(None))
コード例 #20
0
    def test_no_kpi_for_quarter_with_noVolume(self):
        service = Service(details({
           '2012-Q4 Digital vol.': '5'
        }))

        assert_that(service.latest_kpi_for('volume_num'), is_(None))