|
1 |
import datetime
|
1 |
2 |
import json
|
2 |
3 |
import urllib.parse
|
3 |
|
from datetime import date
|
4 |
4 |
from unittest import mock
|
5 |
5 |
|
6 |
6 |
import pytest
|
... | ... | |
1391 |
1391 |
manager_submit_cell(resp.form)
|
1392 |
1392 |
cell.refresh_from_db()
|
1393 |
1393 |
assert cell.time_range == 'range'
|
1394 |
|
assert cell.time_range_start == date(year=2020, month=10, day=1)
|
1395 |
|
assert cell.time_range_end == date(year=2020, month=11, day=3)
|
|
1394 |
assert cell.time_range_start == datetime.date(year=2020, month=10, day=1)
|
|
1395 |
assert cell.time_range_end == datetime.date(year=2020, month=11, day=3)
|
1396 |
1396 |
|
1397 |
1397 |
resp.form[field_prefix + 'time_range_start'] = ''
|
1398 |
1398 |
resp.form[field_prefix + 'time_range_end'] = ''
|
... | ... | |
1855 |
1855 |
|
1856 |
1856 |
@with_httmock(new_api_mock)
|
1857 |
1857 |
@pytest.mark.parametrize('date', ['2020-03-02 12:01', '2020-03-05 12:01']) # Monday and Thursday
|
1858 |
|
def test_chartng_cell_new_api_filter_params(app, new_api_statistics, nocache, freezer, date):
|
|
1858 |
def test_chartng_cell_new_api_filter_params(app, new_api_statistics, nocache, freezer, date, settings):
|
|
1859 |
settings.TEMPLATE_VARS['test_var'] = datetime.date(year=2020, month=10, day=1)
|
1859 |
1860 |
page = Page.objects.create(
|
1860 |
1861 |
title='One',
|
1861 |
1862 |
slug='index',
|
... | ... | |
1864 |
1865 |
'from-request': '{{ request.GET.test }}',
|
1865 |
1866 |
'not-a-date': 'not-a-date',
|
1866 |
1867 |
'syntax-error': '{% for %}',
|
|
1868 |
'from-template-vars': '{{ test_var }}',
|
1867 |
1869 |
},
|
1868 |
1870 |
)
|
1869 |
1871 |
cell = ChartNgCell(page=page, order=1, placeholder='content')
|
... | ... | |
1981 |
1983 |
request = new_api_mock.call['requests'][-1]
|
1982 |
1984 |
assert 'start=2022-05-17' in request.url
|
1983 |
1985 |
|
|
1986 |
cell.time_range_start_template = 'from-template-vars'
|
|
1987 |
cell.save()
|
|
1988 |
app.get(location)
|
|
1989 |
request = new_api_mock.call['requests'][-1]
|
|
1990 |
assert 'start=2020-10-01' in request.url
|
|
1991 |
|
1984 |
1992 |
|
1985 |
1993 |
@with_httmock(new_api_mock)
|
1986 |
1994 |
def test_chartng_cell_new_api_filter_params_month(new_api_statistics, nocache, freezer):
|
1987 |
|
-
|