add tests for get_mairie_opening_hours validity period (#25697)

This commit is contained in:
Elias Showk 2018-08-17 10:10:48 +02:00
parent d67b19fa65
commit b4a823a570
1 changed files with 19 additions and 4 deletions

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import pytest
import json
import os
@ -30,10 +31,6 @@ def test_mairie_hours_nodata():
def test_mairie_hours_special_data():
"""test results for various data examples"""
for x in GEOJSON:
if x['properties']['nom'] == 'Mairie de Jonage':
# openinghoursspecification data format (only, no openinghours data)
assert get_mairie_opening_hours(x) == [('lundi', {'am': '08h30-12h30', 'pm': '14h00-17h00'}), ('mardi', {'am': '08h30-12h30', 'pm': '14h00-17h00'}), ('mercredi', {'am': '08h30-12h30', 'pm': '14h00-17h00'}), ('jeudi', {'am': '08h30-12h30', 'pm': '14h00-17h00'}), ('vendredi', {'am': '08h30-12h30', 'pm': '14h00-17h00'}), ('samedi', {'am': '09h00-12h00', 'pm': '14h00-17h00'})]
if x['properties']['identifiant'] == 'S1376':
# La Mulatière
assert get_mairie_opening_hours(x) == [('lundi', {'am': u'08h30-12h00', 'pm': None}), ('mardi', {'am': u'08h30-12h30', 'pm': u'13h30-17h00'}), ('mercredi', {'am': u'08h30-12h30', 'pm': u'13h30-17h00'}), ('jeudi', {'am': u'08h30-12h30', 'pm': u'13h30-17h00'}), ('vendredi', {'am': u'08h30-12h30', 'pm': u'13h30-17h00'}), ('samedi', {'am': u'09h00-11h45', 'pm': None})]
@ -45,3 +42,21 @@ def test_mairie_hours_special_data():
if x['properties']['identifiant'] == 'S5564':
# classic openinghours days interval for am and pm
assert get_mairie_opening_hours(x) == [('lundi', {'am': u'08h30-12h15', 'pm': u'13h15-17h00'}), ('mardi', {'am': u'08h30-12h15', 'pm': u'13h15-17h00'}), ('mercredi', {'am': u'08h30-12h15', 'pm': u'13h15-17h00'}), ('jeudi', {'am': u'08h30-12h15', 'pm': u'13h15-17h00'}), ('vendredi', {'am': u'08h30-12h15', 'pm': u'13h15-17h00'})]
@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:
if x['properties']['nom'] == 'Mairie de Jonage':
assert get_mairie_opening_hours(x) == [('lundi', {'am': '08h30-12h30', 'pm': '14h00-17h00'}), ('mardi', {'am': '08h30-12h30', 'pm': '14h00-17h00'}), ('mercredi', {'am': '08h30-12h30', 'pm': '14h00-17h00'}), ('jeudi', {'am': '08h30-12h30', 'pm': '14h00-17h00'}), ('vendredi', {'am': '08h30-12h30', 'pm': '14h00-17h00'}), ('samedi', {'am': '09h00-12h00', 'pm': '14h00-17h00'})]
return
@pytest.mark.freeze_time("2020-03-05 15:59:00")
def test_mairie_openinghoursspecification_period_invalid():
"""Test valid periods of openinghoursspecification timetables"""
for x in GEOJSON:
if x['properties']['nom'] == 'Mairie de Jonage':
assert get_mairie_opening_hours(x) == [('lundi', {'am': None, 'pm': None}), ('mardi', {'am': None, 'pm': None}), ('mercredi', {'am': None, 'pm': None}), ('jeudi', {'am': None, 'pm': None}), ('vendredi', {'am': None, 'pm': None})]
return