def test_asset_capital_path(reform_number, corporate, reforms, actual_vs_expect): """ Test corp/non-corp capital path results under different reforms. """ asset = Asset(reforms[reform_number], corp=corporate) asset.calc_all() decimals = 2 capital_path = asset.capital_path.round(decimals) fname = 'asset_ref{}_{}_expect.csv'.format(reform_number, 'corp' if corporate else 'nonc') actual_vs_expect(capital_path, fname, precision=decimals)
def test_debt_interest_path(reform_number, corporate, reforms, actual_vs_expect): """ Test corp/non-corp interest path results under different reforms. """ asset = Asset(reforms[reform_number], corp=corporate) asset.calc_all() debt = Debt(reforms[reform_number], asset.get_forecast()) debt.calc_all() decimals = 2 interest_path = debt.interest_path.round(decimals) fname = 'debt_ref{}_{}_expect.csv'.format(reform_number, 'corp' if corporate else 'nonc') actual_vs_expect(interest_path, fname, precision=decimals)
def test_instantiation_and_update_methods(default_btax_params): """ Test (in)correct CorpTaxReturn instantiation and update_* methods """ good_btax_params = default_btax_params bad_btax_params = list() good_earnings = np.ones(14) bad1_earnings = np.ones(13) bad2_earnings = dict() good_data = Data() good_assets = Asset(default_btax_params) good_assets.calc_all() bad_assets = dict() good_debts = Debt(default_btax_params, np.ones(14)) good_debts.calc_all() bad_debts = dict() # test (in)correct instantiation with pytest.raises(ValueError): CorpTaxReturn(bad_btax_params, good_earnings) with pytest.raises(AssertionError): CorpTaxReturn(good_btax_params, bad1_earnings) with pytest.raises(AssertionError): CorpTaxReturn(good_btax_params, bad2_earnings) CorpTaxReturn(good_btax_params, good_earnings, data=Data()) CorpTaxReturn(good_btax_params, good_earnings, assets=good_assets) with pytest.raises(ValueError): CorpTaxReturn(good_btax_params, good_earnings, assets=bad_assets) CorpTaxReturn(good_btax_params, good_earnings, debts=good_debts) with pytest.raises(ValueError): CorpTaxReturn(good_btax_params, good_earnings, debts=bad_debts) # test update_* methods ctr = CorpTaxReturn(good_btax_params, good_earnings) assert isinstance(ctr, CorpTaxReturn) ctr.update_assets(good_assets) with pytest.raises(ValueError): ctr.update_assets(bad_assets) ctr.update_debts(good_debts) with pytest.raises(ValueError): ctr.update_debts(bad_debts) ctr.update_earnings(good_earnings)
def test_instantiation_and_update_methods(clp_params_df): """ Test (in)correct CorpTaxReturn instantiation and update_* methods """ good_btax_params = clp_params_df bad_btax_params = list() good_earnings = np.ones(16) bad1_earnings = np.ones(13) bad2_earnings = dict() good_data = Data() good_assets = Asset(clp_params_df) good_assets.calc_all() bad_assets = dict() good_debts = Debt(clp_params_df, np.ones(16)) good_debts.calc_all() bad_debts = dict() Corp = Corporation(good_btax_params) # test (in)correct instantiation with pytest.raises(ValueError): CorpTaxReturn(bad_btax_params, Corp.revenues, Corp.deductions, Corp.credits) with pytest.raises(ValueError): CorpTaxReturn(good_btax_params, bad1_earnings, Corp.deductions, Corp.credits) with pytest.raises(ValueError): CorpTaxReturn(good_btax_params, bad2_earnings, Corp.deductions, Corp.credits) CorpTaxReturn(good_btax_params, Corp.revenues, Corp.deductions, Corp.credits, data=Data()) CorpTaxReturn(good_btax_params, Corp.revenues, Corp.deductions, Corp.credits, assets=good_assets) with pytest.raises(ValueError): CorpTaxReturn(good_btax_params, Corp.revenues, Corp.deductions, Corp.credits, assets=bad_assets) CorpTaxReturn(good_btax_params, Corp.revenues, Corp.deductions, Corp.credits, debts=good_debts) with pytest.raises(ValueError): CorpTaxReturn(good_btax_params, Corp.revenues, Corp.deductions, Corp.credits, debts=bad_debts) # test update_* methods ctr = CorpTaxReturn(good_btax_params, Corp.revenues, Corp.deductions, Corp.credits) assert isinstance(ctr, CorpTaxReturn) ctr.update_assets(good_assets) with pytest.raises(ValueError): ctr.update_assets(bad_assets) ctr.update_debts(good_debts) with pytest.raises(ValueError): ctr.update_debts(bad_debts) ctr.update_earnings(good_earnings)