def test_correct_Growfactors_usage(): gf = Growfactors() pir = gf.price_inflation_rates(2013, 2020) assert len(pir) == 8 wgr = gf.wage_growth_rates(2013, 2021) assert len(wgr) == 9 val = gf.factor_value('AWAGE', 2013) assert val > 1.0
def test_growfactors_csv_values(): """ Test numerical contents of growfactors.csv file. """ gfo = Growfactors() min_data_year = min(Records.PUFCSV_YEAR, Records.CPSCSV_YEAR) if min_data_year < Policy.JSON_START_YEAR: for gfname in Growfactors.VALID_NAMES: val = gfo.factor_value(gfname, min_data_year) assert val == 1
def test_proper_usage(): """ Test proper usage of Growfactors object. """ gfo = Growfactors() pir = gfo.price_inflation_rates(2013, 2020) assert len(pir) == 8 wgr = gfo.wage_growth_rates(2013, 2021) assert len(wgr) == 9 val = gfo.factor_value('AWAGE', 2013) assert val > 1.0
def test_improper_usage(bad_gf_file): """ Tests of improper usage of Growfactors object. """ with pytest.raises(ValueError): gfo = Growfactors(dict()) with pytest.raises(ValueError): gfo = Growfactors(bad_gf_file.name) gfo = Growfactors() fyr = gfo.first_year lyr = gfo.last_year with pytest.raises(ValueError): gfo.price_inflation_rates(fyr - 1, lyr) with pytest.raises(ValueError): gfo.price_inflation_rates(fyr, lyr + 1) with pytest.raises(ValueError): gfo.price_inflation_rates(lyr, fyr) with pytest.raises(ValueError): gfo.wage_growth_rates(fyr - 1, lyr) with pytest.raises(ValueError): gfo.wage_growth_rates(fyr, lyr + 1) with pytest.raises(ValueError): gfo.wage_growth_rates(lyr, fyr) with pytest.raises(ValueError): gfo.factor_value('BADNAME', fyr) with pytest.raises(ValueError): gfo.factor_value('AWAGE', fyr - 1) with pytest.raises(ValueError): gfo.factor_value('AWAGE', lyr + 1)
def test_incorrect_Growfactors_usage(bad_gf_file): with pytest.raises(ValueError): gf = Growfactors(dict()) with pytest.raises(ValueError): gf = Growfactors(bad_gf_file.name) gf = Growfactors() with pytest.raises(ValueError): pir = gf.price_inflation_rates(2000, 2099) with pytest.raises(ValueError): pir = gf.price_inflation_rates(2009, 2099) with pytest.raises(ValueError): pir = gf.price_inflation_rates(2021, 2013) with pytest.raises(ValueError): wgr = gf.wage_growth_rates(2000, 2099) with pytest.raises(ValueError): wgr = gf.wage_growth_rates(2009, 2099) with pytest.raises(ValueError): wgr = gf.wage_growth_rates(2021, 2013) with pytest.raises(ValueError): val = gf.factor_value('BADNAME', 2020) with pytest.raises(ValueError): val = gf.factor_value('AWAGE', 2000) with pytest.raises(ValueError): val = gf.factor_value('AWAGE', 2099)