misc: apply double-quote-string-fixer (#79788)

This commit is contained in:
Valentin Deniaud 2023-08-16 10:07:28 +02:00
parent 029f77cb38
commit 9d8876e155
25 changed files with 232 additions and 232 deletions

View File

@ -388,9 +388,9 @@ class ChartNgCell(CellBase):
chart, data['series'][0]['data']
)
if self.chart_type == 'pie':
data["series"] = [
{"label": chart.config.x_value_formatter(label), "data": [data]}
for label, data in zip(chart.x_labels, data["series"][0]["data"])
data['series'] = [
{'label': chart.config.x_value_formatter(label), 'data': [data]}
for label, data in zip(chart.x_labels, data['series'][0]['data'])
if data
]
elif self.chart_type == 'dot':

View File

@ -100,7 +100,7 @@ def lingo_check_request_signature(request):
class LocaleDecimal(Decimal):
# accept , instead of . for French users comfort
def __new__(cls, value="0", *args, **kwargs):
def __new__(cls, value='0', *args, **kwargs):
if isinstance(value, str) and settings.LANGUAGE_CODE.startswith('fr-'):
value = value.replace(',', '.')
return super().__new__(cls, value, *args, **kwargs)
@ -573,7 +573,7 @@ def get_payment_status_view(transaction_id=None, next_url=None):
params.append(('transaction-id', signing_dumps(transaction_id)))
if next_url:
params.append(('next', next_url))
return "%s?%s" % (url, urlencode(params))
return '%s?%s' % (url, urlencode(params))
class BasketItemPayView(PayMixin, View):
@ -640,7 +640,7 @@ class PaymentView(View):
if not payment_backend:
logger.error('lingo: payment backend not found on callback kwargs=%r', kwargs)
raise Http404("A payment backend or regie primary key or slug must be specified")
raise Http404('A payment backend or regie primary key or slug must be specified')
payment = payment_backend.make_eopayment(request=request)
if not backend_response and not payment.has_empty_response:

View File

@ -173,7 +173,7 @@ class MapLayer(models.Model):
cache_duration = models.PositiveIntegerField(_('Cache duration'), default=60, help_text=_('In seconds.'))
include_user_identifier = models.BooleanField(_('Include user identifier in request'), default=True)
geojson_query_parameter = models.CharField(
_("Query parameter for fulltext requests"),
_('Query parameter for fulltext requests'),
max_length=100,
blank=True,
help_text=_('Name of the parameter to use for querying the GeoJSON layer (typically, q)'),
@ -268,7 +268,7 @@ class MapLayer(models.Model):
return {
'type': 'FeatureCollection',
'features': [],
'_combo_err_desc': "Bad response from requested URL (%s)" % e,
'_combo_err_desc': 'Bad response from requested URL (%s)' % e,
}
try:
data = response.json()
@ -276,13 +276,13 @@ class MapLayer(models.Model):
return {
'type': 'FeatureCollection',
'features': [],
'_combo_err_desc': "Non JSON response from requested URL",
'_combo_err_desc': 'Non JSON response from requested URL',
}
if data is None:
return {
'type': 'FeatureCollection',
'features': [],
'_combo_err_desc': "Empty JSON response",
'_combo_err_desc': 'Empty JSON response',
}
if 'features' in data:
features = data['features']
@ -293,20 +293,20 @@ class MapLayer(models.Model):
return {
'type': 'FeatureCollection',
'features': [],
'_combo_err_desc': "Wrong GeoJSON response",
'_combo_err_desc': 'Wrong GeoJSON response',
}
if features:
if not isinstance(features[0], dict):
return {
'type': 'FeatureCollection',
'features': [],
'_combo_err_desc': "Wrong GeoJSON response",
'_combo_err_desc': 'Wrong GeoJSON response',
}
if not ({'geometry', 'properties'} <= set(features[0].keys())):
return {
'type': 'FeatureCollection',
'features': [],
'_combo_err_desc': "Wrong GeoJSON response",
'_combo_err_desc': 'Wrong GeoJSON response',
}
if properties:

View File

@ -71,7 +71,7 @@ class TextEngineSettingsForm(TextEngineSettingsUpdateForm):
label=_('Page'),
required=False,
queryset=Page.objects.none(),
help_text=_("Select a page to limit the search on this page and sub pages contents."),
help_text=_('Select a page to limit the search on this page and sub pages contents.'),
widget=SelectWithDisabled(),
)

View File

@ -55,7 +55,7 @@ class SearchCell(CellBase):
_search_services = JSONField(_('Search Services'), default=dict, blank=True)
title = models.CharField(_('Title'), max_length=150, blank=True)
autofocus = models.BooleanField(_('Autofocus'), default=False)
input_placeholder = models.CharField(_('Placeholder'), max_length=64, default="", blank=True)
input_placeholder = models.CharField(_('Placeholder'), max_length=64, default='', blank=True)
class Meta:
verbose_name = _('Search')

View File

@ -1108,7 +1108,7 @@ class CellBase(models.Model, metaclass=CellMeta):
return cells
def get_reference(self):
"Returns a string that can serve as a unique reference to a cell" ""
'Returns a string that can serve as a unique reference to a cell' ''
return str('%s-%s' % (self.get_cell_type_str(), self.id))
@classmethod
@ -1620,8 +1620,8 @@ class TextCell(CellBase):
text = re.sub(r'src="(.*?)"', sub_src, text)
text = re.sub(r'href="(.*?)"', sub_href, text)
extra_context["text"] = mark_safe(text)
extra_context["title"] = mark_safe(self.title) if self.title else None
extra_context['text'] = mark_safe(text)
extra_context['title'] = mark_safe(self.title) if self.title else None
return extra_context

View File

@ -179,7 +179,7 @@ def skeleton_extra_placeholder(parser, token):
try:
dummy, placeholder_name = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError("%r tag requires exactly one argument" % token.contents.split()[0])
raise template.TemplateSyntaxError('%r tag requires exactly one argument' % token.contents.split()[0])
tokens_copy = parser.tokens[:]
if django.VERSION < (3,):

View File

@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "combo.settings")
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'combo.settings')
application = get_wsgi_application()

View File

@ -2,8 +2,8 @@
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "combo.settings")
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'combo.settings')
from django.core.management import execute_from_command_line

View File

@ -4,7 +4,7 @@ import tempfile
DATABASES = {
'default': {
'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.postgresql_psycopg2'),
'NAME': 'combo-test-%s' % os.environ.get("BRANCH_NAME", "").replace('/', '-')[:35],
'NAME': 'combo-test-%s' % os.environ.get('BRANCH_NAME', '').replace('/', '-')[:35],
}
}
@ -116,7 +116,7 @@ USER_PROFILE_CONFIG = {
LEGACY_URLS_MAPPING = {'old.org': 'new.org'}
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher']
REST_FRAMEWORK = {
# this is the default value but by explicitely setting it

View File

@ -1027,7 +1027,7 @@ def test_config_json_cell_with_param_in_url(app):
'url': 'http://foo?var=[identifier]',
'log_errors': False,
'timeout': 42,
'form': [{"varname": "identifier", "type": "string", "label": "Identifier"}],
'form': [{'varname': 'identifier', 'type': 'string', 'label': 'Identifier'}],
}
},
TEMPLATES=templates_settings,
@ -1060,8 +1060,8 @@ def test_config_json_cell_with_template_string(settings, context):
'name': 'Foobar',
'url': 'http://foo',
'form': [
{"varname": "identifier", "type": "string", "label": "Identifier"},
{"varname": "template_string", "type": "text", "label": "Template"},
{'varname': 'identifier', 'type': 'string', 'label': 'Identifier'},
{'varname': 'template_string', 'type': 'text', 'label': 'Template'},
],
},
}
@ -1084,7 +1084,7 @@ def test_config_json_cell_with_template_string(settings, context):
'name': 'Foobar',
'url': 'http://foo',
'form': [
{"varname": "identifier", "type": "string", "label": "Identifier"},
{'varname': 'identifier', 'type': 'string', 'label': 'Identifier'},
],
},
}
@ -1103,14 +1103,14 @@ def test_config_json_cell_with_global(settings, app):
'url': 'http://foo',
'make_global': 'new_global_context',
'form': [
{"varname": "template_string", "type": "text", "label": "Template"},
{'varname': 'template_string', 'type': 'text', 'label': 'Template'},
],
},
'test-config-json-cell-2': {
'name': 'Foobar 2',
'url': 'http://foo',
'form': [
{"varname": "template_string", "type": "text", "label": "Template"},
{'varname': 'template_string', 'type': 'text', 'label': 'Template'},
],
},
}
@ -1152,7 +1152,7 @@ def test_config_json_cell_with_repeat(settings, app):
'name': 'Foobar',
'url': 'http://foo',
'form': [
{"varname": "template_string", "type": "text", "label": "Template"},
{'varname': 'template_string', 'type': 'text', 'label': 'Template'},
],
},
'test-config-json-cell-2': {
@ -1160,7 +1160,7 @@ def test_config_json_cell_with_repeat(settings, app):
'url': 'http://foo',
'repeat': '3',
'form': [
{"varname": "template_string", "type": "text", "label": "Template"},
{'varname': 'template_string', 'type': 'text', 'label': 'Template'},
],
},
}
@ -1574,8 +1574,8 @@ def test_page_cell_placeholder_restricted_visibility(app, admin_user):
)
)
assert "<p>Public text</p>" in resp.text
assert "<p>Private text</p>" not in resp.text
assert '<p>Public text</p>' in resp.text
assert '<p>Private text</p>' not in resp.text
app = login(app)
resp = app.get(
@ -1586,7 +1586,7 @@ def test_page_cell_placeholder_restricted_visibility(app, admin_user):
)
assert resp.pyquery('.shown-because-admin').text() == 'Public text'
assert "<p>Private text</p>" in resp.text
assert '<p>Private text</p>' in resp.text
def test_page_cell_placeholder_text_cell_title(app, admin_user):

View File

@ -416,34 +416,34 @@ STATISTICS_LIST = {
'url': 'https://authentic.example.com/api/statistics/one-serie/',
'name': 'One serie stat',
'id': 'one-serie',
"filters": [
'filters': [
{
"default": "month",
"id": "time_interval",
"label": "Time interval",
"options": [
{"id": "day", "label": "Day"},
{"id": "month", "label": "Month"},
{"id": "year", "label": "Year"},
'default': 'month',
'id': 'time_interval',
'label': 'Time interval',
'options': [
{'id': 'day', 'label': 'Day'},
{'id': 'month', 'label': 'Month'},
{'id': 'year', 'label': 'Year'},
],
"required": True,
'required': True,
},
{
"id": "ou",
"label": "Organizational Unit",
"options": [
{"id": "default", "label": "Default OU"},
{"id": "other", "label": "Other OU"},
'id': 'ou',
'label': 'Organizational Unit',
'options': [
{'id': 'default', 'label': 'Default OU'},
{'id': 'other', 'label': 'Other OU'},
],
},
{
"id": "service",
"label": "Service",
"options": [
{"id": "chrono", "label": "Chrono"},
{"id": "combo", "label": "Combo"},
'id': 'service',
'label': 'Service',
'options': [
{'id': 'chrono', 'label': 'Chrono'},
{'id': 'combo', 'label': 'Combo'},
],
"default": "chrono",
'default': 'chrono',
},
],
},
@ -466,15 +466,15 @@ STATISTICS_LIST = {
'url': 'https://authentic.example.com/api/statistics/daily/',
'name': 'Daily discontinuous serie',
'id': 'daily',
"filters": [
'filters': [
{
"default": "day",
"id": "time_interval",
"label": "Time interval",
"options": [
{"id": "day", "label": "Day"},
'default': 'day',
'id': 'time_interval',
'label': 'Time interval',
'options': [
{'id': 'day', 'label': 'Day'},
],
"required": True,
'required': True,
}
],
},
@ -482,15 +482,15 @@ STATISTICS_LIST = {
'url': 'https://authentic.example.com/api/statistics/leap-week/',
'name': 'Same week spanning two years',
'id': 'leap-week',
"filters": [
'filters': [
{
"default": "day",
"id": "time_interval",
"label": "Time interval",
"options": [
{"id": "day", "label": "Day"},
'default': 'day',
'id': 'time_interval',
'label': 'Time interval',
'options': [
{'id': 'day', 'label': 'Day'},
],
"required": True,
'required': True,
}
],
},
@ -498,16 +498,16 @@ STATISTICS_LIST = {
'url': 'https://authentic.example.com/api/statistics/filter-multiple/',
'name': 'Filter on multiple values',
'id': 'filter-multiple',
"filters": [
'filters': [
{
"id": "color",
"label": "Color",
"options": [
{"id": "red", "label": "Red"},
{"id": "green", "label": "Green"},
{"id": "blue", "label": "Blue"},
'id': 'color',
'label': 'Color',
'options': [
{'id': 'red', 'label': 'Red'},
{'id': 'green', 'label': 'Green'},
{'id': 'blue', 'label': 'Blue'},
],
"multiple": True,
'multiple': True,
}
],
},
@ -546,24 +546,24 @@ STATISTICS_LIST = {
'url': 'https://authentic.example.com/api/statistics/option-groups/',
'name': 'Option groups',
'id': 'option-groups',
"filters": [
'filters': [
{
"id": "form",
"label": "Form",
"options": [
'id': 'form',
'label': 'Form',
'options': [
[None, [{'id': 'all', 'label': 'All'}]],
['Category A', [{'id': 'test', 'label': 'Test'}]],
['Category B', [{'id': 'test-2', 'label': 'test 2'}]],
],
},
{
"id": "cards_count",
"label": "Cards",
"options": [
'id': 'cards_count',
'label': 'Cards',
'options': [
['Category A', [{'id': 'test', 'label': 'Test'}]],
['Category B', [{'id': 'test-2', 'label': 'test 2'}]],
],
"required": True,
'required': True,
},
],
},
@ -571,12 +571,12 @@ STATISTICS_LIST = {
'url': 'https://authentic.example.com/api/statistics/option-groups-2/',
'name': 'Option groups 2',
'id': 'option-groups-2',
"filters": [
'filters': [
{
"id": "form",
"label": "Form",
"required": True,
"options": [
'id': 'form',
'label': 'Form',
'required': True,
'options': [
[None, [{'id': 'all', 'label': 'All'}]],
['Category A', [{'id': 'test', 'label': 'Test'}, {'id': 'other', 'label': 'Other'}]],
],
@ -587,10 +587,10 @@ STATISTICS_LIST = {
'url': 'https://authentic.example.com/api/statistics/deprecated-filter/',
'name': 'Deprecated filter',
'id': 'deprecated-filter',
"filters": [
'filters': [
{
"id": "form",
"label": "Form",
'id': 'form',
'label': 'Form',
'deprecated': True,
'deprecation_hint': 'This field should not be used',
'options': [
@ -599,8 +599,8 @@ STATISTICS_LIST = {
],
},
{
"id": "card",
"label": "Card",
'id': 'card',
'label': 'Card',
'deprecated': True,
'options': [
{'id': 'one', 'label': 'One'},
@ -614,15 +614,15 @@ STATISTICS_LIST = {
'url': 'https://authentic.example.com/api/statistics/required-without-default/',
'name': 'Required without default',
'id': 'required-without-default',
"filters": [
'filters': [
{
"id": "test",
"label": "Test",
"options": [
{"id": "b", "label": "B"},
{"id": "a", "label": "A"},
'id': 'test',
'label': 'Test',
'options': [
{'id': 'b', 'label': 'B'},
{'id': 'a', 'label': 'A'},
],
"required": True,
'required': True,
},
],
},
@ -652,16 +652,16 @@ STATISTICS_LIST = {
'url': 'https://authentic.example.com/api/statistics/required-boolean/',
'name': 'Required boolean choices',
'id': 'required-boolean',
"filters": [
'filters': [
{
"id": "test",
"label": "Test",
"options": [
{"id": "true", "label": "True"},
{"id": "false", "label": "False"},
'id': 'test',
'label': 'Test',
'options': [
{'id': 'true', 'label': 'True'},
{'id': 'false', 'label': 'False'},
],
"default": "true",
"required": True,
'default': 'true',
'required': True,
},
],
},
@ -742,11 +742,11 @@ def new_api_mock(url, request):
if 'form=food-request' in url.query:
response['data']['subfilters'] = [
{
"id": "menu",
"label": "Menu",
"options": [
{"id": "meat", "label": "Meat"},
{"id": "vegan", "label": "Vegan"},
'id': 'menu',
'label': 'Menu',
'options': [
{'id': 'meat', 'label': 'Meat'},
{'id': 'vegan', 'label': 'Vegan'},
],
}
]
@ -788,8 +788,8 @@ def new_api_mock(url, request):
@with_httmock(bijoe_mock)
def statistics(settings):
settings.KNOWN_SERVICES = {
"bijoe": {
"plop": {"title": "test", "url": "https://bijoe.example.com", "secret": "combo", "orig": "combo"}
'bijoe': {
'plop': {'title': 'test', 'url': 'https://bijoe.example.com', 'secret': 'combo', 'orig': 'combo'}
}
}
settings.STATISTICS_PROVIDERS = ['bijoe']

View File

@ -210,15 +210,15 @@ def test_tipi_cell():
cell = TipiPaymentFormCell()
cell.page = page
cell.title = 'TIPI Payment'
cell.regies = "1234"
cell.regies = '1234'
cell.order = 0
cell.save()
assert cell.control_protocol == 'pesv2'
assert cell.url == 'https://www.payfip.gouv.fr/tpa/paiement.web'
assert cell.default_template_name == 'lingo/tipi_form.html'
html = cell.render({})
assert "<h2>TIPI Payment</h2>" in html
assert "Community identifier" not in html
assert '<h2>TIPI Payment</h2>' in html
assert 'Community identifier' not in html
assert '<input type="hidden" id="numcli" value="1234" />' in html
assert 'id="exer"' in html
assert 'id="idpce"' in html
@ -229,12 +229,12 @@ def test_tipi_cell():
assert 'data-saisie="M"' in html
assert 'data-pesv2="True"' in html
cell.regies = "1234 - test regie"
cell.regies = '1234 - test regie'
cell.save()
html = cell.render({})
assert '<input type="hidden" id="numcli" value="1234" />' in html
cell.regies = "test regie"
cell.regies = 'test regie'
cell.save()
html = cell.render({})
assert '<input type="hidden" id="numcli" value="" />' in html
@ -252,12 +252,12 @@ def test_tipi_cell():
assert 'data-pesv2="False"' in html
cell_media = str(cell.media)
assert "js/tipi.js" in cell_media
assert 'js/tipi.js' in cell_media
cell.regies = '1 regie1, 2- regie2,3 : regie3,4,5regie5 ,bad-format-regie 6'
cell.save()
html = cell.render({})
assert "Community identifier" in html
assert 'Community identifier' in html
assert '<select id="numcli">' in html
assert '<option value="1">1 regie1</option>' in html
assert '<option value="2">2- regie2</option>' in html

View File

@ -495,7 +495,7 @@ def test_basket_items_extra_info_no_basket(app, regie, basket_page, monkeypatch)
)
@pytest.mark.parametrize("invalid_capture_date", [8, '', 'not-a-date'])
@pytest.mark.parametrize('invalid_capture_date', [8, '', 'not-a-date'])
def test_add_basket_capture_date_format(app, user_name_id, regie, invalid_capture_date):
url = '%s?NameId=%s' % (reverse('api-add-basket-item'), user_name_id)
data = {'amount': 10, 'display_name': 'test item'}
@ -547,7 +547,7 @@ def test_cant_pay_if_different_capture_date(mock_trigger_request, app, basket_pa
assert resp.status_code == 302
assert urllib.parse.urlparse(resp.location).path == '/test_basket_cell/'
resp = resp.follow()
assert "Invalid grouping for basket items: different capture dates." in resp.text
assert 'Invalid grouping for basket items: different capture dates.' in resp.text
assert mock_trigger_request.call_count == 0
@ -1543,7 +1543,7 @@ def test_payment_callback_not_found(app, user, regie):
app.get(callback_url, params=data, status=404)
@pytest.mark.parametrize("authenticated", [True, False])
@pytest.mark.parametrize('authenticated', [True, False])
def test_payment_no_basket(app, user_name_id, regie, authenticated):
url = reverse('api-add-basket-item')
source_url = 'http://example.org/item/1/'

View File

@ -150,10 +150,10 @@ def test_invoices_cell_get_payer_external_id(remote_regie):
assert cell.get_payer_external_id(context) is None
cell.payer_external_id_template = '{{ "" }}' # empty
assert cell.get_payer_external_id(context) == ""
assert cell.get_payer_external_id(context) == ''
cell.payer_external_id_template = '{{ "foo" }}' # something
assert cell.get_payer_external_id(context) == "foo"
assert cell.get_payer_external_id(context) == 'foo'
# check that cards|objects is working
data = {'data': []}
@ -162,7 +162,7 @@ def test_invoices_cell_get_payer_external_id(remote_regie):
cell.payer_external_id_template = (
'{{ cards|objects:"foo"|get_full|first|get:"fields"|get:"bar"|default:"baz" }}'
)
assert cell.get_payer_external_id(context) == "baz"
assert cell.get_payer_external_id(context) == 'baz'
# syntax error
cell.payer_external_id_template = '{% for %}'
@ -181,10 +181,10 @@ def test_payments_cell_get_payer_external_id(remote_regie):
assert cell.get_payer_external_id(context) is None
cell.payer_external_id_template = '{{ "" }}' # empty
assert cell.get_payer_external_id(context) == ""
assert cell.get_payer_external_id(context) == ''
cell.payer_external_id_template = '{{ "foo" }}' # something
assert cell.get_payer_external_id(context) == "foo"
assert cell.get_payer_external_id(context) == 'foo'
# check that cards|objects is working
data = {'data': []}
@ -193,7 +193,7 @@ def test_payments_cell_get_payer_external_id(remote_regie):
cell.payer_external_id_template = (
'{{ cards|objects:"foo"|get_full|first|get:"fields"|get:"bar"|default:"baz" }}'
)
assert cell.get_payer_external_id(context) == "baz"
assert cell.get_payer_external_id(context) == 'baz'
# syntax error
cell.payer_external_id_template = '{% for %}'

View File

@ -1219,7 +1219,7 @@ def test_site_export_import_unknown_page(app, admin_user):
resp = app.get('/manage/site-import')
resp.form['site_file'] = Upload('site-export.json', force_bytes(json.dumps(payload)), 'application/json')
with mock.patch('combo.data.models.Page.load_serialized_pages') as mock_load:
mock_load.side_effect = DeserializationError("Page matching query does not exist.")
mock_load.side_effect = DeserializationError('Page matching query does not exist.')
resp = resp.form.submit()
assert resp.context['form'].errors['site_file'] == ['Page matching query does not exist.']
@ -2885,7 +2885,7 @@ def test_manager_link_cell_tabs(app, admin_user):
assert not resp.pyquery('#tab-%s-visibility.pk-tabs--button-marker' % cell.get_reference())
assert not resp.pyquery('[data-tab-slug="appearance"] input[name$="title"]')
cell.title = "Custom"
cell.title = 'Custom'
cell.public = False
cell.save()
resp = app.get('/manage/pages/%s/' % page.pk)

View File

@ -298,7 +298,7 @@ def test_get_geojson(app, layer, user):
# invalid url - missing scheme
resp = app.get(geojson_url)
assert len(resp.json['features']) == 0
assert resp.json['_combo_err_desc'].startswith("Bad response from requested URL (Invalid URL")
assert resp.json['_combo_err_desc'].startswith('Bad response from requested URL (Invalid URL')
layer.geojson_url = 'http://example.org/geojson?t1'
layer.save()

View File

@ -14,42 +14,42 @@ def test_page_snapshot_with_old_lingo_invoices_cells_migration(transactional_db)
snapshot = pagesnapshot_class.objects.create(
serialization={
"cells": [
'cells': [
{
"model": "lingo.activeitems",
"fields": {
"slug": "foo",
"text": "Foo",
"order": 1,
"regie": "blah",
"title": "Fooo",
"groups": [],
"public": True,
"condition": None,
"placeholder": "content",
"hide_if_empty": True,
"template_name": None,
"extra_css_class": "",
"last_update_timestamp": "2023-04-11T15:28:14.052Z",
"restricted_to_unlogged": False,
'model': 'lingo.activeitems',
'fields': {
'slug': 'foo',
'text': 'Foo',
'order': 1,
'regie': 'blah',
'title': 'Fooo',
'groups': [],
'public': True,
'condition': None,
'placeholder': 'content',
'hide_if_empty': True,
'template_name': None,
'extra_css_class': '',
'last_update_timestamp': '2023-04-11T15:28:14.052Z',
'restricted_to_unlogged': False,
},
},
{
"model": "lingo.itemshistory",
"fields": {
"slug": "bar",
"text": "Bar",
"order": 2,
"regie": "blah",
"title": "Baar",
"groups": [],
"public": True,
"condition": None,
"placeholder": "content",
"template_name": None,
"extra_css_class": "",
"last_update_timestamp": "2023-04-11T15:28:27.174Z",
"restricted_to_unlogged": False,
'model': 'lingo.itemshistory',
'fields': {
'slug': 'bar',
'text': 'Bar',
'order': 2,
'regie': 'blah',
'title': 'Baar',
'groups': [],
'public': True,
'condition': None,
'placeholder': 'content',
'template_name': None,
'extra_css_class': '',
'last_update_timestamp': '2023-04-11T15:28:27.174Z',
'restricted_to_unlogged': False,
},
},
]
@ -65,46 +65,46 @@ def test_page_snapshot_with_old_lingo_invoices_cells_migration(transactional_db)
snapshot = pagesnapshot_class.objects.get()
assert snapshot.serialization['cells'][0] == {
"model": "lingo.invoicescell",
"fields": {
"slug": "foo",
"text": "Foo",
"order": 1,
"regie": "blah",
"title": "Fooo",
"groups": [],
"public": True,
"condition": None,
"placeholder": "content",
"hide_if_empty": True,
"template_name": None,
"extra_css_class": "",
"last_update_timestamp": "2023-04-11T15:28:14.052Z",
"restricted_to_unlogged": False,
"display_mode": "active",
"payer_external_id_template": "",
"include_pay_button": True,
'model': 'lingo.invoicescell',
'fields': {
'slug': 'foo',
'text': 'Foo',
'order': 1,
'regie': 'blah',
'title': 'Fooo',
'groups': [],
'public': True,
'condition': None,
'placeholder': 'content',
'hide_if_empty': True,
'template_name': None,
'extra_css_class': '',
'last_update_timestamp': '2023-04-11T15:28:14.052Z',
'restricted_to_unlogged': False,
'display_mode': 'active',
'payer_external_id_template': '',
'include_pay_button': True,
},
}
assert snapshot.serialization['cells'][1] == {
"model": "lingo.invoicescell",
"fields": {
"slug": "bar",
"text": "Bar",
"order": 2,
"regie": "blah",
"title": "Baar",
"groups": [],
"public": True,
"condition": None,
"placeholder": "content",
"hide_if_empty": False,
"template_name": None,
"extra_css_class": "",
"last_update_timestamp": "2023-04-11T15:28:27.174Z",
"restricted_to_unlogged": False,
"display_mode": "historical",
"payer_external_id_template": "",
"include_pay_button": True,
'model': 'lingo.invoicescell',
'fields': {
'slug': 'bar',
'text': 'Bar',
'order': 2,
'regie': 'blah',
'title': 'Baar',
'groups': [],
'public': True,
'condition': None,
'placeholder': 'content',
'hide_if_empty': False,
'template_name': None,
'extra_css_class': '',
'last_update_timestamp': '2023-04-11T15:28:27.174Z',
'restricted_to_unlogged': False,
'display_mode': 'historical',
'payer_external_id_template': '',
'include_pay_button': True,
},
}

View File

@ -294,9 +294,9 @@ def test_notify_remote_items(mock_get, app, john_doe, jane_doe, regie, monkeypat
invoice_now = now()
invoice_now = freezer()
FAKE_PENDING_INVOICES = {
"data": {
'data': {
john_doe.username: {
"invoices": [
'invoices': [
{
'id': '01',
'label': '010101',

View File

@ -421,7 +421,7 @@ def test_get_placeholders():
def test_render(app):
page = Page(
title='foo', slug='foo', template_name='standard-sidebar', order=0, description="page description"
title='foo', slug='foo', template_name='standard-sidebar', order=0, description='page description'
)
page.save()
response = app.get(page.get_online_url())
@ -431,7 +431,7 @@ def test_render(app):
def test_render_cell_having_href_template_error(app):
page = Page(
title='foo', slug='foo', template_name='standard-sidebar', order=0, description="page description"
title='foo', slug='foo', template_name='standard-sidebar', order=0, description='page description'
)
page.save()
cell = TextCell(
@ -439,7 +439,7 @@ def test_render_cell_having_href_template_error(app):
)
cell.save()
response = app.get(page.get_online_url())
assert "{{e-service_url}}backoffice/..." in response.text # href not rendered
assert '{{e-service_url}}backoffice/...' in response.text # href not rendered
def test_cell_maintain_page_cell_cache(freezer):

View File

@ -508,7 +508,7 @@ def test_page_skeleton(app):
cell.save()
resp = app.get('/__skeleton__/?source=%s' % quote('http://example.net/foo/bar'))
assert "Foobar2" in resp.text
assert 'Foobar2' in resp.text
def test_page_skeleton_missing_template(app):
@ -655,7 +655,7 @@ def test_404(app):
cell.save()
resp = app.get('/foobar/', status=404)
assert "This page doesn't exist" in resp.text
assert "FOOBAR" in resp.text
assert 'FOOBAR' in resp.text
index_page.delete()
# check decidated custom page
@ -668,7 +668,7 @@ def test_404(app):
with override_settings(DEBUG=True):
# check error page provides an hint when debugging
resp = app.get('/foobar/', status=404)
assert "find the requested page" in resp.text
assert 'find the requested page' in resp.text
# check native django handler is used if all pages are private
page.public = False

View File

@ -41,8 +41,8 @@ def test_service_worker(app):
# check legacy settings are still supported
with override_settings(
PWA_VAPID_PUBLIK_KEY="BFzvUdXB...",
PWA_VAPID_PRIVATE_KEY="4WbCnBF...",
PWA_VAPID_PUBLIK_KEY='BFzvUdXB...',
PWA_VAPID_PRIVATE_KEY='4WbCnBF...',
PWA_VAPID_CLAIMS={'sub': 'mailto:admin@entrouvert.com'},
):
resp = app.get('/service-worker-registration.js', status=200)
@ -92,8 +92,8 @@ def test_webpush_notification(app, john_doe):
# check legacy settings are still supported
with override_settings(
PWA_VAPID_PUBLIK_KEY="BFzvUdXB...",
PWA_VAPID_PRIVATE_KEY="4WbCnBF...",
PWA_VAPID_PUBLIK_KEY='BFzvUdXB...',
PWA_VAPID_PRIVATE_KEY='4WbCnBF...',
PWA_VAPID_CLAIMS={'sub': 'mailto:admin@entrouvert.com'},
):
with mock.patch('pywebpush.webpush') as webpush:

View File

@ -185,8 +185,8 @@ def test_category_cell_render(mock_send, settings):
context = {'synchronous': True} # to get fresh content
result = cell.render(context)
assert "Test 3" in result
assert "category 3 description" in result
assert 'Test 3' in result
assert 'category 3 description' in result
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)

View File

@ -683,8 +683,8 @@ def test_manager_card_cell(mock_send, app, admin_user):
placeholder='content',
order=2,
carddef_reference='default:card_e',
slug="sluge-again",
card_ids="42",
slug='sluge-again',
card_ids='42',
related_card_path='',
)
resp = app.get('/manage/pages/%s/' % page.pk)
@ -943,7 +943,7 @@ def test_card_cell_table_mode_render_custom_schema_card_field(mock_send, context
'file.pdf',
'', # it's an image !
"lorem<strong>ipsum hello'world", # no multiline support for now
"lorem<strong>ipsum hello world",
'lorem<strong>ipsum hello world',
'test@localhost',
'https://www.example.net/',
"loremipsum\nhello'world",
@ -1295,25 +1295,25 @@ def test_card_cell_table_mode_render_with_headers(mock_send, context, with_heade
custom_schema={
'grid_headers': with_headers,
'cells': [
{'varname': '@custom@', 'template': "foo bar"},
{'varname': '@custom@', 'template': "foo bar bis", "header": "My Custom Header"},
{'varname': '@custom@', 'template': ""}, # not displayed
{'varname': '@custom@', 'template': 'foo bar'},
{'varname': '@custom@', 'template': 'foo bar bis', 'header': 'My Custom Header'},
{'varname': '@custom@', 'template': ''}, # not displayed
{'varname': 'fieldb'},
{'varname': 'user:name'},
{'varname': 'user:email'},
{'varname': 'user:first_name'},
{'varname': 'user:last_name'},
{'varname': '@link@', 'template': "Foo", 'url_template': 'http://foo/bar', 'header': 'Link'},
{'varname': '@link@', 'template': "Bar", 'url_template': '{# empty #}', 'header': 'Link Bis'},
{'varname': '@link@', 'template': 'Foo', 'url_template': 'http://foo/bar', 'header': 'Link'},
{'varname': '@link@', 'template': 'Bar', 'url_template': '{# empty #}', 'header': 'Link Bis'},
{
'varname': '@link@',
'template': "",
'template': '',
'url_template': 'http://foo/bar',
'header': 'Link Not Displayed',
},
{
'varname': '@link@',
'template': "Bar",
'template': 'Bar',
'url_template': '',
'header': 'Link Bis Not Displayed',
},

View File

@ -34,10 +34,10 @@ def mocked_requests_send(request, **kwargs):
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
def test_publik_django_templatetags_integration(mock_send, context, nocache):
t = Template('{{ cards|objects:"foo"|count }}')
assert t.render(context) == "2"
assert t.render(context) == '2'
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
def test_with_explicit_load_wcs(mock_send, context, nocache):
t = Template('{% load wcs %}{{ cards|objects:"foo"|count }}')
assert t.render(context) == "2"
assert t.render(context) == '2'