808 - formatted annual usage section

This commit is contained in:
Jonathan Bobel
2023-10-02 15:12:36 -04:00
parent 20e8aaac1a
commit c7e05246b1
2 changed files with 26 additions and 20 deletions

View File

@@ -20,15 +20,18 @@
<div id='pill-selected-item'> <div id='pill-selected-item'>
<div class='grid-row'> <div class='grid-row'>
<div class='grid-col-6'> <div class='grid-col-12'>
<h2 class='heading-small'>Text messages</h2> <h2 class='heading-small'>Text messages</h2>
<div class="keyline-block"> <div class="keyline-block">
{{ big_number(sms_sent, 'sent', smaller=True) }} You have sent
{{ big_number(sms_free_allowance, 'free allowance', smaller=True) }} {{ big_number(sms_sent, 'messages of your', smaller=True) }}
{{ big_number(sms_free_allowance, 'free messages allowance.', smaller=True) }}
<br />
You have
{% if sms_free_allowance > 0 %} {% if sms_free_allowance > 0 %}
{{ big_number(sms_allowance_remaining, 'free allowance remaining', smaller=True) }} {{ big_number(sms_allowance_remaining, 'messages remaining.', smaller=True) }}
{% endif %} {% endif %}
{% for row in sms_breakdown %} {# {% for row in sms_breakdown %}
{% if row.charged_units > 0 %} {% if row.charged_units > 0 %}
{{ big_number( {{ big_number(
row.charged_units, row.charged_units,
@@ -36,7 +39,7 @@
smaller=True smaller=True
) }} ) }}
{% endif %} {% endif %}
{% endfor %} {% endfor %} #}
</div> </div>
</div> </div>
{# <div class='grid-col-6'> {# <div class='grid-col-6'>

View File

@@ -819,7 +819,7 @@ def test_usage_page(
assert normalize_spaces(unselected_nav_links[0].text) == "2010 to 2011 fiscal year" assert normalize_spaces(unselected_nav_links[0].text) == "2010 to 2011 fiscal year"
assert normalize_spaces(unselected_nav_links[1].text) == "2009 to 2010 fiscal year" assert normalize_spaces(unselected_nav_links[1].text) == "2009 to 2010 fiscal year"
annual_usage = page.find_all("div", {"class": "grid-col-6"}) annual_usage = page.find_all("div", {"class": "keyline-block"})
# annual stats are shown in two rows, each with three column; email is col 1 # annual stats are shown in two rows, each with three column; email is col 1
# email_column = normalize_spaces(annual_usage[0].text + annual_usage[2].text) # email_column = normalize_spaces(annual_usage[0].text + annual_usage[2].text)
@@ -827,13 +827,13 @@ def test_usage_page(
# assert '1,000 sent' in email_column # assert '1,000 sent' in email_column
sms_column = normalize_spaces(annual_usage[0].text) sms_column = normalize_spaces(annual_usage[0].text)
assert "Text messages" in sms_column assert (
assert "251,800 sent" in sms_column "You have sent 251,800 messages of your 250,000 free messages allowance. You have 0 messages remaining."
assert "250,000 free allowance" in sms_column in sms_column
assert "0 free allowance remaining" in sms_column )
assert "$29.85 spent" not in sms_column assert "$29.85 spent" not in sms_column
assert "1,500 at 1.65 pence" in sms_column assert "1,500 at 1.65 pence" not in sms_column
assert "300 at 1.70 pence" in sms_column assert "300 at 1.70 pence" not in sms_column
@freeze_time("2012-03-31 12:12:12") @freeze_time("2012-03-31 12:12:12")
@@ -862,12 +862,12 @@ def test_usage_page_no_sms_spend(
service_id=SERVICE_ONE_ID, service_id=SERVICE_ONE_ID,
) )
annual_usage = page.find_all("div", {"class": "grid-col-6"}) annual_usage = page.find_all("div", {"class": "keyline-block"})
sms_column = normalize_spaces(annual_usage[0].text) sms_column = normalize_spaces(annual_usage[0].text)
assert "Text messages" in sms_column assert (
assert "1,000 sent" in sms_column "You have sent 1,000 messages of your 250,000 free messages allowance. You have 249,000 messages remaining."
assert "250,000 free allowance" in sms_column in sms_column
assert "249,000 free allowance remaining" in sms_column )
assert "$0.00 spent" not in sms_column assert "$0.00 spent" not in sms_column
assert "pence per message" not in sms_column assert "pence per message" not in sms_column
@@ -938,10 +938,13 @@ def test_usage_page_with_0_free_allowance(
year=2020, year=2020,
) )
annual_usage = page.select("main .grid-col-6") annual_usage = page.select("main .grid-col-12 .keyline-block")
sms_column = normalize_spaces(annual_usage[0].text) sms_column = normalize_spaces(annual_usage[0].text)
assert "0 free allowance" in sms_column assert (
"You have sent 251,800 messages of your 0 free messages allowance. You have"
in sms_column
)
assert "free allowance remaining" not in sms_column assert "free allowance remaining" not in sms_column