Commit bf317267 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

slugify ical URLs

parent 1cb638b8
Pipeline #19436 passed with stages
in 17 seconds
......@@ -10,6 +10,8 @@ import re
import uuid
import urllib.parse
from sgelt.utils import slugify
log = logging.getLogger(__name__)
rd = random.Random()
......@@ -83,7 +85,7 @@ def write_calendar_file(filename: str, conf,
"""
Write calendar content to an .ics file and return encoded url
"""
ical_filepath = 'cal' / Path(filename).with_suffix('.ics')
ical_filepath = 'cal' / Path(slugify(filename)).with_suffix('.ics')
ical_outpath = conf.output_path / ical_filepath
log.debug(f"Export ical file to {ical_outpath}")
# Create parent directory if not exists
......
......@@ -183,7 +183,7 @@ def test_write_calendar_file(tmpdir, miniwebsite):
def test_SeminarTopIndexPage(miniwebsite):
miniwebsite.build()
ical_filepath = Path('cal/séminaires.ics')
ical_filepath = Path('cal/seminaires.ics')
ical_outpath = miniwebsite.conf.output_path / ical_filepath
ical_content = ical_outpath.read_text()
assert ical_content.startswith("""\
......
......@@ -310,8 +310,9 @@ def test_SeminarPage(miniwebsite):
'expérience',
'url': 'séminaire/séminaire-beau-souffrance-réveiller-beauté-horizon-manquer.html#naître-fumée-expérience'
}]
assert page.ical_url == "https://fakelab.fk/cal/s%C3%A9minaire-beau-souffrance-r%C3%A9veiller-beaut%C3%A9-horizon-manquer.ics"
ical_filepath = 'cal' / Path(page._get_filename()).with_suffix('.ics')
assert page.ical_url == "https://fakelab.fk/cal/seminaire-beau-souffrance-reveiller-beaute-horizon-manquer.ics"
ical_filepath = ('cal' /
Path(utils.slugify(page._get_filename())).with_suffix('.ics'))
ical_outpath = page.conf.output_path / ical_filepath
# Read the 20 first lines of the ical file
with open(ical_outpath) as f:
......@@ -360,7 +361,7 @@ def test_SeminarTopIndexPage(miniwebsite):
'text': 'Séminaires et groupes de travail',
'title': 'Séminaires et groupes de travail',
'url': 'séminaires-actifs.html'}
assert page.ical_url == "https://fakelab.fk/cal/s%C3%A9minaires.ics"
assert page.ical_url == "https://fakelab.fk/cal/seminaires.ics"
# The rest of SeminarTopIndexPage calendar test is done in test_calendar.py
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment