Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick-calc clean up #759

Merged
merged 7 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions templates/taxbrain/input_file.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,12 @@ <h2>Tax-Calculator Code Build</h2>
<a href="#" ></a>
<input id="tax-submit" class="btn btn-secondary btn-block btn-animate" type="submit" name="full_calc" value="Show me the results!">
</div>
{% if enable_quick_calc %}
<div class="sidebar-button">
<a href="#" ></a>
<button id="tax-submit-quick" class="btn btn-tertiary btn-block" type="submit" value="quick_calc" name="quick_calc">
Quick Calculation! <br> <span style="font-size:smaller;">(1 year; 2% sample)</span>
</button>
</div>
{% endif %}
<div class="sidebar-button">
<a href="#" ></a>
<button id="tax-submit-quick" class="btn btn-tertiary btn-block" type="submit" value="quick_calc" name="quick_calc">
Quick Calculation! <br> <span style="font-size:smaller;">(1 year; small sample)</span>
</button>
</div>

</div> <!-- sidebar -->
</div>
Expand Down
13 changes: 1 addition & 12 deletions templates/taxbrain/input_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,12 @@ <h2>Tax-Calculator Code Build</h2>
<a href="#" ></a>
<input id="tax-submit" class="btn btn-secondary btn-block btn-animate" type="submit" name="full_calc" value="Show me the results!">
</div>
{% if enable_quick_calc %}
<div class="sidebar-button">
<a href="#" ></a>
<button id="tax-submit-quick" class="btn btn-tertiary btn-block" type="submit" value="quick_calc" name="quick_calc">
Quick Calculation! <br> <span style="font-size:smaller;">(1 year; 2% sample)</span>
Quick Calculation! <br> <span style="font-size:smaller;">(1 year; small sample)</span>
</button>
</div>
{% endif %}
<!--
<div class="sidebar-note">
<div class="sidebar-count">
<span>11</span> / 24
</div>
<h3>Changes made to the Current Tax Policy</h3>
<p>Data is pre-populated with current tax policy parameters. The amount listed above tracks the number of parameters changed, that different from the current tax policy parameters.</p>
</div>
-->
</div> <!-- sidebar -->
</div>
<div class="col-xs-9">
Expand Down
2 changes: 1 addition & 1 deletion templates/taxbrain/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h1>Partial Equilibrium Results</h1>
</div>
<p class="meta">These results were generated by <a href="https://github.com/OpenSourcePolicyCenter/webapp-public/tree/v{{webapp_version}}"> PolicyBrain version {{ webapp_version }}</a> on {{ created_on|date:"D, M jS Y \a\t g:iA" }} UTC using <a href="https://github.com/open-source-economics/Tax-Calculator/tree/{{taxcalc_version}}"> Tax-Calculator version {{ taxcalc_version }}.</a> </p>
{% if quick_calc %}
<p class="meta">This calculation used only 2% of the available data and only calculated revenues for one year instead of ten. For the full results, <a href="/taxbrain/submit/{{ unique_url.pk }}/">click here</a></p>
<p class="meta">This calculation used only a small sample of the available data and only calculated revenues for one year instead of ten. For the full results, <a href="/taxbrain/submit/{{ unique_url.pk }}/">click here</a></p>

{% endif %}
{% if is_behavior %}
Expand Down
32 changes: 32 additions & 0 deletions webapp/apps/taxbrain/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,38 @@ def test_taxbrain_file_post_quick_calc(self):
str(START_YEAR))


def test_back_to_back_quickcalc(self):
"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']
del data[u'ID_BenefitSurtax_Switch_4']
del data[u'ID_BenefitSurtax_Switch_6']
data[u'II_em'] = [u'4333']

result = do_micro_sim(self.client, data)

# Check that data was saved properly
truth_mods = {START_YEAR: {"_ID_BenefitSurtax_Switch":
[[0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0]],
"_II_em": [4333.0]}
}
check_posted_params(result['tb_dropq_compute'], truth_mods,
str(START_YEAR))

edit_micro = '/taxbrain/edit/{0}/?start_year={1}'.format(result["pk"],
START_YEAR)
edit_page = self.client.get(edit_micro)
self.assertEqual(edit_page.status_code, 200)

next_csrf = str(edit_page.context['csrf_token'])
data['csrfmiddlewaretoken'] = next_csrf
result2 = do_micro_sim(self.client, data)

check_posted_params(result2['tb_dropq_compute'], truth_mods,
str(START_YEAR))


def test_taxbrain_post_no_behavior_entries(self):
#Monkey patch to mock out running of compute jobs
get_dropq_compute_from_module('webapp.apps.taxbrain.views')
Expand Down
2 changes: 2 additions & 0 deletions webapp/apps/test_assets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from ..taxbrain.models import TaxSaveInputs, OutputUrl
from ..taxbrain.forms import PersonalExemptionForm

from ..dynamic import views
from ..taxbrain import views

from django.core.files.uploadedfile import SimpleUploadedFile

Expand Down