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_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_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_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_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_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_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_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))
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))
def test_kpi_with_missing_property(self): service = Service(details({'2012-Q4 Vol.': '5'})) assert_that(service.latest_kpi_for('volume_change'), is_(None))
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))
def test_no_kpis(self): service = Service(details({})) assert_that(service.latest_kpi_for('takeup'), 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_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_transactions_count(self): service = Service(details({'2013-Q1 Vol.': '10'})) assert_that(service.latest_kpi_for('volume_num'), is_(10))
def test_kpi_with_missing_property(self): service = Service(details({ '2012-Q4 Vol.': '5' })) assert_that(service.latest_kpi_for('volume_change'), is_(None))
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))