From 9d8876e155e8a433ebafbd4ccb9de4960d1830b4 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Wed, 16 Aug 2023 10:07:28 +0200 Subject: [PATCH] misc: apply double-quote-string-fixer (#79788) --- combo/apps/dataviz/models.py | 6 +- combo/apps/lingo/views.py | 6 +- combo/apps/maps/models.py | 14 +-- combo/apps/search/forms.py | 2 +- combo/apps/search/models.py | 2 +- combo/data/models.py | 6 +- combo/public/templatetags/combo.py | 2 +- combo/wsgi.py | 2 +- manage.py | 4 +- tests/settings.py | 4 +- tests/test_cells.py | 22 ++-- tests/test_dataviz.py | 164 ++++++++++++++--------------- tests/test_lingo_cells.py | 14 +-- tests/test_lingo_payment.py | 6 +- tests/test_lingo_remote_regie.py | 12 +-- tests/test_manager.py | 4 +- tests/test_maps_cells.py | 2 +- tests/test_migrations.py | 140 ++++++++++++------------ tests/test_notification.py | 4 +- tests/test_pages.py | 6 +- tests/test_public.py | 6 +- tests/test_pwa.py | 8 +- tests/wcs/test_all.py | 4 +- tests/wcs/test_card.py | 20 ++-- tests/wcs/test_templatetags.py | 4 +- 25 files changed, 232 insertions(+), 232 deletions(-) diff --git a/combo/apps/dataviz/models.py b/combo/apps/dataviz/models.py index dc3e9627..7634dd86 100644 --- a/combo/apps/dataviz/models.py +++ b/combo/apps/dataviz/models.py @@ -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': diff --git a/combo/apps/lingo/views.py b/combo/apps/lingo/views.py index 91aff9c2..e6ee1854 100644 --- a/combo/apps/lingo/views.py +++ b/combo/apps/lingo/views.py @@ -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: diff --git a/combo/apps/maps/models.py b/combo/apps/maps/models.py index da8a6f1d..cdc54059 100644 --- a/combo/apps/maps/models.py +++ b/combo/apps/maps/models.py @@ -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: diff --git a/combo/apps/search/forms.py b/combo/apps/search/forms.py index 781d33a7..1facf0b3 100644 --- a/combo/apps/search/forms.py +++ b/combo/apps/search/forms.py @@ -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(), ) diff --git a/combo/apps/search/models.py b/combo/apps/search/models.py index 41b0d8ba..5932132f 100644 --- a/combo/apps/search/models.py +++ b/combo/apps/search/models.py @@ -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') diff --git a/combo/data/models.py b/combo/data/models.py index 0be71f7f..fb9b95c2 100644 --- a/combo/data/models.py +++ b/combo/data/models.py @@ -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 diff --git a/combo/public/templatetags/combo.py b/combo/public/templatetags/combo.py index efcdc5d5..c798bdf6 100644 --- a/combo/public/templatetags/combo.py +++ b/combo/public/templatetags/combo.py @@ -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,): diff --git a/combo/wsgi.py b/combo/wsgi.py index 2f794803..a3a73f9d 100644 --- a/combo/wsgi.py +++ b/combo/wsgi.py @@ -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() diff --git a/manage.py b/manage.py index fddbd9fd..988b9140 100755 --- a/manage.py +++ b/manage.py @@ -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 diff --git a/tests/settings.py b/tests/settings.py index 4a99f3c6..4e98b52e 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -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 diff --git a/tests/test_cells.py b/tests/test_cells.py index 58582cfe..71d4fc47 100644 --- a/tests/test_cells.py +++ b/tests/test_cells.py @@ -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 "

Public text

" in resp.text - assert "

Private text

" not in resp.text + assert '

Public text

' in resp.text + assert '

Private text

' 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 "

Private text

" in resp.text + assert '

Private text

' in resp.text def test_page_cell_placeholder_text_cell_title(app, admin_user): diff --git a/tests/test_dataviz.py b/tests/test_dataviz.py index 494124da..f453830f 100644 --- a/tests/test_dataviz.py +++ b/tests/test_dataviz.py @@ -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'] diff --git a/tests/test_lingo_cells.py b/tests/test_lingo_cells.py index 0a43ac50..bb51c6db 100644 --- a/tests/test_lingo_cells.py +++ b/tests/test_lingo_cells.py @@ -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 "

TIPI Payment

" in html - assert "Community identifier" not in html + assert '

TIPI Payment

' in html + assert 'Community identifier' not in html assert '' 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 '' in html - cell.regies = "test regie" + cell.regies = 'test regie' cell.save() html = cell.render({}) assert '' 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 '