mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-25 18:38:57 -04:00
flask-script has been deprecated by the internal flask.cli module, but making this carries a few changes with it * you should add FLASK_APP=application.py and FLASK_DEBUG=1 to your environment.sh. * instead of using `python app.py runserver`, now you must run `flask run -p 6012`. The -p command is important - the port must be set before the config is loaded, so that it can live reload nicely. (https://github.com/pallets/flask/issues/2113#issuecomment-268014481) * find available commands by just running `flask`. * run them using flask. eg `flask list_routes` * define new tasks by giving them the decorator `@app.cli.command('task-name')`. Task name isn't needed if it's just the same as the function name. Alternatively, if app isn't available in the current scope, you can invoke the decorator directly, as seen in app/commands.py
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import pytest
|
|
|
|
from app.main.forms import ChooseTimeForm
|
|
from freezegun import freeze_time
|
|
|
|
|
|
@freeze_time("2016-01-01 11:09:00.061258")
|
|
def test_form_contains_next_24h():
|
|
|
|
choices = ChooseTimeForm().scheduled_for.choices
|
|
|
|
# Friday
|
|
assert choices[0] == ('', 'Now')
|
|
assert choices[1] == ('2016-01-01T12:00:00.061258', 'Today at midday')
|
|
assert choices[13] == ('2016-01-02T00:00:00.061258', 'Today at midnight')
|
|
|
|
# Saturday
|
|
assert choices[14] == ('2016-01-02T01:00:00.061258', 'Tomorrow at 1am')
|
|
assert choices[37] == ('2016-01-03T00:00:00.061258', 'Tomorrow at midnight')
|
|
|
|
# Sunday
|
|
assert choices[38] == ('2016-01-03T01:00:00.061258', 'Sunday at 1am')
|
|
|
|
# Monday
|
|
assert choices[84] == ('2016-01-04T23:00:00.061258', 'Monday at 11pm')
|
|
assert choices[85] == ('2016-01-05T00:00:00.061258', 'Monday at midnight')
|
|
|
|
with pytest.raises(IndexError):
|
|
assert choices[
|
|
12 + # hours left in the day
|
|
(3 * 24) + # 3 days
|
|
2 # magic number
|
|
]
|
|
|
|
|
|
@freeze_time("2016-01-01 11:09:00.061258")
|
|
def test_form_defaults_to_now(client):
|
|
assert ChooseTimeForm().scheduled_for.data == ''
|
|
|
|
|
|
@freeze_time("2016-01-01 11:09:00.061258")
|
|
def test_form_contains_next_three_days():
|
|
assert ChooseTimeForm().scheduled_for.categories == [
|
|
'Later today', 'Tomorrow', 'Sunday', 'Monday'
|
|
]
|