|
|
|
@ -59,6 +59,29 @@ def test_jinja2_security_url_query(client, live_server, measure_memory_usage):
|
|
|
|
|
# Some of the spewed output from the subclasses
|
|
|
|
|
assert b'dict_values' not in res.data
|
|
|
|
|
|
|
|
|
|
def test_timezone(mocker):
|
|
|
|
|
"""Verify that timezone is parsed."""
|
|
|
|
|
|
|
|
|
|
timezone = 'America/Buenos Aires'
|
|
|
|
|
currentDate = arrow.now(timezone)
|
|
|
|
|
arrowNowMock = mocker.patch("arrow.now")
|
|
|
|
|
arrowNowMock.return_value = currentDate
|
|
|
|
|
finalRender = render(f"{{% now '{timezone}' %}}")
|
|
|
|
|
|
|
|
|
|
assert finalRender == currentDate.strftime("%Y-%m-%d")
|
|
|
|
|
|
|
|
|
|
def test_format(mocker):
|
|
|
|
|
"""Verify that format is parsed."""
|
|
|
|
|
|
|
|
|
|
timezone = 'utc'
|
|
|
|
|
format = '%d %b %Y %H:%M:%S'
|
|
|
|
|
currentDate = arrow.now(timezone)
|
|
|
|
|
arrowNowMock = mocker.patch("arrow.now")
|
|
|
|
|
arrowNowMock.return_value = currentDate
|
|
|
|
|
finalRender = render(f"{{% now '{timezone}', '{format}' %}}")
|
|
|
|
|
|
|
|
|
|
assert finalRender == currentDate.strftime(format)
|
|
|
|
|
|
|
|
|
|
def test_add_time(mocker):
|
|
|
|
|
"""Verify that added time offset can be parsed."""
|
|
|
|
|
|
|
|
|
@ -70,6 +93,17 @@ def test_add_time(mocker):
|
|
|
|
|
|
|
|
|
|
assert finalRender == currentDate.strftime("%Y-%m-%d")
|
|
|
|
|
|
|
|
|
|
def test_add_weekday(mocker):
|
|
|
|
|
"""Verify that added weekday offset can be parsed."""
|
|
|
|
|
|
|
|
|
|
timezone = 'utc'
|
|
|
|
|
currentDate = arrow.now(timezone)
|
|
|
|
|
arrowNowMock = mocker.patch("arrow.now")
|
|
|
|
|
arrowNowMock.return_value = currentDate
|
|
|
|
|
finalRender = render(f"{{% now '{timezone}' + 'weekday=1' %}}")
|
|
|
|
|
|
|
|
|
|
assert finalRender == currentDate.shift(weekday=1).strftime('%Y-%m-%d')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_substract_time(mocker):
|
|
|
|
|
"""Verify that substracted time offset can be parsed."""
|
|
|
|
@ -92,7 +126,7 @@ def test_offset_with_format(mocker):
|
|
|
|
|
arrowNowMock.return_value = currentDate
|
|
|
|
|
format = '%d %b %Y %H:%M:%S'
|
|
|
|
|
finalRender = render(
|
|
|
|
|
f"{{% now '{timezone}' - 'days=2,minutes=33,seconds=1', '%d %b %Y %H:%M:%S' %}}"
|
|
|
|
|
f"{{% now '{timezone}' - 'days=2,minutes=33,seconds=1', '{format}' %}}"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert finalRender == currentDate.shift(days=-2, minutes=-33, seconds=-1).strftime(format)
|