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

This commit is contained in:
Valentin Deniaud 2023-08-16 11:52:19 +02:00
parent 3027580dd5
commit 62e2e241da
4 changed files with 591 additions and 591 deletions

File diff suppressed because it is too large Load Diff

View File

@ -322,7 +322,7 @@ def get_mairie_opening_hours(mairie_data):
period, all_day_hours = get_period_from_data(time_table)
if all_day_hours and period == 'am':
opening_hours_dict[weekday]['pm'] = '' # empty string to avoid displaying fermé
opening_hours_dict[weekday][period] = "%sh%s-%sh%s" % (
opening_hours_dict[weekday][period] = '%sh%s-%sh%s' % (
time_table['start_hour'],
time_table['start_minute'],
time_table['end_hour'],
@ -413,7 +413,7 @@ def as_opening_hours_badge(data):
slots[i] = None
def format_time(hour, minute):
time = "%sh%02d" % (hour, minute)
time = '%sh%02d' % (hour, minute)
if time == '0h00':
time = 'minuit'
return time
@ -434,7 +434,7 @@ def as_opening_hours_badge(data):
day_label = 'demain'
else:
day_label = FR_WEEKDAYS[slots[0].start.weekday()]
if slots[0].start.strftime("%H:%M") == slots[0].end.strftime("%H:%M") == '00:00':
if slots[0].start.strftime('%H:%M') == slots[0].end.strftime('%H:%M') == '00:00':
label = '%s %s 24h/24' % (verb, day_label)
else:
time = format_time(slots[0].start.hour, slots[0].start.minute)
@ -444,8 +444,8 @@ def as_opening_hours_badge(data):
klass = 'soon-to-be-closed'
else:
klass = 'open'
if slots[0].start.strftime("%H:%M") == slots[0].end.strftime("%H:%M") == '00:00':
label = "Ouvert 24h/24"
if slots[0].start.strftime('%H:%M') == slots[0].end.strftime('%H:%M') == '00:00':
label = 'Ouvert 24h/24'
else:
time = format_time(slots[0].end.hour, slots[0].end.minute)
label = "Ouvert jusqu'à %s" % time

View File

@ -9,11 +9,11 @@ from combo_plugin_gnm.templatetags.gnm import EN_FULL_WEEKDAYS_LIST, FR_WEEKDAYS
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
GEOJSON = json.load(open(os.path.join(BASE_DIR, 'tests/data/mairie-geojson.json')))['features']
MDR_GEOJSON = json.load(open(os.path.join(BASE_DIR, 'tests/data/mdr-geojson.json')))['features']
TZOFFSETS = {"Europe/Paris": 3600}
TZOFFSETS = {'Europe/Paris': 3600}
@pytest.mark.freeze_time(
"2018-03-04 23:00:00",
'2018-03-04 23:00:00',
)
def test_every_mairie_closed():
"""every mairie is closed at mignight"""
@ -21,7 +21,7 @@ def test_every_mairie_closed():
assert len([x for x in opening_hours if 'open' in x]) == 0
@pytest.mark.freeze_time("2018-03-04 23:00:00")
@pytest.mark.freeze_time('2018-03-04 23:00:00')
def test_all_mairie_data_parsed_correct():
"""everything got parsed correctly"""
opening_hours = [
@ -32,14 +32,14 @@ def test_all_mairie_data_parsed_correct():
assert opening_hours.count('') == 0
@pytest.mark.freeze_time("2018-03-05 14:59:00")
@pytest.mark.freeze_time('2018-03-05 14:59:00')
def test_empty_data():
""" "no data return the empty html"""
test_html = as_opening_hours_badge(GEOJSON[0]['properties'])
assert test_html == ''
@pytest.mark.freeze_time("2018-08-13 14:59:00")
@pytest.mark.freeze_time('2018-08-13 14:59:00')
def test_mairie_bron_monday():
"""S1326"""
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1326'][0]
@ -47,15 +47,15 @@ def test_mairie_bron_monday():
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-08-12 14:59:00")
@pytest.mark.freeze_time('2018-08-12 14:59:00')
def test_mairie_bron_sunday():
"""S1326"""
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1326'][0]
klass, label = 'closed', "Réouvre demain à 8h00"
klass, label = 'closed', 'Réouvre demain à 8h00'
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-08-09 13:30:01")
@pytest.mark.freeze_time('2018-08-09 13:30:01')
def test_mairie_sathonay_thursday_afternoon():
"""S1326"""
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1415'][0]
@ -63,15 +63,15 @@ def test_mairie_sathonay_thursday_afternoon():
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-08-11 11:30:01")
@pytest.mark.freeze_time('2018-08-11 11:30:01')
def test_mairie_saint_priest_closed():
"""S1326"""
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1406'][0]
klass, label = 'closed', "Réouvre lundi à 8h15"
klass, label = 'closed', 'Réouvre lundi à 8h15'
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-08-22 12:13:01")
@pytest.mark.freeze_time('2018-08-22 12:13:01')
def test_mairie_saint_priest_open():
"""S1326"""
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1406'][0]
@ -79,17 +79,17 @@ def test_mairie_saint_priest_open():
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-08-11 14:59:00")
@pytest.mark.freeze_time('2018-08-11 14:59:00')
def test_mairie_bron_saturday():
"""S1326"""
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1326'][0]
klass, label = 'closed', "Réouvre lundi à 8h00"
klass, label = 'closed', 'Réouvre lundi à 8h00'
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 09:59:13")
@pytest.mark.freeze_time('2018-03-05 09:59:13')
def test_jonage_open():
"Jonage is defined only by openinghoursspecification data"
'Jonage is defined only by openinghoursspecification data'
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['nom'] == 'Mairie de Jonage'][
0
]
@ -97,9 +97,9 @@ def test_jonage_open():
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 11:32:00")
@pytest.mark.freeze_time('2018-03-05 11:32:00')
def test_jonage_soon_to_be_closed():
"Jonage is defined only by openinghoursspecification data"
'Jonage is defined only by openinghoursspecification data'
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['nom'] == 'Mairie de Jonage'][
0
]
@ -107,17 +107,17 @@ def test_jonage_soon_to_be_closed():
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-03-10 17:30:00")
@pytest.mark.freeze_time('2018-03-10 17:30:00')
def test_jonage_closed():
"Jonage is defined only by openinghoursspecification data"
'Jonage is defined only by openinghoursspecification data'
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['nom'] == 'Mairie de Jonage'][
0
]
klass, label = 'closed', "Réouvre lundi à 8h30"
klass, label = 'closed', 'Réouvre lundi à 8h30'
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 15:55:00")
@pytest.mark.freeze_time('2018-03-05 15:55:00')
def test_data_input_compatibility():
"""as_opening_hours with a fixed datetime"""
klass = 'open'
@ -128,7 +128,7 @@ def test_data_input_compatibility():
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 00:00:00")
@pytest.mark.freeze_time('2018-03-05 00:00:00')
def test_all_mdr_closed():
"""every mdr is closed at mignight"""
opening_hours = [as_opening_hours_badge(x) for x in MDR_GEOJSON]
@ -141,41 +141,41 @@ def test_all_mdr_data_parsed_correct():
assert opening_hours.count('') == 0
@pytest.mark.freeze_time("2018-03-05 14:59:00")
@pytest.mark.freeze_time('2018-03-05 14:59:00')
def test_mdr_open():
test_html = as_opening_hours_badge(MDR_GEOJSON[0])
klass, label = 'open', "Ouvert jusqu'à 16h45"
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 15:46:00")
@pytest.mark.freeze_time('2018-03-05 15:46:00')
def test_mdr_soon_to_be_closed():
test_html = as_opening_hours_badge(MDR_GEOJSON[0])
klass, label = 'soon-to-be-closed', "Ouvert jusqu'à 16h45"
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-03-10 17:30:00")
@pytest.mark.freeze_time('2018-03-10 17:30:00')
def test_mdr_just_closed():
test_html = as_opening_hours_badge(MDR_GEOJSON[0])
klass, label = 'closed', "Réouvre lundi à 8h30"
klass, label = 'closed', 'Réouvre lundi à 8h30'
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-01-01 14:59:00")
@pytest.mark.freeze_time('2018-01-01 14:59:00')
def test_mairie_holiday():
# Ecully, using datetimes
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1361'][0]
klass, label = 'closed', "Réouvre demain à 8h30"
klass, label = 'closed', 'Réouvre demain à 8h30'
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
# Feyzin, using dates
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1365'][0]
klass, label = 'closed', "Réouvre demain à 8h30"
klass, label = 'closed', 'Réouvre demain à 8h30'
assert test_html == mark_safe('<div class="badge %s"><span>%s</span></div>' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 00:30:00")
@pytest.mark.freeze_time('2018-03-05 00:30:00')
@pytest.mark.parametrize(
'day, hours, badge, text',
[
@ -188,7 +188,7 @@ def test_mairie_holiday():
('lundi_am', '00h00-00h45', 'soon-to-be-closed', "Ouvert jusqu'à 0h45"),
('dimanche_pm', '20h30-00h45', 'soon-to-be-closed', "Ouvert jusqu'à 0h45"),
('lundi_am', '00h15-24h00', 'open', "Ouvert jusqu'à minuit"),
('lundi_am', '00h00-24h00', 'open', "Ouvert 24h/24"),
('lundi_am', '00h00-24h00', 'open', 'Ouvert 24h/24'),
],
)
def test_mdr_format(day, hours, badge, text):
@ -206,7 +206,7 @@ def test_mdr_format(day, hours, badge, text):
assert html == '<div class="badge %s"><span>%s</span></div>' % (badge, text)
@pytest.mark.freeze_time("2018-03-05 00:30:00")
@pytest.mark.freeze_time('2018-03-05 00:30:00')
@pytest.mark.parametrize(
'openinghour, badge, text',
[
@ -219,7 +219,7 @@ def test_mdr_format(day, hours, badge, text):
('Mo 00:00-00:45', 'soon-to-be-closed', "Ouvert jusqu'à 0h45"),
('Su 20:30-00:45', 'soon-to-be-closed', "Ouvert jusqu'à 0h45"),
('Mo 00:15-24:00', 'open', "Ouvert jusqu'à minuit"),
('Mo 00:00-24:00', 'open', "Ouvert 24h/24"),
('Mo 00:00-24:00', 'open', 'Ouvert 24h/24'),
],
)
def test_mairie_format_openinghours(openinghour, badge, text):
@ -237,7 +237,7 @@ def test_mairie_format_openinghours(openinghour, badge, text):
assert html == '<div class="badge %s"><span>%s</span></div>' % (badge, text)
@pytest.mark.freeze_time("2018-03-05 00:30:00")
@pytest.mark.freeze_time('2018-03-05 00:30:00')
@pytest.mark.parametrize(
'day, opens, closes, badge, text',
[
@ -250,7 +250,7 @@ def test_mairie_format_openinghours(openinghour, badge, text):
('Monday', '00:00', '00:45', 'soon-to-be-closed', "Ouvert jusqu'à 0h45"),
('Sunday', '20:30', '00:45', 'soon-to-be-closed', "Ouvert jusqu'à 0h45"),
('Monday', '00:15', '24:00', 'open', "Ouvert jusqu'à minuit"),
('Monday', '00:00', '24:00', 'open', "Ouvert 24h/24"),
('Monday', '00:00', '24:00', 'open', 'Ouvert 24h/24'),
],
)
def test_mairie_format_openinghoursspecification(day, opens, closes, badge, text):
@ -275,7 +275,7 @@ def test_mairie_format_openinghoursspecification(day, opens, closes, badge, text
assert html == '<div class="badge %s"><span>%s</span></div>' % (badge, text)
@pytest.mark.freeze_time("2018-03-09 00:30:00")
@pytest.mark.freeze_time('2018-03-09 00:30:00')
def test_mairie_having_both_formats():
"""openinghoursspecification take preference over openinghours"""
geojson = r"""
@ -298,7 +298,7 @@ def test_mairie_having_both_formats():
assert html == '<div class="badge %s"><span>%s</span></div>' % ('closed', 'Réouvre lundi à 9h30')
@pytest.mark.freeze_time("2021-01-21 15:37:00")
@pytest.mark.freeze_time('2021-01-21 15:37:00')
def test_mairie_saint_genis_lavak():
"""#50337"""
geojson = json.load(open(os.path.join(BASE_DIR, 'tests/data/mairie-saint-genis-lavak.json')))
@ -313,8 +313,8 @@ def test_mairie_saint_genis_lavak():
[
('2017-12-01', '2018-02-01', 'closed', 'Fermé'),
('2018-01-04', '2018-01-04', 'closed', 'Réouvre demain à 8h30'),
('2018-01-04', '2018-01-09', 'closed', "Réouvre mercredi à 8h30"),
('2018-01-04', '2018-01-11', 'closed', "Fermé"),
('2018-01-04', '2018-01-09', 'closed', 'Réouvre mercredi à 8h30'),
('2018-01-04', '2018-01-11', 'closed', 'Fermé'),
('2018-01-05', '2018-01-11', 'open', "Ouvert jusqu'à 17h30"),
],
)

View File

@ -8,7 +8,7 @@ from combo_plugin_gnm.templatetags.gnm import EN_FULL_WEEKDAYS_LIST, FR_WEEKDAYS
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
GEOJSON = json.load(open(os.path.join(BASE_DIR, 'tests/data/mairie-geojson.json')))['features']
TZOFFSETS = {"Europe/Paris": 3600}
TZOFFSETS = {'Europe/Paris': 3600}
def test_mairie_hours_parsing():
@ -60,7 +60,7 @@ def test_mairie_hours_special_data():
]
@pytest.mark.freeze_time("2018-03-05 15:59:00")
@pytest.mark.freeze_time('2018-03-05 15:59:00')
def test_mairie_openinghoursspecification_period_valid():
"""Test valid periods of openinghoursspecification timetables"""
for x in GEOJSON:
@ -76,7 +76,7 @@ def test_mairie_openinghoursspecification_period_valid():
return
@pytest.mark.freeze_time("2020-03-05 15:59:00")
@pytest.mark.freeze_time('2020-03-05 15:59:00')
def test_mairie_openinghoursspecification_period_all_closed():
# display known format but no opening hours as all closed
for x in GEOJSON:
@ -109,7 +109,7 @@ def test_mairie_sathonay_timetable():
def test_mairie_saint_priest():
"S1406"
'S1406'
test_time_table = [
get_mairie_opening_hours(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1406'
][0]
@ -150,7 +150,7 @@ def test_mairie_format_openinghours():
]
@pytest.mark.freeze_time("2018-03-09 00:30:00")
@pytest.mark.freeze_time('2018-03-09 00:30:00')
def test_mairie_format_openinghoursspecification():
"""openinghoursspecification the default format"""
geojson = r"""
@ -212,7 +212,7 @@ def test_mairie_format_openinghoursspecification():
]
@pytest.mark.freeze_time("2018-03-09 00:30:00")
@pytest.mark.freeze_time('2018-03-09 00:30:00')
def test_mairie_having_both_formats():
"""openinghoursspecification take preference over openinghours"""
geojson = r"""
@ -235,7 +235,7 @@ def test_mairie_having_both_formats():
assert hours[0] == ('lundi', {'am': '09h30-12h30', 'pm': None})
@pytest.mark.freeze_time("2021-01-21 15:37:00")
@pytest.mark.freeze_time('2021-01-21 15:37:00')
def test_mairie_saint_genis_lavak():
"""#50337"""
geojson = json.load(open(os.path.join(BASE_DIR, 'tests/data/mairie-saint-genis-lavak.json')))
@ -250,7 +250,7 @@ def test_mairie_saint_genis_lavak():
]
@pytest.mark.freeze_time("2018-01-01 14:59:00")
@pytest.mark.freeze_time('2018-01-01 14:59:00')
def test_mairie_holiday_day():
# Ecully, using datetimes
test_time_table = [