Exemplo n.º 1
0
def test_update_after_use():
    """
    Test of improper update after Growfactors object has been used.
    """
    gfo = Growfactors()
    gfo.price_inflation_rates(gfo.first_year, gfo.last_year)
    with pytest.raises(ValueError):
        gfo.update('AWAGE', 2013, 0.01)
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
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)
Exemplo n.º 5
0
def test_update_and_apply_growdiff():
    syr = 2013
    nyrs = 5
    lyr = syr + nyrs - 1
    gdiff = Growdiff(start_year=syr, num_years=nyrs)
    # update Growdiff instance
    diffs = {2014: {'_AWAGE': [0.01]}, 2016: {'_AWAGE': [0.02]}}
    gdiff.update_growdiff(diffs)
    expected_wage_diffs = [0.00, 0.01, 0.01, 0.02, 0.02]
    assert_allclose(gdiff._AWAGE, expected_wage_diffs, atol=0.0, rtol=0.0)
    # apply growdiff to Growfactors instance
    gf = Growfactors()
    pir_pre = gf.price_inflation_rates(syr, lyr)
    wgr_pre = gf.wage_growth_rates(syr, lyr)
    gfactors = Growfactors()
    gdiff.apply_to(gfactors)
    pir_pst = gfactors.price_inflation_rates(syr, lyr)
    wgr_pst = gfactors.wage_growth_rates(syr, lyr)
    expected_wgr_pst = [
        wgr_pre[i] + expected_wage_diffs[i] for i in range(0, nyrs)
    ]
    assert_allclose(pir_pre, pir_pst, atol=0.0, rtol=0.0)
    assert_allclose(wgr_pst, expected_wgr_pst, atol=1.0e-9, rtol=0.0)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
def test_update_after_use():
    gf = Growfactors()
    pir = gf.price_inflation_rates(gf.first_year, gf.last_year)
    with pytest.raises(ValueError):
        gf.update('AWAGE', 2013, 0.01)