diff --git a/combo_plugin_gnm/management/commands/gnm_clean_autotiles.py b/combo_plugin_gnm/management/commands/gnm_clean_autotiles.py
index 3367485..4455a96 100644
--- a/combo_plugin_gnm/management/commands/gnm_clean_autotiles.py
+++ b/combo_plugin_gnm/management/commands/gnm_clean_autotiles.py
@@ -14,11 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+from combo.data.models import ConfigJsonCell
from django.core.management.base import BaseCommand
from django.utils.timezone import now, timedelta
-from combo.data.models import ConfigJsonCell
-
class Command(BaseCommand):
def handle(self, *args, **options):
diff --git a/combo_plugin_gnm/management/commands/gnm_create_places.py b/combo_plugin_gnm/management/commands/gnm_create_places.py
index 99c023a..917cdcc 100644
--- a/combo_plugin_gnm/management/commands/gnm_create_places.py
+++ b/combo_plugin_gnm/management/commands/gnm_create_places.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# combo-plugin-gnm - Combo GNM plugin
# Copyright (C) 2017 Entr'ouvert
#
@@ -16,13 +15,12 @@
# along with this program. If not, see .
+from combo.apps.maps.models import MapLayer
+from combo.data.models import ConfigJsonCell, Page
from django.conf import settings
from django.core.management.base import BaseCommand
from django.template import Context, Template
-from combo.apps.maps.models import MapLayer
-from combo.data.models import Page, ConfigJsonCell
-
class Command(BaseCommand):
def handle(self, *args, **options):
@@ -51,9 +49,9 @@ class Command(BaseCommand):
self.stderr.write('error in layer %s: %r\n' % (layer, resp['features']))
continue
for feature in resp['features']:
- cell_parameters = dict(
- [(x, feature['properties'][x]) for x in feature['properties'] if x in cell_form_keys]
- )
+ cell_parameters = {
+ x: feature['properties'][x] for x in feature['properties'] if x in cell_form_keys
+ }
try:
cell = ConfigJsonCell.objects.get(
key=layer.slug, parameters=cell_parameters, page__template_name='place'
diff --git a/combo_plugin_gnm/management/commands/gnm_kill_zombie_tiles.py b/combo_plugin_gnm/management/commands/gnm_kill_zombie_tiles.py
index f21a511..30940fd 100644
--- a/combo_plugin_gnm/management/commands/gnm_kill_zombie_tiles.py
+++ b/combo_plugin_gnm/management/commands/gnm_kill_zombie_tiles.py
@@ -14,11 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+from combo.apps.dashboard.models import Tile
from django.core.management.base import BaseCommand
from django.utils.timezone import now, timedelta
-from combo.apps.dashboard.models import Tile
-
class Command(BaseCommand):
def handle(self, *args, **options):
diff --git a/combo_plugin_gnm/management/commands/gnm_reporting.py b/combo_plugin_gnm/management/commands/gnm_reporting.py
index 18bbf4c..a540343 100644
--- a/combo_plugin_gnm/management/commands/gnm_reporting.py
+++ b/combo_plugin_gnm/management/commands/gnm_reporting.py
@@ -15,20 +15,19 @@
# along with this program. If not, see .
import html
-from io import BytesIO
import os
import re
import xml.etree.ElementTree as ET
import zipfile
+from io import BytesIO
+from combo.data.models import TextCell
+from combo.utils import requests
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.files.storage import default_storage
from django.core.management.base import BaseCommand, CommandError
-from combo.data.models import TextCell
-from combo.utils import requests
-
class Command(BaseCommand):
def handle(self, *args, **options):
diff --git a/combo_plugin_gnm/management/commands/gnm_update_settings.py b/combo_plugin_gnm/management/commands/gnm_update_settings.py
index a0cc629..3db916d 100644
--- a/combo_plugin_gnm/management/commands/gnm_update_settings.py
+++ b/combo_plugin_gnm/management/commands/gnm_update_settings.py
@@ -17,8 +17,8 @@
import json
import os
-from django.core.management.base import BaseCommand
from django.conf import settings
+from django.core.management.base import BaseCommand
from django.db import connection
@@ -237,7 +237,7 @@ class Command(BaseCommand):
"cache_duration": 60,
"force_async": False,
"name": "M'y rendre",
- "loading-message": u'Calcul…',
+ "loading-message": 'Calcul…',
"varnames": ["lat1", "lng1", "lat2", "lng2", "date", "to"],
"form": [
{
@@ -572,14 +572,14 @@ class Command(BaseCommand):
}
PRODUCER_LABELS = {
- 'atmo': u'ATMO Auvergne Rhône-Alpes',
- 'rnsa': u'RNSA',
- 'onlymoov': u'ONLY MOOV',
- 'tcl': u'TCL',
- 'toodego': u'Toodego',
+ 'atmo': 'ATMO Auvergne Rhône-Alpes',
+ 'rnsa': 'RNSA',
+ 'onlymoov': 'ONLY MOOV',
+ 'tcl': 'TCL',
+ 'toodego': 'Toodego',
'velov': "Velo'v",
'vivrou': "Vivro",
- 'grandlyon': u'Grand Lyon',
+ 'grandlyon': 'Grand Lyon',
'bluely': "Bluely",
'citiz-lpa': "Citiz LPA",
'sncf': "SNCF",
@@ -659,12 +659,12 @@ class Command(BaseCommand):
COMBO_ASSET_SLOTS = self.settings_json.get('COMBO_ASSET_SLOTS.update') or {}
for producer, producer_label in PRODUCER_LABELS.items():
- COMBO_ASSET_SLOTS['logo:%s' % producer] = {'label': u'Logo %s' % producer_label}
+ COMBO_ASSET_SLOTS['logo:%s' % producer] = {'label': 'Logo %s' % producer_label}
# add lyon as used by cart@ds
for arrondissement in ['1er'] + ['%seme' % x for x in range(2, 10)]:
COMBO_ASSET_SLOTS['logo:lyon-%s' % arrondissement] = {
- 'label': u'Logo Lyon %s' % arrondissement,
+ 'label': 'Logo Lyon %s' % arrondissement,
}
tiles = [
@@ -688,7 +688,7 @@ class Command(BaseCommand):
('parc-velo', "Parc vélo"),
('piscine', "Piscine"),
('pollen', "Pollen"),
- ('silo-a-verre', u'Silo à verre'),
+ ('silo-a-verre', 'Silo à verre'),
('taxi', "Taxi"),
('tcl', "TCL"),
('velov', "Velo'v"),
@@ -704,10 +704,10 @@ class Command(BaseCommand):
]
for tile, tile_label in tiles:
- COMBO_ASSET_SLOTS['picture:%s' % tile] = {'label': u'Photographie %s' % tile_label}
+ COMBO_ASSET_SLOTS['picture:%s' % tile] = {'label': 'Photographie %s' % tile_label}
if tile not in ('taxi', 'tcl', 'velov'):
COMBO_ASSET_SLOTS['picture:banner:%s' % tile] = {
- 'label': u'Photographie/bannière %s' % tile_label
+ 'label': 'Photographie/bannière %s' % tile_label
}
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
diff --git a/combo_plugin_gnm/templatetags/gnm.py b/combo_plugin_gnm/templatetags/gnm.py
index fd9f641..bab3e4f 100644
--- a/combo_plugin_gnm/templatetags/gnm.py
+++ b/combo_plugin_gnm/templatetags/gnm.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# combo-plugin-gnm - Combo GNM plugin
# Copyright (C) 2017 Entr'ouvert
#
@@ -15,33 +14,31 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
-from collections import OrderedDict
import datetime
import json
import operator
import random
import re
import urllib.parse
-
-from pyproj import Geod
-from requests import RequestException
-
-from django import template
-from django.conf import settings
-from django.core.serializers.json import DjangoJSONEncoder
-from django.core import signing
-from django.utils.dateparse import parse_date, parse_datetime
-from django.utils.http import quote
-from django.utils.html import format_html
-from django.utils.text import slugify
-from django.utils.timezone import now, is_naive, make_aware
-from django.utils.safestring import mark_safe
+from collections import OrderedDict
from combo.apps.dashboard.models import DashboardCell, Tile
from combo.apps.maps.models import Map, MapLayer
-from combo.data.models import Page, CellBase, ConfigJsonCell
+from combo.data.models import CellBase, ConfigJsonCell, Page
from combo.public.views import render_cell
from combo.utils import requests
+from django import template
+from django.conf import settings
+from django.core import signing
+from django.core.serializers.json import DjangoJSONEncoder
+from django.utils.dateparse import parse_date, parse_datetime
+from django.utils.html import format_html
+from django.utils.http import quote
+from django.utils.safestring import mark_safe
+from django.utils.text import slugify
+from django.utils.timezone import is_naive, make_aware, now
+from pyproj import Geod
+from requests import RequestException
register = template.Library()
@@ -62,7 +59,7 @@ EN_FULL_WEEKDAYS_LIST = list(EN_ABBREV_WEEKDAYS.values())
FR_ABBREV_WEEKDAYS_LIST = OrderedDict(zip(EN_ABBREV_WEEKDAYS_LIST, FR_WEEKDAYS))
-class TimeSlot(object):
+class TimeSlot:
def __init__(self, start, end):
if is_naive(start):
start = make_aware(start)
@@ -425,35 +422,35 @@ def as_opening_hours_badge(data):
slots = [x for x in slots if x]
if not slots:
klass = 'closed'
- label = u'Fermé'
+ label = 'Fermé'
elif base_datetime < slots[0].start:
klass = 'closed'
- verb = u'Réouvre'
+ verb = 'Réouvre'
if slots[0].start.weekday() == today.weekday():
day_label = ''
if slots[0].start.hour < 12:
verb = 'Ouvre'
elif slots[0].start.weekday() == (today.weekday() + 1) % 7:
- day_label = u'demain'
+ 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':
- label = u'%s %s 24h/24' % (verb, day_label)
+ label = '%s %s 24h/24' % (verb, day_label)
else:
time = format_time(slots[0].start.hour, slots[0].start.minute)
- label = u'%s %s à %s' % (verb, day_label, time)
+ label = '%s %s à %s' % (verb, day_label, time)
elif base_datetime < slots[0].end:
if (slots[0].end - base_datetime).seconds < 3600:
klass = 'soon-to-be-closed'
else:
klass = 'open'
if slots[0].start.strftime("%H:%M") == slots[0].end.strftime("%H:%M") == '00:00':
- label = u"Ouvert 24h/24"
+ label = "Ouvert 24h/24"
else:
time = format_time(slots[0].end.hour, slots[0].end.minute)
- label = u"Ouvert jusqu'à %s" % time
+ label = "Ouvert jusqu'à %s" % time
- return mark_safe(u'
%s
' % (klass, label))
+ return mark_safe('%s
' % (klass, label))
@register.filter
@@ -688,11 +685,11 @@ def get_suggestions(request, user_data, places_data):
address = None
if places_data and places_data.get('data'):
place_data = places_data['data'][0]
- address = u'%(adresse)s, %(ville)s, France' % place_data['content']
+ address = '%(adresse)s, %(ville)s, France' % place_data['content']
elif user_data.get('address_street'):
if not user_data.get('address_number'):
user_data['address_number'] = ''
- address = u'%(address_number)s %(address_street)s, %(address_city)s, France' % user_data
+ address = '%(address_number)s %(address_street)s, %(address_city)s, France' % user_data
coords = None
if address:
diff --git a/debian/50gnm.py b/debian/50gnm.py
index da4c4e9..8f89261 100644
--- a/debian/50gnm.py
+++ b/debian/50gnm.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
if not 'combo_plugin_gnm' in INSTALLED_APPS:
INSTALLED_APPS += ('combo_plugin_gnm',)
TENANT_APPS += ('combo_plugin_gnm',)
diff --git a/debian/control b/debian/control
index 102c7ee..7e9d08b 100644
--- a/debian/control
+++ b/debian/control
@@ -2,12 +2,17 @@ Source: combo-plugin-gnm
Maintainer: Frederic Peters
Section: python
Priority: optional
-Build-Depends: debhelper-compat (= 12), dh-python, python3-all, python3-setuptools, python3-django, python3-dateutil
+Build-Depends: debhelper-compat (= 12),
+ dh-python,
+ python3-all,
+ python3-dateutil,
+ python3-django,
+ python3-setuptools,
Standards-Version: 3.9.1
Package: python3-combo-plugin-gnm
Architecture: all
-Depends: ${misc:Depends}, ${python:Depends}, python3-combo
+Depends: python3-combo, ${misc:Depends}, ${python:Depends}
Description: Combo GNM Plugin (Python 3)
Extension module for the Combo content management system,
with various developments that are at the moment at least
diff --git a/setup.py b/setup.py
index 9c02d5a..9496976 100644
--- a/setup.py
+++ b/setup.py
@@ -1,17 +1,16 @@
#! /usr/bin/env python
-# -*- coding: utf-8 -*-
import glob
import os
import re
import subprocess
import sys
-
-from setuptools.command.install_lib import install_lib as _install_lib
+from distutils.cmd import Command
from distutils.command.build import build as _build
from distutils.command.sdist import sdist
-from distutils.cmd import Command
-from setuptools import setup, find_packages
+
+from setuptools import find_packages, setup
+from setuptools.command.install_lib import install_lib as _install_lib
class eo_sdist(sdist):
@@ -28,7 +27,7 @@ class eo_sdist(sdist):
def get_version():
if os.path.exists('VERSION'):
- with open('VERSION', 'r') as v:
+ with open('VERSION') as v:
return v.read()
if os.path.exists('.git'):
p = subprocess.Popen(
diff --git a/tests/test_as_opening_hours.py b/tests/test_as_opening_hours.py
index 404ba6c..6196c96 100644
--- a/tests/test_as_opening_hours.py
+++ b/tests/test_as_opening_hours.py
@@ -1,12 +1,10 @@
-# -*- coding: utf-8 -*-
-import pytest
import json
import os
+import pytest
from django.utils.safestring import mark_safe
-from combo_plugin_gnm.templatetags.gnm import as_opening_hours_badge, EN_FULL_WEEKDAYS_LIST, FR_WEEKDAYS
-
+from combo_plugin_gnm.templatetags.gnm import EN_FULL_WEEKDAYS_LIST, FR_WEEKDAYS, as_opening_hours_badge
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
GEOJSON = json.load(open(os.path.join(BASE_DIR, 'tests/data/mairie-geojson.json')))['features']
@@ -45,48 +43,48 @@ def test_empty_data():
def test_mairie_bron_monday():
"""S1326"""
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['identifiant'] == 'S1326'][0]
- klass, label = 'open', u"Ouvert jusqu'à 17h15"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'open', "Ouvert jusqu'à 17h15"
+ assert test_html == mark_safe('%s
' % (klass, label))
@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', u"Réouvre demain à 8h00"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'closed', "Réouvre demain à 8h00"
+ assert test_html == mark_safe('%s
' % (klass, label))
@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]
- klass, label = 'open', u"Ouvert jusqu'à 17h00"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'open', "Ouvert jusqu'à 17h00"
+ assert test_html == mark_safe('%s
' % (klass, label))
@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', u"Réouvre lundi à 8h15"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'closed', "Réouvre lundi à 8h15"
+ assert test_html == mark_safe('%s
' % (klass, label))
@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]
- klass, label = 'soon-to-be-closed', u"Ouvert jusqu'à 12h15"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'soon-to-be-closed', "Ouvert jusqu'à 12h15"
+ assert test_html == mark_safe('%s
' % (klass, label))
@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', u"Réouvre lundi à 8h00"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'closed', "Réouvre lundi à 8h00"
+ assert test_html == mark_safe('%s
' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 09:59:13")
@@ -95,8 +93,8 @@ def test_jonage_open():
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['nom'] == 'Mairie de Jonage'][
0
]
- klass, label = 'open', u"Ouvert jusqu'à 12h30"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'open', "Ouvert jusqu'à 12h30"
+ assert test_html == mark_safe('%s
' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 11:32:00")
@@ -105,8 +103,8 @@ def test_jonage_soon_to_be_closed():
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['nom'] == 'Mairie de Jonage'][
0
]
- klass, label = 'soon-to-be-closed', u"Ouvert jusqu'à 12h30"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'soon-to-be-closed', "Ouvert jusqu'à 12h30"
+ assert test_html == mark_safe('%s
' % (klass, label))
@pytest.mark.freeze_time("2018-03-10 17:30:00")
@@ -115,19 +113,19 @@ def test_jonage_closed():
test_html = [as_opening_hours_badge(x) for x in GEOJSON if x['properties']['nom'] == 'Mairie de Jonage'][
0
]
- klass, label = 'closed', u"Réouvre lundi à 8h30"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'closed', "Réouvre lundi à 8h30"
+ assert test_html == mark_safe('%s
' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 15:55:00")
def test_data_input_compatibility():
"""as_opening_hours with a fixed datetime"""
klass = 'open'
- label = u"Ouvert jusqu'à 17h00"
+ label = "Ouvert jusqu'à 17h00"
test_html = as_opening_hours_badge(GEOJSON[1]['properties'])
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ assert test_html == mark_safe('%s
' % (klass, label))
test_html = as_opening_hours_badge(GEOJSON[1])
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ assert test_html == mark_safe('%s
' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 00:00:00")
@@ -146,35 +144,35 @@ def test_all_mdr_data_parsed_correct():
@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', u"Ouvert jusqu'à 16h45"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'open', "Ouvert jusqu'à 16h45"
+ assert test_html == mark_safe('%s
' % (klass, label))
@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', u"Ouvert jusqu'à 16h45"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'soon-to-be-closed', "Ouvert jusqu'à 16h45"
+ assert test_html == mark_safe('%s
' % (klass, label))
@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', u"Réouvre lundi à 8h30"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'closed', "Réouvre lundi à 8h30"
+ assert test_html == mark_safe('%s
' % (klass, label))
@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', u"Réouvre demain à 8h30"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'closed', "Réouvre demain à 8h30"
+ assert test_html == mark_safe('%s
' % (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', u"Réouvre demain à 8h30"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'closed', "Réouvre demain à 8h30"
+ assert test_html == mark_safe('%s
' % (klass, label))
@pytest.mark.freeze_time("2018-03-05 00:30:00")
@@ -256,7 +254,7 @@ def test_mairie_format_openinghours(openinghour, badge, text):
],
)
def test_mairie_format_openinghoursspecification(day, opens, closes, badge, text):
- geojson = """
+ geojson = r"""
{
"properties": {
"openinghoursspecification": [{
@@ -280,7 +278,7 @@ def test_mairie_format_openinghoursspecification(day, opens, closes, badge, text
@pytest.mark.freeze_time("2018-03-09 00:30:00")
def test_mairie_having_both_formats():
"""openinghoursspecification take preference over openinghours"""
- geojson = """
+ geojson = r"""
{
"properties": {
"openinghours": [
@@ -305,8 +303,8 @@ def test_mairie_saint_genis_lavak():
"""#50337"""
geojson = json.load(open(os.path.join(BASE_DIR, 'tests/data/mairie-saint-genis-lavak.json')))
test_html = as_opening_hours_badge(geojson['features'][0])
- klass, label = 'open', u"Ouvert jusqu'à 17h30"
- assert test_html == mark_safe(u'%s
' % (klass, label))
+ klass, label = 'open', "Ouvert jusqu'à 17h30"
+ assert test_html == mark_safe('%s
' % (klass, label))
@pytest.mark.freeze_time('2018-01-04 14:59:00')
diff --git a/tests/test_get_mairie_opening_hours.py b/tests/test_get_mairie_opening_hours.py
index 01810ef..ea6ffc7 100644
--- a/tests/test_get_mairie_opening_hours.py
+++ b/tests/test_get_mairie_opening_hours.py
@@ -1,11 +1,9 @@
-# -*- coding: utf-8 -*-
-
-import pytest
import json
import os
-from combo_plugin_gnm.templatetags.gnm import get_mairie_opening_hours, EN_FULL_WEEKDAYS_LIST, FR_WEEKDAYS
+import pytest
+from combo_plugin_gnm.templatetags.gnm import EN_FULL_WEEKDAYS_LIST, FR_WEEKDAYS, get_mairie_opening_hours
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
GEOJSON = json.load(open(os.path.join(BASE_DIR, 'tests/data/mairie-geojson.json')))['features']
@@ -30,35 +28,35 @@ def test_mairie_hours_special_data():
if x['properties']['identifiant'] == 'S1376':
# La Mulatière : openinghoursspecification set but without opens/closes
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}),
+ ('lundi', {'am': '08h30-12h00', 'pm': None}),
+ ('mardi', {'am': '08h30-12h30', 'pm': '13h30-17h00'}),
+ ('mercredi', {'am': '08h30-12h30', 'pm': '13h30-17h00'}),
+ ('jeudi', {'am': '08h30-12h30', 'pm': '13h30-17h00'}),
+ ('vendredi', {'am': '08h30-12h30', 'pm': '13h30-17h00'}),
+ ('samedi', {'am': '09h00-11h45', 'pm': None}),
]
if x['properties']['identifiant'] == 'S1437':
x['properties']['openinghoursspecification'] = [] # force using openinghours
# special openinghours format with days intervals, comma-separated list and one day definition with a saturday
assert get_mairie_opening_hours(x) == [
- ('lundi', {'am': u'08h45-12h30', 'pm': u'14h00-16h45'}),
- ('mardi', {'am': u'08h45-16h45', 'pm': ''}),
- ('mercredi', {'am': u'08h45-16h45', 'pm': ''}),
- ('jeudi', {'am': u'08h45-18h00', 'pm': ''}),
- ('vendredi', {'am': u'08h45-16h45', 'pm': ''}),
- ('samedi', {'am': u'09h00-12h00', 'pm': None}),
+ ('lundi', {'am': '08h45-12h30', 'pm': '14h00-16h45'}),
+ ('mardi', {'am': '08h45-16h45', 'pm': ''}),
+ ('mercredi', {'am': '08h45-16h45', 'pm': ''}),
+ ('jeudi', {'am': '08h45-18h00', 'pm': ''}),
+ ('vendredi', {'am': '08h45-16h45', 'pm': ''}),
+ ('samedi', {'am': '09h00-12h00', 'pm': None}),
]
if x['properties']['identifiant'] == 'S5564':
x['properties']['openinghoursspecification'] = [] # force using openinghours
# 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'}),
+ ('lundi', {'am': '08h30-12h15', 'pm': '13h15-17h00'}),
+ ('mardi', {'am': '08h30-12h15', 'pm': '13h15-17h00'}),
+ ('mercredi', {'am': '08h30-12h15', 'pm': '13h15-17h00'}),
+ ('jeudi', {'am': '08h30-12h15', 'pm': '13h15-17h00'}),
+ ('vendredi', {'am': '08h30-12h15', 'pm': '13h15-17h00'}),
]
@@ -101,12 +99,12 @@ def test_mairie_sathonay_timetable():
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}),
+ ('lundi', {'am': '08h30-12h00', 'pm': '14h00-17h00'}),
+ ('mardi', {'am': '08h30-12h00', 'pm': '13h30-17h00'}),
+ ('mercredi', {'am': '08h30-12h00', 'pm': '14h00-17h00'}),
+ ('jeudi', {'am': '08h30-12h00', 'pm': '14h00-17h00'}),
+ ('vendredi', {'am': '08h30-12h00', 'pm': '14h00-17h00'}),
+ ('samedi', {'am': '08h30-12h00', 'pm': None}),
]
@@ -116,12 +114,12 @@ def test_mairie_saint_priest():
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}),
+ ('lundi', {'am': '08h15-12h15', 'pm': '13h30-17h30'}),
+ ('mardi', {'am': '08h15-12h15', 'pm': '13h30-17h30'}),
+ ('mercredi', {'am': '08h15-12h15', 'pm': '13h30-17h30'}),
+ ('jeudi', {'am': '08h15-11h15', 'pm': '13h30-17h30'}),
+ ('vendredi', {'am': '08h15-12h15', 'pm': '13h30-17h30'}),
+ ('samedi', {'am': '09h00-11h30', 'pm': None}),
]
@@ -155,7 +153,7 @@ def test_mairie_format_openinghours():
@pytest.mark.freeze_time("2018-03-09 00:30:00")
def test_mairie_format_openinghoursspecification():
"""openinghoursspecification the default format"""
- geojson = """
+ geojson = r"""
{
"properties": {
"openinghoursspecification": [{
@@ -217,7 +215,7 @@ def test_mairie_format_openinghoursspecification():
@pytest.mark.freeze_time("2018-03-09 00:30:00")
def test_mairie_having_both_formats():
"""openinghoursspecification take preference over openinghours"""
- geojson = """
+ geojson = r"""
{
"properties": {
"openinghours": [