Commit Graph

4330 Commits

Author SHA1 Message Date
Chris Hill-Scott
7f94232f4e Clean up old text message price
Now that the new price is in effect, we don’t need to check the date to
see which price should be displayed to the user.
2022-05-03 10:14:35 +01:00
Ben Thorner
3a1ac189ff Merge pull request #4225 from alphagov/free-allowance-api-181934027
Change annual usage to work with multiple SMS rates
2022-04-29 13:22:54 +01:00
Chris Hill-Scott
208985aa25 Merge pull request #4222 from alphagov/1-may-price-change
Update text message rate on 1 May 2022
2022-04-29 11:16:57 +01:00
Chris Hill-Scott
4a0f5e8a41 Make text message price dependent on date
So we don’t have to deploy a change on a Saturday.

In the future this could pull from the rates in the database, but while
that code is shifting around I didn’t want to touoch it. We’d also have
to think about caching so as not to have a non-authenticated route
hitting the database.
2022-04-28 10:48:44 +01:00
Ben Thorner
5511f15ae8 Add missing dashboard test for zero SMS cost 2022-04-27 17:08:44 +01:00
Ben Thorner
e6c04ef556 Support variable rates for annual usage stats
Note: I've removed the pricing assertion in the "0_free_allowance"
test as it's covered elsewhere - the value of the test is really to
check that we don't show the remainder if there never was any.
2022-04-27 17:06:17 +01:00
Ben Thorner
e0aa51c306 Use new "cost" field in usage APIs
The previous, manual calculation could be incorrect depending on
which SMS rates the free allowance was attributed to.

The new field also supersedes the old "letter_total" bolt-on so we
can get cost information consistently for both types.
2022-04-27 17:06:12 +01:00
Ben Thorner
82c3e8093d Remove redundant SMS test data for annual usage 2022-04-27 16:58:18 +01:00
Ben Thorner
4925264fb7 Remove duplicate test for usage page
This is covered by the main test for the page.
2022-04-27 16:57:11 +01:00
Ben Thorner
c6f5467009 Extend main test for service usage page
This adds missing assertions for email and SMS usage, as well as
letters with the help of some additional test data.

Previously we were only checking monthly usage (in other tests).
2022-04-27 16:57:06 +01:00
Ben Thorner
2aa3e78db2 Tidy up monthly usage test assertions
The "with_letters" was mostly a duplicate of the one before - no
change in test setup - bar the three assertions at the end.

Having the assertions in a separate test will help keep the one
above manageable as we add more assertions for the annual usage.
2022-04-27 16:37:17 +01:00
Ben Thorner
55ea5d90c7 Migrate away from ambiguous "billing_units"
This uses two new fields in the annual usage API instead of the
old one, which was actually a mix of two kinds of data [^1].

[^1]: fc378fed96
2022-04-27 16:32:52 +01:00
Ben Thorner
a02e1adbc5 Tweak usage dashboard test to cover rate changes 2022-04-26 14:02:54 +01:00
David McDonald
2706ec4c73 Take sms_rate from monthly usage data
At the moment, we put the sms rate on the usage page for each
months billing data by taking the single sms rate for the year.

The assumption that there will be a single sms rate for the year is
no longer going to be true. Therefore, instead we take the sms
rate from the monthly data itself which tells us the rate for
a months worth of sent SMS.
2022-04-26 10:38:10 +01:00
David McDonald
d18c787a02 Give better names to usage page variables
`free` becomes `sms_free_count`
`paid` becomes `sms_paid_count`

This small change is just to help with readability for this
complex area of code
2022-04-25 11:27:03 +01:00
David McDonald
c5d729b5f2 Remove unused letter_cumulative field
I have searched for this in the code and can't see it being used
anywhere so have removed it!
2022-04-25 11:11:45 +01:00
Leo Hemsted
19d501e2aa Merge pull request #4214 from alphagov/0-free-allowance
Hide remaining free allowance if it starts at 0
2022-04-22 13:32:16 +01:00
Ben Thorner
4a3ba97115 Remove redundant conditional for CF Redis
This is now used in all environments and we've removed support for
non-CF Redis [1].

[1]: https://github.com/alphagov/notifications-admin/pull/4213
2022-04-20 11:32:57 +01:00
Chris Hill-Scott
d11beee5b6 Hide remaining free allowance if it starts at 0
If your free allowance starts a 0 (which we have done for some services
this year) it’s redundant to say ‘0 of 0 remaining’.
2022-04-20 10:53:05 +01:00
Ben Thorner
be1fc9de79 Remove redundant CloudFoundry config code
These env vars can be set directly in the manifest, like we do for
Template Preview [^1].

[^1]: c08036189b/manifest.yml.j2 (L23-L26)
2022-04-13 14:45:29 +01:00
Ben Thorner
339ca93d9b Add support for migrating to Redis on PaaS
Similarly to https://github.com/alphagov/notifications-api/pull/3508
2022-04-12 17:46:45 +01:00
Leo Hemsted
1bed87b67d Merge pull request #4206 from alphagov/daily-sms-vols-reports
add new daily sms provider volumes report
2022-04-12 15:48:36 +01:00
Leo Hemsted
971101d07c clean up test_platform_admin string concatenation
make it consistent - always use a + to concatenate strings, always have
that + at the end of the line.

(also remove a rogue "when" from some test names)
2022-04-11 14:55:58 +01:00
Leo Hemsted
ebc005005b refactor: DRY up billing api client test
at the same time add the new daily_sms_provider_volumes_report func to
the tests.
2022-04-11 14:40:32 +01:00
Leo Hemsted
b3f5bb6435 add new daily sms provider volumes report
nearly identical to the daily-volumes-report but sms only, and split up
by provider
2022-04-11 14:40:31 +01:00
Ben Thorner
9132004ea3 DRY-up creating provider fixtures 2022-04-07 14:05:10 +01:00
Ben Thorner
05c396434d Use fixtures for SMS provider test data
This avoids the need to manually copy psuedo fixture data to avoid
breaking other tests.
2022-04-07 14:05:09 +01:00
Ben Thorner
6d77ff54b1 Standardise provider psuedo fixture data
Previously it was hard to distinguish ids from identifiers from
display names (in the case of the email fixtures).

Using predictable attributes will also make it easier to convert
this dictionaries to proper fixtures.
2022-04-07 14:05:08 +01:00
Ben Thorner
7f52e8dedf Add missing test for editing inactive providers 2022-04-07 14:05:05 +01:00
Ben Thorner
c4e1f40b43 Add missing test for viewing SMS ratio edit page 2022-04-07 14:05:02 +01:00
Ben Thorner
55e89b3f12 Add validation for provider SMS percentages
We could alternatively put the "add up to 100%" error on the page
using form-level errors [^1] and a custom flash message. Putting
the error on each field is slightly simpler and does make it clear
the issue is with all of the fields together.

[^1]: 22636b55ed
2022-04-07 14:05:01 +01:00
Ben Thorner
7f333ba5fe Rewrite SMS ratio form to cope with 3 providers
This replaces the slider with an integer input for each provider.
Unfortunately showing a variable number of inputs isn't easy to
achieve in WTForms [^1], but we think this is the least worst way
to do it vs e.g. not using WTForms at all.

[^1]: https://github.com/wtforms/wtforms/issues/736
2022-04-07 14:05:00 +01:00
Ben Thorner
01389b5edf Rename provider tests to match endpoint under test
This makes it clearer which tests we have for what.
2022-04-07 14:04:59 +01:00
Ben Thorner
8655ab7dea Stop showing priorities for other provider types
This isn't used and showing priorities when we only have a single
provider or where they have no effect is unnecessarily confusing.
Removing the form makes it clearer that there's only one way to
adjust priorities for domestic SMS providers.

If we add another email or international SMS provider in future,
we would need to rewrite the form here anyway as the priorities
need to be adjusted in tandem, not individually.
2022-04-07 14:04:57 +01:00
Ben Thorner
66335d20c2 Return to main provider page after editing ratio
Staying on the edit page is atypical behaviour for an edit form,
especially now it no longer shows the version history.
2022-04-07 13:43:56 +01:00
Ben Thorner
a3231effb1 Remove version history from provider ratio page
This doesn't work with 3 providers. You can still see the version
history for each provider on their dedicated page.
2022-04-07 13:43:54 +01:00
Katie Smith
b5fa270cd2 Bump all test dependencies
This results in some new errors from flake8-bugbear:
```
B020: Loop control variable overrides iterable it iterates
```
I can't see an issue with the places that we do this, so have ignored
these warnings. If we keep getting these and they look fine, we can
create a global rule to ignore B020.
2022-04-06 12:17:09 +01:00
Ben Thorner
e02dbde378 Small changes to address PR comments
In response to [^1] and [^2].

[^1]: https://github.com/alphagov/notifications-admin/pull/4199#discussion_r842653983
[^2]: https://github.com/alphagov/notifications-admin/pull/4199#discussion_r842667340
2022-04-05 15:55:07 +01:00
Ben Thorner
55e2a2f96b Stop reversing the order of SMS providers
This makes no functional difference but does make it easier to read.
2022-04-05 15:55:05 +01:00
Ben Thorner
9355c4f8d1 Only show active providers when changing priority
This fixes a bug where a third inactive provider would (potentially)
appear in place of one of the two active ones, depending on the order
of its identifier compared to the other two.

In future we may look at simplifying this to cope with more than two
active providers. For now, the existing UI will continue to work when
we add a new, inactive SMS provider for Reach.
2022-04-05 15:55:04 +01:00
Ben Thorner
f9749c0ae3 Standardise priorities / names for test providers
Only multiples of 10 are possible in practice. This will make it
easier to use this test data in the next commits.
2022-04-05 15:55:03 +01:00
Ben Thorner
0f9b73f73c Use fixtures instead deep-copying constants
This is more conventional and removes the ambiguity about whether
the deepcopy was actually necessary for new tests.
2022-04-05 15:55:02 +01:00
Ben Thorner
396e9e3743 Split up provider test data into separate vars
This makes it easier to follow which dict is being referred to as
the indices didn't convey this.
2022-04-05 15:55:01 +01:00
Ben Thorner
7a7d8f8aa6 Link to history for SMS providers
Although the priority history is shown on the "Change priority"
page, this doesn't show active/inactive changes.
2022-04-05 15:54:58 +01:00
Ben Thorner
c7951f8667 Split out email and letter branding request tests
In response to: [^1].

I've named the file to distinguish it from the admin endpoints to
set branding.

[^1]: https://github.com/alphagov/notifications-admin/pull/4196#discussion_r838734482
2022-03-30 17:46:55 +01:00
Ben Thorner
a27b5eb12b Move service setting tests into subdirectory
In response to: [^1].

This makes it clearer that the tests are split between files.

[^1]: https://github.com/alphagov/notifications-admin/pull/4196#discussion_r838734482
2022-03-30 17:46:54 +01:00
Ben Thorner
fa01889d01 Rearrange branding tests to group email / letters
Previously I found it hard to audit these tests when they flipped
between emails and letters when scrolling vertically.

While these have much in common, they are still separate features
and will evolve separately.
2022-03-30 17:46:52 +01:00
Ben Thorner
543dff4a18 Remove redundant scenario for email branding test
This is no longer possible since [^1].

[^1]: https://github.com/alphagov/notifications-admin/pull/4180
2022-03-30 17:46:51 +01:00
Ben Thorner
e2929118c8 Remove redundant letter branding UI test
This is now covered by the unit tests for the new branding module.
Showing the "something else" text box is also already covered by
another UI test, so we don't need it for that either.
2022-03-30 17:46:50 +01:00
Ben Thorner
1a7ecd85c9 Add tests for branding options conditional on name 2022-03-30 17:46:49 +01:00