2017-08-31 14:29:13 +01:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
2017-11-22 17:54:59 +00:00
|
|
|
from app.commands import backfill_processing_time
|
2017-08-31 14:29:13 +01:00
|
|
|
|
2017-08-31 14:45:01 +01:00
|
|
|
|
2017-11-24 12:01:28 +00:00
|
|
|
def test_backfill_processing_time_works_for_correct_dates(mocker, notify_api):
|
2017-08-31 14:29:13 +01:00
|
|
|
send_mock = mocker.patch('app.commands.send_processing_time_for_start_and_end')
|
|
|
|
|
|
2017-11-24 12:01:28 +00:00
|
|
|
# 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__
|
2017-11-28 11:10:19 +00:00
|
|
|
backfill_processing_time.callback.__wrapped__(datetime(2017, 8, 1), datetime(2017, 8, 3))
|
2017-08-31 14:29:13 +01:00
|
|
|
|
|
|
|
|
assert send_mock.call_count == 3
|
|
|
|
|
send_mock.assert_any_call(datetime(2017, 7, 31, 23, 0), datetime(2017, 8, 1, 23, 0))
|
|
|
|
|
send_mock.assert_any_call(datetime(2017, 8, 1, 23, 0), datetime(2017, 8, 2, 23, 0))
|
|
|
|
|
send_mock.assert_any_call(datetime(2017, 8, 2, 23, 0), datetime(2017, 8, 3, 23, 0))
|