Skip to content

Commit

Permalink
Update tests part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Doupe committed Jan 19, 2018
1 parent d84d42c commit 85b12f4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 135 deletions.
2 changes: 1 addition & 1 deletion webapp/apps/dynamic/tests/test_behavioral.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_behavioral_reform_with_wildcard(self):

def test_behavioral_reform_from_file(self):
# Do the microsim from file
data = get_file_post_data(START_YEAR, test_reform.reform_text)
data = get_file_post_data(START_YEAR, test_reform.r1)
micro1 = do_micro_sim(self.client, data, post_url='/taxbrain/file/')
micro1 = micro1["response"]

Expand Down
2 changes: 1 addition & 1 deletion webapp/apps/dynamic/tests/test_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_elasticity_edit(self):
@pytest.mark.xfail
def test_elasticity_reform_from_file(self):
# Do the microsim from file
data = get_file_post_data(START_YEAR, test_reform.reform_text)
data = get_file_post_data(START_YEAR, test_reform.r1)
# set dyn_dropq_compute to False so that
# webapp.apps.dynamic_views.dropq_compute is not Mocked
micro1 = do_micro_sim(
Expand Down
2 changes: 1 addition & 1 deletion webapp/apps/dynamic/tests/test_ogusa.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_ogusa_reform_from_file(self):
self.client.login(username='temporary', password='temporary')
start_year = 2016
# Do the microsim from file
data = get_file_post_data(start_year, test_reform.reform_text)
data = get_file_post_data(start_year, test_reform.r1)
micro1 = do_micro_sim(self.client, data, post_url='/taxbrain/file/')

# Do the partial equilibrium simulation based on the microsim
Expand Down
34 changes: 17 additions & 17 deletions webapp/apps/taxbrain/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_taxbrain_file_post_quick_calc(self):
Using file-upload interface, test quick calculation post and full
post from quick_calc page
"""
data = get_file_post_data(START_YEAR, test_reform.reform_text, quick_calc=False)
data = get_file_post_data(START_YEAR, test_reform.r1, quick_calc=False)

wnc, created = WorkerNodesCounter.objects.get_or_create(singleton_enforce=1)
current_dropq_worker_offset = wnc.current_offset
Expand All @@ -125,7 +125,7 @@ def test_taxbrain_file_post_quick_calc(self):

# Check that data was saved properly
truth_mods = taxcalc.Calculator.read_json_param_objects(
test_reform.reform_text,
test_reform.r1,
None,
)
truth_mods = truth_mods["policy"]
Expand All @@ -150,7 +150,7 @@ def test_taxbrain_file_post_quick_calc(self):


def test_back_to_back_quickcalc(self):
"Test back to back quick calc posts"
"Test back to back quick calc posts"
# switches 0, 4, 6 are False
data = get_post_data(START_YEAR, quick_calc=True)
del data[u'ID_BenefitSurtax_Switch_0']
Expand Down Expand Up @@ -333,7 +333,7 @@ def test_taxbrain_wildcard_params_with_validation_is_OK(self):
truth_mods = {
START_YEAR: {'_II_brk2_cpi': False},
START_YEAR + 2: {
'_II_brk1': [[15000.0, 19069.63, 9534.81, 13650.38, 19069.63]]
'_II_brk1': [[15000.0, 19050.0, 9525.0, 13600.0, 19050.0]]
}
}
check_posted_params(result['tb_dropq_compute'], truth_mods,
Expand Down Expand Up @@ -566,13 +566,13 @@ def test_taxbrain_rt_to_passthrough(self):
do_micro_sim(self.client, data)

def test_taxbrain_file_post_only_reform(self):
data = get_file_post_data(START_YEAR, test_reform.reform_text)
data = get_file_post_data(START_YEAR, test_reform.r1)
do_micro_sim(self.client, data, post_url="/taxbrain/file/")


def test_taxbrain_file_post_reform_and_assumptions(self):
data = get_file_post_data(START_YEAR,
test_reform.reform_text,
test_reform.r1,
test_assumptions.assumptions_text)

do_micro_sim(self.client, data, post_url="/taxbrain/file/")
Expand Down Expand Up @@ -636,8 +636,8 @@ def test_taxbrain_error_reform_file(self):
# Check that no redirect happens
self.assertEqual(response.status_code, 200)
assert response.context['has_errors'] is True
msg = 'ERROR: _II_brk1_4 value 9e+99 > max value 89239.88 for _II_brk2_4 for 2024'
assert msg in response.context['errors']
assert any(['_II_brk1_4' in msg and '2024' in msg
for msg in response.context['errors']])

# get most recent object
objects = js.objects.order_by('id')
Expand Down Expand Up @@ -672,8 +672,8 @@ def test_taxbrain_warning_reform_file(self):
# Check that no redirect happens
self.assertEqual(response.status_code, 200)
assert response.context['has_errors'] is True
msg = 'WARNING: _STD_0 value 1073.53 < min value 7191.08 for 2023'
assert msg in response.context['errors']
assert any(['_STD_0' in msg and '2023' in msg
for msg in response.context['errors']])

# get most recent object
objects = js.objects.order_by('id')
Expand All @@ -693,7 +693,7 @@ def test_taxbrain_warning_reform_file(self):

truth_mods = {
2020: {
"_STD": [[1000, 13583.32, 6791.67, 10000.32, 13583.32]]
"_STD": [[1000, 24981.84, 12490.92, 18736.38, 24981.84]]
}
}
check_posted_params(result['tb_dropq_compute'], truth_mods, START_YEAR)
Expand All @@ -715,8 +715,8 @@ def test_taxbrain_reform_file_file_swap(self):
# Check that no redirect happens
self.assertEqual(response.status_code, 200)
assert response.context['has_errors'] is True
msg = 'WARNING: _STD_0 value 1073.53 < min value 7191.08 for 2023'
assert msg in response.context['errors']
assert any(['_STD_0' in msg and '2023' in msg
for msg in response.context['errors']])

# get most recent object
objects = js.objects.order_by('id')
Expand Down Expand Up @@ -762,8 +762,8 @@ def test_taxbrain_reform_file_file_swap_no_assump(self):
# Check that no redirect happens
self.assertEqual(response.status_code, 200)
assert response.context['has_errors'] is True
msg = 'WARNING: _STD_0 value 1073.53 < min value 7191.08 for 2023'
assert msg in response.context['errors']
assert any(['_STD_0' in msg and '2023' in msg
for msg in response.context['errors']])

# get most recent object
objects = js.objects.order_by('id')
Expand Down Expand Up @@ -807,7 +807,7 @@ def test_taxbrain_up_to_2018(self):

def test_taxbrain_file_up_to_2018(self):
start_year = 2018
data = get_file_post_data(start_year, test_reform.reform_text)
data = get_file_post_data(start_year, test_reform.r1)

post_url = '/taxbrain/file/'

Expand All @@ -819,7 +819,7 @@ def test_taxbrain_file_up_to_2018(self):

# Check that data was saved properly
truth_mods = taxcalc.Calculator.read_json_param_objects(
test_reform.reform_text,
test_reform.r1,
None,
)
truth_mods = truth_mods["policy"]
Expand Down
2 changes: 1 addition & 1 deletion webapp/apps/test_assets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from test_assumptions import assumptions_text
from test_reform import reform_text
from test_reform import r1
113 changes: 0 additions & 113 deletions webapp/apps/test_assets/test_reform.py
Original file line number Diff line number Diff line change
@@ -1,116 +1,3 @@
reform_text = """// Title: 2016 Trump Campaign Tax Plan
// Reform_File_Author: Matt Jensen
// Reform_Reference: https://www.donaldjtrump.com/policies/tax-plan
// Reform_Description:
// - New personal income tax schedule (regular/non-AMT/non-pass-through) (1)
// - New pass-through income tax schedule (2)
// - New long-term capital gains and qualified dividends tax schedule (3)
// - Repeal Alternative Minimum Tax (4)
// - Repeal Net Investment Income Tax (5)
// - Raise the Standard Deduction (6)
// - Repeal the Personal Exemption (7)
// - New above the line deduction for child and elder care (8)
// - Cap itemized deductions (9)
// Reform_Parameter_Map:
// - 1: _II_rt*, II_brk*
// - 2: _PT_*
// - 3: _CG_*
// - 4: _AMT_*
// - 5: _NIIT_rt
// - 6: _STD
// - 7: _II_em
// - 8: _ALD_Dependents*
// - 9: _ID_c
{
"policy": {
"_II_rt1": {
"2017": [0.12],
"2018": [0.12]
},
"_II_brk1":
{"2017": [[37500, 75000, 37500, 37500, 75000]]},
"_II_rt2":
{"2017": [0.25]},
"_II_brk2":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_II_rt3":
{"2017": [0.25]},
"_II_brk3":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_II_rt4":
{"2017": [0.25]},
"_II_brk4":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_II_rt5":
{"2017": [0.25]},
"_II_brk5":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_II_rt6":
{"2017": [0.25]},
"_II_brk6":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_II_rt7":
{"2017": [0.33]},
"_PT_rt1":
{"2017": [0.12]},
"_PT_brk1":
{"2017": [[37500, 75000, 37500, 37500, 75000]]},
"_PT_rt2":
{"2017": [0.15]},
"_PT_brk2":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_PT_rt3":
{"2017": [0.15]},
"_PT_brk3":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_PT_rt4":
{"2017": [0.15]},
"_PT_brk4":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_PT_rt5":
{"2017": [0.15]},
"_PT_brk5":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_PT_rt6":
{"2017": [0.15]},
"_PT_brk6":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_PT_rt7":
{"2017": [0.15]},
"_CG_brk1":
{"2017": [[37500, 75000, 37500, 37500, 75000]]},
"_CG_brk2":
{"2017": [[112500, 225000, 112500, 112500, 225000]]},
"_AMT_rt1":
{"2017": [0]},
"_AMT_rt2":
{"2017": [0]},
"_NIIT_rt":
{"2017": [0]},
"_STD":
{"2017": [[15000, 30000, 15000, 15000, 30000]]},
"_II_em":
{"2017": [0]},
"_ALD_Dependents_thd":
{"2017": [[250000, 500000, 250000, 500000, 500000]]},
"_ALD_Dependents_Elder_c":
{"2017": [5000]},
"_ALD_Dependents_Child_c":
{"2017": [7156]},
"_ID_c":
{"2017": [[100000, 200000, 100000, 100000, 200000]]}
}
}
// Note: Due to lack of detail, data, or modeling capability, many provisions cannot be scored.
// These omitted provisions include:
// - Allow expenssing for pass-through firms
// - Tax carried interest as ordinary business income
// - Repeal pass-through business tax expenditures
// - Corporate tax provisions
// - Estate tax provisions"""


r1 = """// r1.json assumes reform with the following provisions:
// - adhoc raises in OASDI maximum taxable earnings in 2018, 2019 and 2020,
// with _SS_Earnings_c wage indexed in subsequent years
Expand Down
4 changes: 3 additions & 1 deletion webapp/apps/test_assets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ def check_posted_params(mock_compute, params_to_check, start_year):
assert last_posted["first_budget_year"] == int(start_year)
for year in params_to_check:
for param in params_to_check[year]:
assert user_mods["policy"][str(year)][param] == params_to_check[year][param]
act = user_mods["policy"][str(year)][param]
exp = params_to_check[year][param]
assert exp == act


def get_post_data(start_year, _ID_BenefitSurtax_Switches=True, quick_calc=False):
Expand Down

0 comments on commit 85b12f4

Please sign in to comment.