mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-14 23:07:49 -04:00
take advantage of click's type validation/coercion
(saves us having to write the stuff ourselves). Also adds a small
click plugin to do datetime parsing.
Sample output:
```
[leohemsted:~/dev/api]$ flask command create_provider_rates --help
Usage: flask command create_provider_rates [OPTIONS]
Backfill rates for a given provider
Options:
-p, --provider_name [mmg|firetext|ses]
[required]
-c, --cost FLOAT Cost (pence) per message including decimals
[required]
-d, --valid_from DATE [required]
--help Show this message and exit.
[leohemsted:~/dev/api]$ flask command create_provider_rates -p ses -c 1.234 -d invalid
Usage: flask command create_provider_rates [OPTIONS]
Error: Invalid value for "-d" / "--valid_from": Could not parse datetime string "invalid" formatted as %Y-%m-%dT%H:%M:%S
```
This commit is contained in:
@@ -8,7 +8,7 @@ def test_backfill_processing_time_works_for_correct_dates(mocker, notify_api):
|
||||
|
||||
# backfill_processing_time is a click.Command object - if you try invoking the callback on its own, it
|
||||
# throws a `RuntimeError: There is no active click context.` - so get at the original function using __wrapped__
|
||||
backfill_processing_time.callback.__wrapped__('2017-08-01', '2017-08-03')
|
||||
backfill_processing_time.callback.__wrapped__(datetime(2017, 8, 1), datetime(2017, 8, 3))
|
||||
|
||||
assert send_mock.call_count == 3
|
||||
send_mock.assert_any_call(datetime(2017, 7, 31, 23, 0), datetime(2017, 8, 1, 23, 0))
|
||||
|
||||
Reference in New Issue
Block a user