tests: add tests on night hours (#48919)
This commit is contained in:
parent
1e849e1cfb
commit
23f6a7f14d
|
@ -165,3 +165,72 @@ def test_mairie_holiday():
|
|||
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1365'][0]
|
||||
klass, label = 'closed', u"Réouvre demain à 8h30"
|
||||
assert test_html == mark_safe(u'<div class="badge %s"><span>%s</span></div>' % (klass, label))
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2018-03-05 00:30:00")
|
||||
@pytest.mark.parametrize('day, hours, badge, text', [
|
||||
('mercredi_pm', '14h30-17h45', 'closed', 'Réouvre mercredi à 14h30'),
|
||||
('mardi_pm', '14h30-17h45', 'closed', 'Réouvre demain à 14h30'),
|
||||
('lundi_pm', '14h30-17h45', 'closed', 'Réouvre à 14h30'),
|
||||
('lundi_am', '08h30-11h45', 'closed', 'Ouvre à 8h30'),
|
||||
('lundi_am', '00h00-00h45', 'soon-to-be-closed', "Ouvert jusqu'à 0h45"),
|
||||
('dimanche_pm', '20h30-00h45', 'closed', 'Réouvre dimanche à 20h30'), # wrong
|
||||
])
|
||||
def test_mdr_format(day, hours, badge, text):
|
||||
geojson = """
|
||||
{
|
||||
"properties": {
|
||||
"%s" : "%s"
|
||||
}
|
||||
}
|
||||
""" % (day, hours)
|
||||
html = as_opening_hours_badge(json.loads(geojson))
|
||||
assert html == '<div class="badge %s"><span>%s</span></div>' % (badge, text)
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2018-03-05 00:30:00")
|
||||
@pytest.mark.parametrize('openinghour, badge, text', [
|
||||
('We 14:30-17:45', 'closed', 'Réouvre mercredi à 14h30'),
|
||||
('Tu 14:30-17:45', 'closed', 'Réouvre demain à 14h30'),
|
||||
('Mo 14:30-17:45', 'closed', 'Réouvre à 14h30'),
|
||||
('Mo 08:30-11:45', 'closed', 'Ouvre à 8h30'),
|
||||
('Mo 00:00-00:45', 'soon-to-be-closed', "Ouvert jusqu'à 0h45"),
|
||||
('Su 20:30-00:45', 'closed', 'Réouvre dimanche à 20h30'), # wrong
|
||||
])
|
||||
def test_mairie_format_openinghours(openinghour, badge, text):
|
||||
geojson = """
|
||||
{
|
||||
"properties": {
|
||||
"openinghours": ["%s"]
|
||||
}
|
||||
}
|
||||
""" % openinghour
|
||||
html = as_opening_hours_badge(json.loads(geojson))
|
||||
assert html == '<div class="badge %s"><span>%s</span></div>' % (badge, text)
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2018-03-05 00:30:00")
|
||||
@pytest.mark.parametrize('day, opens, closes, badge, text', [
|
||||
('Wednesday', '14:30', '17:45', 'closed', 'Réouvre mercredi à 14h30'),
|
||||
('Tuesday', '14:30', '17:45', 'closed', 'Réouvre demain à 14h30'),
|
||||
('Monday', '14:30', '17:45', 'closed', 'Réouvre à 14h30'),
|
||||
('Monday', '08:30', '11:45', 'closed', 'Ouvre à 8h30'),
|
||||
('Monday', '00:00', '00:45', 'closed', 'Fermé'), # wrong
|
||||
('Sunday', '20:30', '00:45', 'closed', 'Réouvre dimanche à 20h30'), # wrong
|
||||
])
|
||||
def test_mairie_format_openinghoursspecification(day, opens, closes, badge, text):
|
||||
geojson = """
|
||||
{
|
||||
"properties": {
|
||||
"openinghoursspecification": [{
|
||||
"opens": "%s",
|
||||
"closes": "%s",
|
||||
"dayOfWeek": "http:\/\/schema.org\/%s",
|
||||
"validFrom": "2018-01-01T00:00:00+01:00",
|
||||
"validThrough": "2018-06-30T23:59:59+01:00"
|
||||
}]
|
||||
}
|
||||
}
|
||||
""" % (opens, closes, day)
|
||||
html = as_opening_hours_badge(json.loads(geojson))
|
||||
assert html == '<div class="badge %s"><span>%s</span></div>' % (badge, text)
|
||||
|
|
|
@ -64,7 +64,78 @@ def test_mairie_sathonay_timetable():
|
|||
test_time_table = [get_mairie_opening_hours(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1415'][0]
|
||||
assert test_time_table == [('lundi', {'am': u'08h30-12h00', 'pm': u'14h00-17h00'}), ('mardi', {'am': u'08h30-12h00', 'pm': u'13h30-17h00'}), ('mercredi', {'am': u'08h30-12h00', 'pm': u'14h00-17h00'}), ('jeudi', {'am': u'08h30-12h00', 'pm': u'14h00-17h00'}), ('vendredi', {'am': u'08h30-12h00', 'pm': u'14h00-17h00'}), ('samedi', {'am': u'08h30-12h00', 'pm': None})]
|
||||
|
||||
|
||||
def test_mairie_saint_priest():
|
||||
"S1406"
|
||||
test_time_table = [get_mairie_opening_hours(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1406'][0]
|
||||
assert test_time_table == [('lundi', {'am': u'08h15-12h15', 'pm': u'13h30-17h30'}), ('mardi', {'am': u'08h15-12h15', 'pm': u'13h30-17h30'}), ('mercredi', {'am': u'08h15-12h15', 'pm': u'13h30-17h30'}), ('jeudi', {'am': u'08h15-11h15', 'pm': u'13h30-17h30'}), ('vendredi', {'am': u'08h15-12h15', 'pm': u'13h30-17h30'}), ('samedi', {'am': u'09h00-11h30', 'pm': None})]
|
||||
|
||||
|
||||
def test_mairie_format_openinghours():
|
||||
geojson = """
|
||||
{
|
||||
"properties": {
|
||||
"openinghours": [
|
||||
"Mo 08:30-11:30",
|
||||
"Tu 14:00-17:00",
|
||||
"We 10:30-18:30",
|
||||
"Th 22:30-00:30",
|
||||
"Fr 07:30-07:00"
|
||||
]}}
|
||||
"""
|
||||
hours = get_mairie_opening_hours(json.loads(geojson))
|
||||
assert hours == [
|
||||
('lundi', {'am': '08h30-11h30', 'pm': None}),
|
||||
('mardi', {'am': None, 'pm': '14h00-17h00'}),
|
||||
('mercredi', {'am': '10h30-18h30', 'pm': ''}),
|
||||
('jeudi', {'am': '22h30-00h30', 'pm': None}), # wrong
|
||||
('vendredi', {'am': '07h30-07h00', 'pm': None}), # wrong
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2018-03-09 00:30:00")
|
||||
def test_mairie_format_openinghoursspecification():
|
||||
""" some mairie only have openinghoursspecification """
|
||||
geojson = """
|
||||
{
|
||||
"properties": {
|
||||
"openinghoursspecification": [{
|
||||
"opens": "08:30",
|
||||
"closes": "11:30",
|
||||
"dayOfWeek": "http:\/\/schema.org\/Monday",
|
||||
"validFrom": "2018-01-01T00:00:00+01:00",
|
||||
"validThrough": "2018-06-30T23:59:59+02:00"
|
||||
}, {
|
||||
"opens": "14:00",
|
||||
"closes": "17:00",
|
||||
"dayOfWeek": "http:\/\/schema.org\/Tuesday",
|
||||
"validFrom": "2018-01-01T00:00:00+01:00",
|
||||
"validThrough": "2018-06-30T23:59:59+02:00"
|
||||
}, {
|
||||
"opens": "10:30",
|
||||
"closes": "18:30",
|
||||
"dayOfWeek": "http:\/\/schema.org\/Wednesday",
|
||||
"validFrom": "2018-01-01T00:00:00+01:00",
|
||||
"validThrough": "2018-06-30T23:59:59+02:00"
|
||||
}, {
|
||||
"opens": "22:30",
|
||||
"closes": "00:30",
|
||||
"dayOfWeek": "http:\/\/schema.org\/Thursday",
|
||||
"validFrom": "2018-01-01T00:00:00+01:00",
|
||||
"validThrough": "2018-06-30T23:59:59+02:00"
|
||||
}, {
|
||||
"opens": "07:30",
|
||||
"closes": "07:00",
|
||||
"dayOfWeek": "http:\/\/schema.org\/Friday",
|
||||
"validFrom": "2018-01-01T00:00:00+01:00",
|
||||
"validThrough": "2018-06-30T23:59:59+02:00"
|
||||
}]}}
|
||||
"""
|
||||
hours = get_mairie_opening_hours(json.loads(geojson))
|
||||
assert hours == [
|
||||
('lundi', {'am': '08h30-11h30', 'pm': None}),
|
||||
('mardi', {'am': None, 'pm': '14h00-17h00'}),
|
||||
('mercredi', {'am': '10h30-18h30', 'pm': ''}),
|
||||
('jeudi', {'am': '22h30-00h30', 'pm': None}), # wrong
|
||||
('vendredi', {'am': '07h30-07h00', 'pm': None}), # wrong
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue