summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <rsd@gnu.org>2020-07-09 22:41:52 -0400
committerrsiddharth <rsd@gnu.org>2020-07-09 22:41:52 -0400
commita32c34dab635a74f3a7e2bcd138c12090f5942e9 (patch)
tree48ddae3688969408ede0e96764461894a60d0bef
parent43472681058c163f31a027ebc19659675ae088ea (diff)
Format via black.
-rw-r--r--Makefile4
-rw-r--r--lps_gen.py284
-rw-r--r--lpschedule_generator/_version.py2
-rw-r--r--setup.py72
-rw-r--r--tests/test_lps_gen.py939
5 files changed, 601 insertions, 700 deletions
diff --git a/Makefile b/Makefile
index c43c4ac..fbb645a 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,10 @@ test:
.PHONY: test
+fmt:
+ black --include 'lps_gen.py|setup.py|tests/*.py|lpschedule_generator/*.py' .
+.PHONY: fmt
+
build-dist:
@python setup.py sdist bdist_wheel
diff --git a/lps_gen.py b/lps_gen.py
index f8b1ab6..de2c5c2 100644
--- a/lps_gen.py
+++ b/lps_gen.py
@@ -42,14 +42,14 @@ def read_file(filename):
:param str filename: Absolute pathname of the file.
"""
- content = ''
+ content = ""
try:
- with open(filename, 'r') as f:
+ with open(filename, "r") as f:
for line in f:
content = content + line
except IOError:
- print('Error: unable to open {}'.format(filename))
+ print("Error: unable to open {}".format(filename))
return content
@@ -65,11 +65,11 @@ def write_file(filename, filecontent):
"""
file_ = None
try:
- file_ = open(filename, 'w')
- file_.write(filecontent)
- file_.close()
+ file_ = open(filename, "w")
+ file_.write(filecontent)
+ file_.close()
except IOError:
- print('Error creating and writing content to {}'.format(filename))
+ print("Error creating and writing content to {}".format(filename))
exit(1)
@@ -89,19 +89,18 @@ def json_read(filename):
if not path.isfile(filename):
return False
- return json.loads(read_file(filename),
- object_pairs_hook=OrderedDict)
+ return json.loads(read_file(filename), object_pairs_hook=OrderedDict)
def template_read(name):
"""Return template as `str`.
"""
- p = 'lpschedule_generator'
- r = 'data/{}.jinja2'.format(name)
+ p = "lpschedule_generator"
+ r = "data/{}.jinja2".format(name)
t = None
try:
- t = pkgr.resource_string(p, r).decode('utf-8')
+ t = pkgr.resource_string(p, r).decode("utf-8")
except Exception as e:
print(e, file=sys.stderr)
@@ -117,15 +116,14 @@ class LPiCal(object):
self.lp_year = str(lp_year)
# Matches strings like '09:45 - 10:30: Lorem ipsum dolor sit.'
- self.timeslot_re = re.compile(r'(\d+:\d+).+?(\d+:\d+)'
- r'\s*[:-]?\s*(.+\b)?')
+ self.timeslot_re = re.compile(r"(\d+:\d+).+?(\d+:\d+)" r"\s*[:-]?\s*(.+\b)?")
# Matches strings like 'Saturday, March 19'
- self.month_day_re = re.compile(r'\w+,\s*([a-zA-Z]+)\s*(\d+)')
+ self.month_day_re = re.compile(r"\w+,\s*([a-zA-Z]+)\s*(\d+)")
self.cal = Calendar()
- self.cal.add('prodid', '-//lpschedule generator//mxm.dk//')
- self.cal.add('version', '2.0')
- self.cal.add('x-wr-calname', 'LibrePlanet {}'.format(self.lp_year))
+ self.cal.add("prodid", "-//lpschedule generator//mxm.dk//")
+ self.cal.add("version", "2.0")
+ self.cal.add("x-wr-calname", "LibrePlanet {}".format(self.lp_year))
# RFC 2445 requires DTSTAMP to be in UTC. DTSTAMP is used in
# VEVENT (Event object, see `add_event` method).
@@ -134,16 +132,13 @@ class LPiCal(object):
# used to generate uid for ical.
self.ucounter = 0
-
def gen_uid(self):
"""Returns an unique id.
Used for Event object.
"""
self.ucounter = self.ucounter + 1
- return '{}@LP{}@libreplanet.org'.format(str(self.ucounter),
- self.lp_year)
-
+ return "{}@LP{}@libreplanet.org".format(str(self.ucounter), self.lp_year)
def get_timeslot(self, s):
"""Get start and end time for a timeslot.
@@ -156,11 +151,10 @@ class LPiCal(object):
t_start = timeslot.group(1)
t_end = timeslot.group(2)
- name = timeslot.group(3) or ''
+ name = timeslot.group(3) or ""
return t_start, t_end, name
-
def get_month_day(self, s):
"""Get month and day.
"""
@@ -175,7 +169,6 @@ class LPiCal(object):
return month, day
-
def mk_datetime(self, month, day, time):
"""Returns datetime object (EST).
"""
@@ -185,78 +178,72 @@ class LPiCal(object):
# Hour %H (24-hr)
# Minute %M (zero padded)
# Second %S (zero padded)
- datetime_fmt = '%d %B %Y %H:%M:%S'
- eastern = timezone('US/Eastern')
+ datetime_fmt = "%d %B %Y %H:%M:%S"
+ eastern = timezone("US/Eastern")
- hour = time.split(':')[0]
- minute = time.split(':')[1]
- datetime_str = '{} {} {} {}:{}:{}'.format(day, month,
- self.lp_year,
- hour.zfill(2),
- minute.zfill(2),
- '00')
+ hour = time.split(":")[0]
+ minute = time.split(":")[1]
+ datetime_str = "{} {} {} {}:{}:{}".format(
+ day, month, self.lp_year, hour.zfill(2), minute.zfill(2), "00"
+ )
dt_object = datetime.strptime(datetime_str, datetime_fmt)
return vDatetime(eastern.localize(dt_object))
-
def mk_attendee(self, speaker):
"""Make Attendee to be added to an Event object.
See `add_event` method.
"""
# Get rid of HTML (<a> element, etc) in `speaker`
- speaker = BeautifulSoup(speaker, 'html.parser').get_text()
+ speaker = BeautifulSoup(speaker, "html.parser").get_text()
- attendee = vCalAddress('invalid:nomail')
- attendee.params['cn'] = vText(speaker)
- attendee.params['ROLE'] = vText('REQ-PARTICIPANT')
- attendee.params['CUTYPE'] = vText('INDIVIDUAL')
+ attendee = vCalAddress("invalid:nomail")
+ attendee.params["cn"] = vText(speaker)
+ attendee.params["ROLE"] = vText("REQ-PARTICIPANT")
+ attendee.params["CUTYPE"] = vText("INDIVIDUAL")
return attendee
-
- def add_event(self, month, day, t_start, t_end, t_name, session,
- session_info):
+ def add_event(self, month, day, t_start, t_end, t_name, session, session_info):
"""Adds event to calendar.
"""
event = Event()
- event['uid'] = self.gen_uid()
- event['dtstamp'] = self.dtstamp
- event['class'] = vText('PUBLIC')
- event['status'] = vText('CONFIRMED')
- event['method'] = vText('PUBLISH')
-
- if session == 'st-from-ts':
- event['summary'] = t_name
+ event["uid"] = self.gen_uid()
+ event["dtstamp"] = self.dtstamp
+ event["class"] = vText("PUBLIC")
+ event["status"] = vText("CONFIRMED")
+ event["method"] = vText("PUBLISH")
+
+ if session == "st-from-ts":
+ event["summary"] = t_name
else:
- event['summary'] = session
+ event["summary"] = session
- event['location'] = vText(session_info['room'])
+ event["location"] = vText(session_info["room"])
# Get rid of HTML in 'desc'
- desc = BeautifulSoup(' '.join(
- session_info['desc']).replace(
- '\n', ' '), 'html.parser').get_text()
- event['description'] = desc
+ desc = BeautifulSoup(
+ " ".join(session_info["desc"]).replace("\n", " "), "html.parser"
+ ).get_text()
+ event["description"] = desc
# Add speakers
- for speaker in session_info['speakers']:
- event.add('attendee', self.mk_attendee(speaker), encode=0)
+ for speaker in session_info["speakers"]:
+ event.add("attendee", self.mk_attendee(speaker), encode=0)
dt_start = self.mk_datetime(month, day, t_start)
dt_end = self.mk_datetime(month, day, t_end)
- event['dtstart'] = dt_start
- event['dtend'] = dt_end
+ event["dtstart"] = dt_start
+ event["dtend"] = dt_end
# Add to calendar
self.cal.add_component(event)
return event
-
def gen_ical(self):
"""Parse LP schedule dict and generate iCal Calendar object.
"""
@@ -274,16 +261,16 @@ class LPiCal(object):
# this timeslot
continue
for session, session_info in sessions.items():
- self.add_event(month, day, t_start, t_end, t_name,
- session, session_info)
-
- return self.cal.to_ical().decode('utf-8')
+ self.add_event(
+ month, day, t_start, t_end, t_name, session, session_info
+ )
+ return self.cal.to_ical().decode("utf-8")
def to_ical(self):
"""Writes iCal to disk.
"""
- filename = 'lp{}-schedule.ics'.format(self.lp_year)
+ filename = "lp{}-schedule.ics".format(self.lp_year)
write_file(filename, self.gen_ical())
return filename
@@ -313,8 +300,7 @@ class LPSRenderer(Renderer):
# If it is 'False', then the 'speaker.ids' file was not found;
# otherwise it is an OrderedDict containing the mapping of
# speakers and their corresponding id.
- self.speakers_ids = json_read('speakers.ids')
-
+ self.speakers_ids = json_read("speakers.ids")
def get_uid(self, speaker):
"""Generate unique id for `speaker`.
@@ -332,7 +318,6 @@ class LPSRenderer(Renderer):
# speaker not found in speakers_ids OrderedDict.
return False
-
def _check_session_title_exists(self):
"""Checks if :py:attr:`.last_session` is set.
@@ -356,10 +341,8 @@ class LPSRenderer(Renderer):
# no session title.
#
# st-from-ts -> session title from time slot.
- lps_dict[self.last_day][self.last_time_slot][
- 'st-from-ts'] = OrderedDict()
- self.last_session = 'st-from-ts'
-
+ lps_dict[self.last_day][self.last_time_slot]["st-from-ts"] = OrderedDict()
+ self.last_session = "st-from-ts"
def _process_video(self, text):
"""Process the video text.
@@ -369,15 +352,15 @@ class LPSRenderer(Renderer):
This method is meant to be called from the
:py:method:`.paragraph` method.
"""
- soup = BeautifulSoup(text, 'html.parser')
- links = soup.find_all('a')
+ soup = BeautifulSoup(text, "html.parser")
+ links = soup.find_all("a")
if len(links) == 0:
# no links found, so
return text
# link(s) found, return the first link's href.
- return links[0]['href']
+ return links[0]["href"]
def link(self, link, title, text):
# Here, we catch speaker names that have to be autolinked and
@@ -388,7 +371,7 @@ class LPSRenderer(Renderer):
# Here, `text` is the speaker' name.
id_ = self.get_uid(text)
if id_:
- link = 'speakers.html#{}'.format(id_)
+ link = "speakers.html#{}".format(id_)
else:
# Oh no, there is no id for this speaker.
self.speakers_noids.append(text)
@@ -397,7 +380,6 @@ class LPSRenderer(Renderer):
return super(LPSRenderer, self).link(link, title, text)
-
def header(self, text, level, raw=None):
global lps_dict
@@ -415,8 +397,7 @@ class LPSRenderer(Renderer):
self.last_session = None
elif level == 4:
# Add new session
- lps_dict[self.last_day][self.last_time_slot][
- text] = OrderedDict()
+ lps_dict[self.last_day][self.last_time_slot][text] = OrderedDict()
self.last_session = text
# We found a new session; set no of paragraphs processed
# to 0.
@@ -424,7 +405,6 @@ class LPSRenderer(Renderer):
return super(LPSRenderer, self).header(text, level, raw)
-
def paragraph(self, text):
global lps_dict
@@ -433,26 +413,29 @@ class LPSRenderer(Renderer):
if self.no_paragraph == 0:
# Speaker
- speakers = text.split(', ')
+ speakers = text.split(", ")
- lps_dict[self.last_day][self.last_time_slot][
- self.last_session]['speakers'] = speakers
+ lps_dict[self.last_day][self.last_time_slot][self.last_session][
+ "speakers"
+ ] = speakers
self.no_paragraph = self.no_paragraph + 1
elif self.no_paragraph == 1:
# Room
- lps_dict[self.last_day][self.last_time_slot][
- self.last_session]['room'] = text
+ lps_dict[self.last_day][self.last_time_slot][self.last_session][
+ "room"
+ ] = text
self.no_paragraph = self.no_paragraph + 1
elif self.no_paragraph == 2:
- lps_dict[self.last_day][self.last_time_slot][
- self.last_session]['video'] = self._process_video(text)
+ lps_dict[self.last_day][self.last_time_slot][self.last_session][
+ "video"
+ ] = self._process_video(text)
# Initialize description
- lps_dict[self.last_day][self.last_time_slot][
- self.last_session]['desc'] = []
+ lps_dict[self.last_day][self.last_time_slot][self.last_session]["desc"] = []
self.no_paragraph = self.no_paragraph + 1
elif self.no_paragraph > 1:
- lps_dict[self.last_day][self.last_time_slot][
- self.last_session]['desc'].append(text)
+ lps_dict[self.last_day][self.last_time_slot][self.last_session][
+ "desc"
+ ].append(text)
return p
@@ -466,8 +449,8 @@ class LPSpeakersRenderer(Renderer):
global lpspeakers_dict
lpspeakers_dict = OrderedDict()
- lpspeakers_dict['keynote-speakers'] = []
- lpspeakers_dict['speakers'] = []
+ lpspeakers_dict["keynote-speakers"] = []
+ lpspeakers_dict["speakers"] = []
# Type of present speaker being processed; can either be
# 'keynote-speakers' or 'speakers'.
@@ -476,12 +459,11 @@ class LPSpeakersRenderer(Renderer):
# Maintain a dict of speakers and their IDs.
self.speakers_ids = OrderedDict()
-
def mk_uid(self, speaker_block):
"""Returns a unique id.
"""
# 'John HÖcker, Onion Project' -> 'John HÖcker'
- speaker = str(speaker_block.split(', ')[0])
+ speaker = str(speaker_block.split(", ")[0])
# 'John HÖcker' -> 'John Hacker'
ascii_speaker = unidecode(speaker)
@@ -490,60 +472,52 @@ class LPSpeakersRenderer(Renderer):
id_ = ascii_speaker.split()[-1].lower()
if id_ not in self.speakers_ids.values():
- self.speakers_ids[speaker]= id_
+ self.speakers_ids[speaker] = id_
return id_
else:
# 'John Hacker' -> 'john_hacker'
- id_ = '_'.join([s.lower() for s in ascii_speaker.split()])
+ id_ = "_".join([s.lower() for s in ascii_speaker.split()])
self.speakers_ids[speaker] = id_
return id_
-
def header(self, text, level, raw=None):
global lpspeakers_dict
if level == 1:
- self.speaker_type = 'keynote-speakers'
+ self.speaker_type = "keynote-speakers"
lpspeakers_dict[self.speaker_type].append(OrderedDict())
- lpspeakers_dict[self.speaker_type][-1]['speaker'] = text
- lpspeakers_dict[self.speaker_type][-1][
- 'id'] = self.mk_uid(text)
- lpspeakers_dict[self.speaker_type][-1][
- 'bio'] = []
+ lpspeakers_dict[self.speaker_type][-1]["speaker"] = text
+ lpspeakers_dict[self.speaker_type][-1]["id"] = self.mk_uid(text)
+ lpspeakers_dict[self.speaker_type][-1]["bio"] = []
elif level == 2:
- self.speaker_type = 'speakers'
+ self.speaker_type = "speakers"
lpspeakers_dict[self.speaker_type].append(OrderedDict())
- lpspeakers_dict[self.speaker_type][
- -1]['speaker'] = text.split(', ')[0]
- lpspeakers_dict[self.speaker_type][
- -1]['id'] = self.mk_uid(text)
- lpspeakers_dict[self.speaker_type][
- -1]['bio'] = []
+ lpspeakers_dict[self.speaker_type][-1]["speaker"] = text.split(", ")[0]
+ lpspeakers_dict[self.speaker_type][-1]["id"] = self.mk_uid(text)
+ lpspeakers_dict[self.speaker_type][-1]["bio"] = []
return super(LPSpeakersRenderer, self).header(text, level, raw)
-
def image(self, src, title, text):
global lpspeakers_dict
- lpspeakers_dict[self.speaker_type][-1]['img_url'] = src
- lpspeakers_dict[self.speaker_type][-1]['img_alt'] = text
+ lpspeakers_dict[self.speaker_type][-1]["img_url"] = src
+ lpspeakers_dict[self.speaker_type][-1]["img_alt"] = text
return super(LPSpeakersRenderer, self).image(src, title, text)
-
def paragraph(self, text):
global lpspeakers_dict
p = super(LPSpeakersRenderer, self).paragraph(text)
- if text.startswith('<img'):
+ if text.startswith("<img"):
# ignore
return p
- lpspeakers_dict[self.speaker_type][-1]['bio'].append(text)
+ lpspeakers_dict[self.speaker_type][-1]["bio"].append(text)
return p
@@ -552,16 +526,15 @@ class LPSMarkdown(Markdown):
Returns the Markdown version of LP schedule as a dictionary.
"""
+
def __init__(self, inline=None, block=None, **kwargs):
"""
Initialize with LPSRenderer as the renderer.
"""
self.sessions_renderer = LPSRenderer()
super(LPSMarkdown, self).__init__(
- renderer=self.sessions_renderer,
- inline=None, block=None,
- **kwargs)
-
+ renderer=self.sessions_renderer, inline=None, block=None, **kwargs
+ )
def parse(self, text):
global lps_dict
@@ -570,8 +543,7 @@ class LPSMarkdown(Markdown):
html = super(LPSMarkdown, self).parse(text)
# Write list of speakers with no ids to `speakers.noids`.
- json_write('speakers.noids',
- self.sessions_renderer.speakers_noids)
+ json_write("speakers.noids", self.sessions_renderer.speakers_noids)
return lps_dict
@@ -588,10 +560,8 @@ class LPSpeakersMarkdown(Markdown):
"""
self.speakers_renderer = LPSpeakersRenderer()
super(LPSpeakersMarkdown, self).__init__(
- renderer=self.speakers_renderer,
- inline=None, block=None,
- **kwargs)
-
+ renderer=self.speakers_renderer, inline=None, block=None, **kwargs
+ )
def parse(self, text):
global lpspeakers_dict
@@ -599,7 +569,7 @@ class LPSpeakersMarkdown(Markdown):
html = super(LPSpeakersMarkdown, self).parse(text)
# Write mapping of speakers and their ids to `speakers.ids`.
- json_write('speakers.ids', self.speakers_renderer.speakers_ids)
+ json_write("speakers.ids", self.speakers_renderer.speakers_ids)
return lpspeakers_dict
@@ -611,51 +581,53 @@ def RenderHTML(lp_dict, template_name):
"""
template_content = template_read(template_name)
if not template_content:
- exit('Unable to read {} template'.format(template_name))
+ exit("Unable to read {} template".format(template_name))
- template = Environment(
- trim_blocks=True,
- lstrip_blocks=True
- ).from_string(template_content)
+ template = Environment(trim_blocks=True, lstrip_blocks=True).from_string(
+ template_content
+ )
lp_html = template.render(lp_dict=lp_dict)
- return str(BeautifulSoup(lp_html, 'html.parser')).strip()
+ return str(BeautifulSoup(lp_html, "html.parser")).strip()
def main():
parser = ArgumentParser()
group = parser.add_mutually_exclusive_group()
- group.add_argument("-sc", "--schedule", action="store_true",
- help="Generate LP schedule")
- group.add_argument("-sp", "--speakers", action="store_true",
- help="Generate LP speakers")
-
- parser.add_argument("--ical", type=int,
- help="Specify LP year as argument; "
- + "generates iCal")
- parser.add_argument("--version", action="version",
- version='lpschedule-generator version {}'
- .format(__version__),
- help="Show version number and exit.")
- parser.add_argument("lp_md",
- help="Path to the LP markdown.")
+ group.add_argument(
+ "-sc", "--schedule", action="store_true", help="Generate LP schedule"
+ )
+ group.add_argument(
+ "-sp", "--speakers", action="store_true", help="Generate LP speakers"
+ )
+
+ parser.add_argument(
+ "--ical", type=int, help="Specify LP year as argument; " + "generates iCal"
+ )
+ parser.add_argument(
+ "--version",
+ action="version",
+ version="lpschedule-generator version {}".format(__version__),
+ help="Show version number and exit.",
+ )
+ parser.add_argument("lp_md", help="Path to the LP markdown.")
args = parser.parse_args()
lp_md_content = read_file(path.abspath(args.lp_md))
if lp_md_content:
- template_name = ''
+ template_name = ""
if args.schedule:
markdown = LPSMarkdown()
- template_name = 'schedule'
+ template_name = "schedule"
elif args.speakers:
markdown = LPSpeakersMarkdown()
- template_name = 'speakers'
+ template_name = "speakers"
else:
- parser.error('No action requested, add -s or -sp switch')
+ parser.error("No action requested, add -s or -sp switch")
lp_dict = markdown(lp_md_content)
lp_html = RenderHTML(lp_dict, template_name)
@@ -664,13 +636,13 @@ def main():
LPiCal(lp_dict, args.ical).to_ical()
else:
- exit('Unable to read LP markdown')
+ exit("Unable to read LP markdown")
if lp_html:
# stdout lps html
print(lp_html)
else:
- print('Error generating LP HTML.')
+ print("Error generating LP HTML.")
if __name__ == "__main__":
diff --git a/lpschedule_generator/_version.py b/lpschedule_generator/_version.py
index b071082..0f296c4 100644
--- a/lpschedule_generator/_version.py
+++ b/lpschedule_generator/_version.py
@@ -5,4 +5,4 @@
# This file is part of lpschedule-generator.
#
-__version__ = u'0.10.0'
+__version__ = u"0.10.0"
diff --git a/setup.py b/setup.py
index 3fc75ce..b7c4290 100644
--- a/setup.py
+++ b/setup.py
@@ -10,48 +10,54 @@ from lpschedule_generator import _version
from setuptools import setup, find_packages
+
def readf(filename):
- content = ''
+ content = ""
try:
- with open(filename, 'r') as f:
+ with open(filename, "r") as f:
for line in f:
content = content + line
except IOError:
- print('Error: unable to open {}'.format(filename))
+ print("Error: unable to open {}".format(filename))
return content
+
config = {
- 'name': 'lpschedule-generator',
- 'description': 'LibrePlanet schedule generator',
- 'long_description': readf('README.rst'),
- 'version': _version.__version__,
- 'license': 'Public Domain',
- 'url': 'https://notabug.org/rsd/lpschedule-generator/',
- 'author': 'rsiddharth',
- 'author_email': 'rsd@gnu.org',
- 'install_requires': ['mistune>=0.8,<1', 'Jinja2', 'beautifulsoup4',
- 'unidecode', 'icalendar', 'pytz'],
- 'tests_require': ['nose', 'mock'],
- 'test_suite': 'nose.collector',
- 'py_modules': ['lps_gen'],
- 'packages': ['lpschedule_generator'],
- 'package_data': {
- 'lpschedule_generator': ['data/schedule.jinja2', 'data/speakers.jinja2']
- },
- 'entry_points': {
- 'console_scripts': ['lps_gen = lps_gen:main']
+ "name": "lpschedule-generator",
+ "description": "LibrePlanet schedule generator",
+ "long_description": readf("README.rst"),
+ "version": _version.__version__,
+ "license": "Public Domain",
+ "url": "https://notabug.org/rsd/lpschedule-generator/",
+ "author": "rsiddharth",
+ "author_email": "rsd@gnu.org",
+ "install_requires": [
+ "mistune>=0.8,<1",
+ "Jinja2",
+ "beautifulsoup4",
+ "unidecode",
+ "icalendar",
+ "pytz",
+ ],
+ "tests_require": ["nose", "mock"],
+ "test_suite": "nose.collector",
+ "py_modules": ["lps_gen"],
+ "packages": ["lpschedule_generator"],
+ "package_data": {
+ "lpschedule_generator": ["data/schedule.jinja2", "data/speakers.jinja2"]
},
- 'classifiers': [
- 'Development Status :: 3 - Alpha',
- 'Environment :: Console',
- 'Intended Audience :: Other Audience',
- 'License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication',
- 'Operating System :: POSIX :: Linux',
- 'Operating System :: POSIX :: BSD :: OpenBSD',
- 'Programming Language :: Python :: 3 :: Only',
- 'Topic :: Text Processing',
- 'Topic :: Utilities',
- ]
+ "entry_points": {"console_scripts": ["lps_gen = lps_gen:main"]},
+ "classifiers": [
+ "Development Status :: 3 - Alpha",
+ "Environment :: Console",
+ "Intended Audience :: Other Audience",
+ "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
+ "Operating System :: POSIX :: Linux",
+ "Operating System :: POSIX :: BSD :: OpenBSD",
+ "Programming Language :: Python :: 3 :: Only",
+ "Topic :: Text Processing",
+ "Topic :: Utilities",
+ ],
}
setup(**config)
diff --git a/tests/test_lps_gen.py b/tests/test_lps_gen.py
index bb8c519..e5117b3 100644
--- a/tests/test_lps_gen.py
+++ b/tests/test_lps_gen.py
@@ -21,70 +21,79 @@ from icalendar import vCalAddress, vText, vDatetime
from nose.tools import *
from pytz import timezone
-from lps_gen import (read_file, write_file, json_write, json_read,
- json_write, template_read, LPiCal, LPSRenderer,
- LPSpeakersRenderer, LPSMarkdown,
- LPSpeakersMarkdown, RenderHTML)
+from lps_gen import (
+ read_file,
+ write_file,
+ json_write,
+ json_read,
+ json_write,
+ template_read,
+ LPiCal,
+ LPSRenderer,
+ LPSpeakersRenderer,
+ LPSMarkdown,
+ LPSpeakersMarkdown,
+ RenderHTML,
+)
class TestJSONUtils(object):
"""Class that tests json utils in `lps_gen` module.
"""
+
@classmethod
def setup_class(self):
"""Runs before running any tests in this class."""
- self.speakers_ids = OrderedDict({
- 'Daniel Kahn Gillmor': 'gillmor',
- 'Edward Snowden': 'snowden',
- 'Richard Stallman': 'stallman',
- 'Clara Snowden': 'clara_snowden',
- 'Ludovic Courtès': 'courtes',
- 'Jonas Öberg': 'aberg',
- })
- self.ids_filename = 'speakers.ids'
+ self.speakers_ids = OrderedDict(
+ {
+ "Daniel Kahn Gillmor": "gillmor",
+ "Edward Snowden": "snowden",
+ "Richard Stallman": "stallman",
+ "Clara Snowden": "clara_snowden",
+ "Ludovic Courtès": "courtes",
+ "Jonas Öberg": "aberg",
+ }
+ )
+ self.ids_filename = "speakers.ids"
self.speakers_noids = [
- 'Daniel Kahn Gillmor',
- 'Richard Stallman',
- 'Ludovic Courtès',
- 'Jonas Öberg',
+ "Daniel Kahn Gillmor",
+ "Richard Stallman",
+ "Ludovic Courtès",
+ "Jonas Öberg",
]
- self.noids_filename = 'speakers.noids'
+ self.noids_filename = "speakers.noids"
# Change current working directory to the tests directory.
self.old_cwd = os.getcwd()
- os.chdir('tests')
-
+ os.chdir("tests")
def setup(self):
"""Runs before each test in this class."""
pass
-
def test_json_write(self):
"""Testing json_write function."""
json_write(self.ids_filename, self.speakers_ids)
- assert_equal(json.loads(read_file(self.ids_filename),
- object_pairs_hook=OrderedDict),
- self.speakers_ids)
+ assert_equal(
+ json.loads(read_file(self.ids_filename), object_pairs_hook=OrderedDict),
+ self.speakers_ids,
+ )
json_write(self.noids_filename, self.speakers_noids)
- assert_equal(json.loads(read_file(self.noids_filename),
- object_pairs_hook=OrderedDict),
- self.speakers_noids)
-
+ assert_equal(
+ json.loads(read_file(self.noids_filename), object_pairs_hook=OrderedDict),
+ self.speakers_noids,
+ )
def test_json_read(self):
"""Testing json_read function."""
- write_file(self.ids_filename, json.dumps(self.speakers_ids,
- indent=4))
+ write_file(self.ids_filename, json.dumps(self.speakers_ids, indent=4))
assert_equal(json_read(self.ids_filename), self.speakers_ids)
- write_file(self.noids_filename, json.dumps(self.speakers_noids,
- indent=4))
+ write_file(self.noids_filename, json.dumps(self.speakers_noids, indent=4))
assert_equal(json_read(self.noids_filename), self.speakers_noids)
-
def teardown(self):
"""Cleans up things after each test in this class."""
# Remove `speakers.ids` file if it exists.
@@ -95,7 +104,6 @@ class TestJSONUtils(object):
if path.isfile(self.noids_filename):
os.remove(self.noids_filename)
-
@classmethod
def teardown_class(self):
"""Clean up the mess created by this test."""
@@ -108,16 +116,16 @@ class TestTemplates(object):
"""
def test_read(self):
- t = template_read('schedule')
+ t = template_read("schedule")
assert type(t) is str
assert len(t) > 0
- t = template_read('speakers')
+ t = template_read("speakers")
assert type(t) is str
assert len(t) > 0
- with mock.patch('sys.stderr', new_callable=StringIO) as out:
- t = template_read('nonexistent')
+ with mock.patch("sys.stderr", new_callable=StringIO) as out:
+ t = template_read("nonexistent")
assert t is None
@@ -133,48 +141,41 @@ class TestLPiCal(object):
# Change current working directory to the tests directory.
self.old_cwd = os.getcwd()
- os.chdir('tests')
+ os.chdir("tests")
- self.MD_FILE = path.join('files', 'lp-sch.md')
+ self.MD_FILE = path.join("files", "lp-sch.md")
self.MD_FILE_CONTENT = read_file(self.MD_FILE)
- self.MD_FILE_S_ONLY = path.join('files', 'lp-sch-sessions-only.md')
+ self.MD_FILE_S_ONLY = path.join("files", "lp-sch-sessions-only.md")
self.MD_FILE_S_ONLY_CONTENT = read_file(self.MD_FILE_S_ONLY)
self.markdown = LPSMarkdown()
self.lps_dict = self.markdown(self.MD_FILE_CONTENT)
self.lps_dict_s_only = self.markdown(self.MD_FILE_S_ONLY_CONTENT)
- self.purge_list = ['speakers.noids']
-
+ self.purge_list = ["speakers.noids"]
def setup(self):
"""Setting up things for a new test.
"""
- self.lp_ical = LPiCal(self.lps_dict, '2019')
-
+ self.lp_ical = LPiCal(self.lps_dict, "2019")
def test_init(self):
"""Testing LPiCal.__init__.
"""
- lp_ical = LPiCal(self.lps_dict, '2019')
+ lp_ical = LPiCal(self.lps_dict, "2019")
- assert_equal(lp_ical.lp_year, '2019')
- assert_equal(lp_ical.cal.get('x-wr-calname'),
- 'LibrePlanet 2019')
+ assert_equal(lp_ical.lp_year, "2019")
+ assert_equal(lp_ical.cal.get("x-wr-calname"), "LibrePlanet 2019")
assert_equal(lp_ical.ucounter, 0)
-
def test_gen_uid(self):
"""Testing LPiCal.gen_uid.
"""
- uid_fmt = ''.join(['{id}@LP', self.lp_ical.lp_year,
- '@libreplanet.org'])
+ uid_fmt = "".join(["{id}@LP", self.lp_ical.lp_year, "@libreplanet.org"])
for i in range(40):
- assert_equals(self.lp_ical.gen_uid(),
- uid_fmt.format(id=i+1))
-
+ assert_equals(self.lp_ical.gen_uid(), uid_fmt.format(id=i + 1))
def test_get_timeslot(self):
"""
@@ -182,36 +183,25 @@ class TestLPiCal(object):
"""
timeslots = {
- '09:00-09:45: Registration and Breakfast':
- ['09:00', '09:45', 'Registration and Breakfast'],
- ' 09:45 - 10:45: Opening Keynote':
- ['09:45', '10:45', 'Opening Keynote'],
- '10:5 - 10:55: Break':
- ['10:5', '10:55', 'Break'],
- ' 10:55 - 11:40: Session Block 1A':
- ['10:55', '11:40', 'Session Block 1A'],
- ' 11:40 - 11:50: Break':
- ['11:40', '11:50', 'Break'],
- '9:45 - 10:30: Keynote ':
- ['9:45', '10:30', 'Keynote'],
- '16:55 - 17:40:Session Block 6B':
- ['16:55', '17:40', 'Session Block 6B'],
- '17:50 - 18:35: Closing keynote':
- ['17:50', '18:35', 'Closing keynote'],
- '':
- [None, None, None],
- '\t\t\t':
- [None, None, None],
- ' ':
- [None, None, None],
- '10:00 - 10:45 - Keynote':
- ['10:00', '10:45', 'Keynote'],
- '16:20 - 17:05':
- ['16:20', '17:05', ''],
- '16:25-17:25':
- ['16:25', '17:25', ''],
- '17:05-17:15 - Break':
- ['17:05', '17:15', 'Break']
+ "09:00-09:45: Registration and Breakfast": [
+ "09:00",
+ "09:45",
+ "Registration and Breakfast",
+ ],
+ " 09:45 - 10:45: Opening Keynote": ["09:45", "10:45", "Opening Keynote"],
+ "10:5 - 10:55: Break": ["10:5", "10:55", "Break"],
+ " 10:55 - 11:40: Session Block 1A": ["10:55", "11:40", "Session Block 1A"],
+ " 11:40 - 11:50: Break": ["11:40", "11:50", "Break"],
+ "9:45 - 10:30: Keynote ": ["9:45", "10:30", "Keynote"],
+ "16:55 - 17:40:Session Block 6B": ["16:55", "17:40", "Session Block 6B"],
+ "17:50 - 18:35: Closing keynote": ["17:50", "18:35", "Closing keynote"],
+ "": [None, None, None],
+ "\t\t\t": [None, None, None],
+ " ": [None, None, None],
+ "10:00 - 10:45 - Keynote": ["10:00", "10:45", "Keynote"],
+ "16:20 - 17:05": ["16:20", "17:05", ""],
+ "16:25-17:25": ["16:25", "17:25", ""],
+ "17:05-17:15 - Break": ["17:05", "17:15", "Break"],
}
for string, timeslot in timeslots.items():
@@ -220,78 +210,67 @@ class TestLPiCal(object):
assert_equal(end, timeslot[1])
assert_equal(name, timeslot[2])
-
def test_get_month_day(self):
"""Testing LPiCal.get_month_day.
"""
month_days = {
- 'Sunday, March 20': ['March', '20'],
- 'Saturday, March 19': ['March', '19'],
- 'Monday,March 20 ': ['March', '20'],
- 'Tuesday,March21': ['March', '21'],
- ' Wednesday, March 22': ['March', '22'],
- 'Thursday, March 23 ': ['March', '23'],
- '': [None, None],
- '\t\t': [None, None],
- ' ': [None, None],
+ "Sunday, March 20": ["March", "20"],
+ "Saturday, March 19": ["March", "19"],
+ "Monday,March 20 ": ["March", "20"],
+ "Tuesday,March21": ["March", "21"],
+ " Wednesday, March 22": ["March", "22"],
+ "Thursday, March 23 ": ["March", "23"],
+ "": [None, None],
+ "\t\t": [None, None],
+ " ": [None, None],
}
for string, month_day in month_days.items():
- month, day = self.lp_ical.get_month_day(string)
+ month, day = self.lp_ical.get_month_day(string)
assert_equal(month, month_day[0])
assert_equal(day, month_day[1])
-
def test_mk_datetime(self):
"""Testing LPiCal.mk_datetime
"""
datetimes = [
- {
- 'params': ['February', '28','08:00'],
- 'datetime': '2019-02-28 08:00:00',
- },
- {
- 'params': ['March', '21', '9:0'],
- 'datetime': '2019-03-21 09:00:00',
- },
- {
- 'params': ['March', '23', '15:30'],
- 'datetime': '2019-03-23 15:30:00',
- },
+ {"params": ["February", "28", "08:00"], "datetime": "2019-02-28 08:00:00",},
+ {"params": ["March", "21", "9:0"], "datetime": "2019-03-21 09:00:00",},
+ {"params": ["March", "23", "15:30"], "datetime": "2019-03-23 15:30:00",},
]
for test in datetimes:
- month = test['params'][0]
- day = test['params'][1]
- time = test['params'][2]
+ month = test["params"][0]
+ day = test["params"][1]
+ time = test["params"][2]
dt_obj = self.lp_ical.mk_datetime(month, day, time)
- assert str(dt_obj.dt.tzinfo) == 'US/Eastern'
- assert str(dt_obj.dt)[:-6] == test['datetime']
-
+ assert str(dt_obj.dt.tzinfo) == "US/Eastern"
+ assert str(dt_obj.dt)[:-6] == test["datetime"]
def test_mk_attendee(self):
"""Testing LPiCal.mk_attendee
"""
speakers = [
- 'Richard Stallman',
- 'ginger coons',
+ "Richard Stallman",
+ "ginger coons",
'<a href="speakers.htmll#corvellec">Marianne Corvellec</a>',
'<a href="speakers.html#le-lous">Jonathan Le Lous</a>',
- 'Jonas \xc3\x96berg',
- ]
+ "Jonas \xc3\x96berg",
+ ]
for speaker in speakers:
attendee = self.lp_ical.mk_attendee(speaker)
- assert str(attendee) == 'invalid:nomail'
- assert attendee.params.get('cn') == BeautifulSoup(
- speaker, 'html.parser').get_text()
- assert attendee.params.get('ROLE') == 'REQ-PARTICIPANT'
- assert attendee.params.get('CUTYPE') == 'INDIVIDUAL'
-
+ assert str(attendee) == "invalid:nomail"
+ assert (
+ attendee.params.get("cn")
+ == BeautifulSoup(speaker, "html.parser").get_text()
+ )
+ assert attendee.params.get("ROLE") == "REQ-PARTICIPANT"
+ assert attendee.params.get("CUTYPE") == "INDIVIDUAL"
def test_add_event(self):
"""Testing LPiCal.add_event
@@ -303,58 +282,58 @@ class TestLPiCal(object):
for timeslot_str, sessions in timeslots.items():
t_start, t_end, t_name = self.lp_ical.get_timeslot(timeslot_str)
for session, session_info in sessions.items():
- event = self.lp_ical.add_event(month, day,
- t_start, t_end, t_name,
- session, session_info)
- assert event['uid'] not in uids
- uids.append(event['uid'])
-
- assert event['dtstamp'] == self.lp_ical.dtstamp
- assert event['class'] == 'PUBLIC'
- assert event['status'] == 'CONFIRMED'
- assert event['method'] == 'PUBLISH'
-
- if session == 'st-from-ts':
- assert event['summary'] == t_name
+ event = self.lp_ical.add_event(
+ month, day, t_start, t_end, t_name, session, session_info
+ )
+ assert event["uid"] not in uids
+ uids.append(event["uid"])
+
+ assert event["dtstamp"] == self.lp_ical.dtstamp
+ assert event["class"] == "PUBLIC"
+ assert event["status"] == "CONFIRMED"
+ assert event["method"] == "PUBLISH"
+
+ if session == "st-from-ts":
+ assert event["summary"] == t_name
else:
- assert event['summary'] == session
-
- assert event['location'] == session_info['room']
- assert event['description'] == BeautifulSoup(' '.join(
- session_info['desc']).replace(
- '\n',' '), 'html.parser').get_text()
-
- if type(event['attendee']) is list:
- for attendee in event['attendee']:
+ assert event["summary"] == session
+
+ assert event["location"] == session_info["room"]
+ assert (
+ event["description"]
+ == BeautifulSoup(
+ " ".join(session_info["desc"]).replace("\n", " "),
+ "html.parser",
+ ).get_text()
+ )
+
+ if type(event["attendee"]) is list:
+ for attendee in event["attendee"]:
assert isinstance(attendee, vCalAddress)
else:
- assert isinstance(event['attendee'], vCalAddress)
-
- assert isinstance(event['dtstart'], vDatetime)
- assert isinstance(event['dtend'], vDatetime)
+ assert isinstance(event["attendee"], vCalAddress)
+ assert isinstance(event["dtstart"], vDatetime)
+ assert isinstance(event["dtend"], vDatetime)
def test_gen_ical(self):
"""Testing LPiCal.gen_ical.
"""
print(self.lp_ical.gen_ical())
-
def test_gen_ical_sessions_only(self):
"""Testing LPiCal.gen_ical with sessions only schedule.
"""
- print(LPiCal(self.lps_dict_s_only, '2019').gen_ical())
-
+ print(LPiCal(self.lps_dict_s_only, "2019").gen_ical())
def test_to_ical(self):
"""Testing LPiCal.to_ical.
"""
filename = self.lp_ical.to_ical()
- assert_equal(filename, 'lp2019-schedule.ics')
+ assert_equal(filename, "lp2019-schedule.ics")
self.purge_list.append(filename)
-
@classmethod
def teardown_class(self):
"""
@@ -374,15 +353,16 @@ class TestLPS(object):
"""
Class that tests everything related LP Schedule.
"""
+
@classmethod
def setup_class(self):
"""Runs before running any tests in this class."""
# Change current working directory to the tests directory.
self.old_cwd = os.getcwd()
- os.chdir('tests')
+ os.chdir("tests")
- self.MD_FILE = path.join('files', 'lp-sch.md')
+ self.MD_FILE = path.join("files", "lp-sch.md")
self.MD_FILE_CONTENT = read_file(self.MD_FILE)
self.markdown = LPSMarkdown()
@@ -392,34 +372,31 @@ class TestLPS(object):
"""Runs before each test in this class."""
pass
-
def test_LPSMarkdown_day(self):
"""
Testing `LPSMarkdown` class - Day.
"""
- days = ['Saturday, March 19',
- 'Sunday, March 20']
+ days = ["Saturday, March 19", "Sunday, March 20"]
i = 0
for day in self.lps_dict.keys():
assert_equal(day, days[i])
i = i + 1
-
def test_LPSMarkdown_timeslot(self):
"""
Testing `LPSMarkdown` class - Timeslot.
"""
timeslots = [
- '09:00 - 09:45: Registration and Breakfast',
- '09:45 - 10:45: Opening Keynote: Richard Stallman',
- '10:55 - 11:40: Session Block 1A',
- '11:40 - 11:50: Break',
- '11:50 - 12:35: Session Block 2A',
- '09:00 - 09:45: Registration and breakfast',
- '09:45 - 10:30: Keynote: Access without empowerment',
- '10:30 - 10:40: Break',
- '10:40 - 11:25: Session Block 1B',
- ]
+ "09:00 - 09:45: Registration and Breakfast",
+ "09:45 - 10:45: Opening Keynote: Richard Stallman",
+ "10:55 - 11:40: Session Block 1A",
+ "11:40 - 11:50: Break",
+ "11:50 - 12:35: Session Block 2A",
+ "09:00 - 09:45: Registration and breakfast",
+ "09:45 - 10:30: Keynote: Access without empowerment",
+ "10:30 - 10:40: Break",
+ "10:40 - 11:25: Session Block 1B",
+ ]
i = 0
for lps_timeslots in self.lps_dict.values():
@@ -427,22 +404,21 @@ class TestLPS(object):
assert_equal(timeslot, timeslots[i])
i = i + 1
-
def test_LPSMarkdown_session(self):
"""
Testing `LPSMarkdown` class - Session.
"""
sessions = [
- 'Free software, free hardware, and other things',
- 'Federation and GNU',
- 'Dr. Hyde and Mr. Jekyll: advocating for free software in nonfree academic contexts',
- 'TAFTA, CETA, TISA: traps and threats to Free Software Everywhere',
- 'Let\'s encrypt!',
- 'Attribution revolution -- turning copyright upside-down',
- 'st-from-ts',
- 'Fork and ignore: fighting a GPL violation by coding instead',
- 'Who did this? Just wait until your father gets home',
- ]
+ "Free software, free hardware, and other things",
+ "Federation and GNU",
+ "Dr. Hyde and Mr. Jekyll: advocating for free software in nonfree academic contexts",
+ "TAFTA, CETA, TISA: traps and threats to Free Software Everywhere",
+ "Let's encrypt!",
+ "Attribution revolution -- turning copyright upside-down",
+ "st-from-ts",
+ "Fork and ignore: fighting a GPL violation by coding instead",
+ "Who did this? Just wait until your father gets home",
+ ]
i = 0
for lps_timeslots in self.lps_dict.values():
@@ -451,144 +427,136 @@ class TestLPS(object):
assert_equal(session, sessions[i])
i = i + 1
-
def test_LPSMarkdown_speaker(self):
"""
Testing `LPSMarkdown` class - Speaker
"""
speakers = [
- ['Richard Stallman'],
+ ["Richard Stallman"],
['<a href="http://dustycloud.org">Christopher Webber</a>'],
- ['ginger coons'],
- ['<a href="/2015/program/speakers.html#corvellec">Marianne Corvellec</a>',
- '<a href="/2015/program/speakers.html#le-lous">Jonathan Le Lous</a>'],
- ['Seth Schoen'],
- ['Jonas Öberg'],
- ['Benjamin Mako Hill'],
- ['Bradley Kuhn'],
- ['Ken Starks'],
- ]
+ ["ginger coons"],
+ [
+ '<a href="/2015/program/speakers.html#corvellec">Marianne Corvellec</a>',
+ '<a href="/2015/program/speakers.html#le-lous">Jonathan Le Lous</a>',
+ ],
+ ["Seth Schoen"],
+ ["Jonas Öberg"],
+ ["Benjamin Mako Hill"],
+ ["Bradley Kuhn"],
+ ["Ken Starks"],
+ ]
i = 0
for lps_timeslots in self.lps_dict.values():
for lps_sessions in lps_timeslots.values():
for session_info in lps_sessions.values():
- assert_equal(session_info['speakers'], speakers[i])
+ assert_equal(session_info["speakers"], speakers[i])
i = i + 1
-
def test_LPSMarkdown_room(self):
"""
Testing `LPSMarkdown` class - Room
"""
rooms = [
- 'Room 32-123',
- 'Room 32-123',
- 'Room 32-141',
- 'Room 32-155',
- 'Room 32-123',
- 'Room 32-141',
- 'Room 32-123',
- 'Room 32-123',
- 'Room 32-141',
- ]
+ "Room 32-123",
+ "Room 32-123",
+ "Room 32-141",
+ "Room 32-155",
+ "Room 32-123",
+ "Room 32-141",
+ "Room 32-123",
+ "Room 32-123",
+ "Room 32-141",
+ ]
i = 0
for lps_timeslots in self.lps_dict.values():
for lps_sessions in lps_timeslots.values():
for session_info in lps_sessions.values():
- assert_equal(session_info['room'], rooms[i])
+ assert_equal(session_info["room"], rooms[i])
i = i + 1
-
def test_LPSMarkdown_video(self):
"""Testing `LPSMarkdown` class - Video
"""
videos = [
- 'https://media.libre.planet/rms-free-everything',
- 'https://media.libre.planet/gnu-fed',
- 'VideoTBA',
- 'https://media.libre.planet/tafta-ceta-tisa',
- 'https://media.libre.planet/letsencrypt',
- 'VideoTBA',
- 'https://media.libre.planet/mako-keynote',
- 'https://media.libre.planet/fork-ignore',
- 'VideoTBA',
- ]
+ "https://media.libre.planet/rms-free-everything",
+ "https://media.libre.planet/gnu-fed",
+ "VideoTBA",
+ "https://media.libre.planet/tafta-ceta-tisa",
+ "https://media.libre.planet/letsencrypt",
+ "VideoTBA",
+ "https://media.libre.planet/mako-keynote",
+ "https://media.libre.planet/fork-ignore",
+ "VideoTBA",
+ ]
i = 0
for lps_timeslots in self.lps_dict.values():
for lps_sessions in lps_timeslots.values():
for session_info in lps_sessions.values():
- assert_equal(session_info['video'], videos[i])
+ assert_equal(session_info["video"], videos[i])
i = i + 1
-
def test_LPSMarkdown_desc(self):
"""Testing `LPSMarkdown` class - Video
"""
descriptions = [
- 'Preceded by a welcome address from',
- 'The effort to re-decentralize the web has',
- 'What if the classic horror trope of the',
- 'TAFTA, CETA, and TISA are far-reaching',
- 'This year a robotic certificate authority will',
- 'Reusing works licensed under free licenses seems',
- 'In order to relate effectively to the digital works',
- 'The free software movement has twin',
- 'Typically, GPL enforcement activity',
- 'While traditional enforcement is often',
- 'Recently, Software Freedom Conservancy',
- 'This talk discusses which scenarios make this remedy',
- 'What\'s going on in here? Computer parts',
+ "Preceded by a welcome address from",
+ "The effort to re-decentralize the web has",
+ "What if the classic horror trope of the",
+ "TAFTA, CETA, and TISA are far-reaching",
+ "This year a robotic certificate authority will",
+ "Reusing works licensed under free licenses seems",
+ "In order to relate effectively to the digital works",
+ "The free software movement has twin",
+ "Typically, GPL enforcement activity",
+ "While traditional enforcement is often",
+ "Recently, Software Freedom Conservancy",
+ "This talk discusses which scenarios make this remedy",
+ "What's going on in here? Computer parts",
]
i = 0
for lps_timeslots in self.lps_dict.values():
for lps_sessions in lps_timeslots.values():
for session_info in lps_sessions.values():
- for desc in session_info['desc']:
+ for desc in session_info["desc"]:
assert_true(desc.startswith(descriptions[i]))
i = i + 1
-
def test_RenderHTML(self):
"""Testing `RenderHTML` function with LP schedule
"""
- lps_html = RenderHTML(self.lps_dict, 'schedule')
- print(lps_html) # TODO: Scrape and test html output
-
+ lps_html = RenderHTML(self.lps_dict, "schedule")
+ print(lps_html) # TODO: Scrape and test html output
def test_RenderHTML_sessions_only(self):
"""Testing `RenderHTML` function - LP schedule - sessions only
"""
- md_content = read_file(path.join('files',
- 'lp-sch-sessions-only.md'))
+ md_content = read_file(path.join("files", "lp-sch-sessions-only.md"))
- lps_html = RenderHTML(self.markdown(md_content),
- 'schedule')
- print(lps_html) # TODO: Scrape and test html output
+ lps_html = RenderHTML(self.markdown(md_content), "schedule")
+ print(lps_html) # TODO: Scrape and test html output
@raises(SystemExit)
def test_RenderHTML_nonexistent_template(self):
"""Testing `RenderHTML` function - LP schedule - ith non-existent template
"""
- with mock.patch('sys.stderr', new_callable=StringIO) as out:
- lps_html = RenderHTML(self.lps_dict, 'nonexistent')
-
+ with mock.patch("sys.stderr", new_callable=StringIO) as out:
+ lps_html = RenderHTML(self.lps_dict, "nonexistent")
def teardown(self):
"""Cleans up things after each test in this class."""
pass
-
@classmethod
def teardown_class(self):
"""Clean up the mess created by this test."""
# Remove `speakers.noids` file if it exists.
- if path.isfile('speakers.noids'):
- os.remove('speakers.noids')
+ if path.isfile("speakers.noids"):
+ os.remove("speakers.noids")
# Change back to the old cwd
os.chdir(self.old_cwd)
@@ -606,97 +574,88 @@ class TestLPSTBA(object):
"""
# Change current working directory to the tests directory.
self.old_cwd = os.getcwd()
- os.chdir('tests')
+ os.chdir("tests")
- self.MD_FILE = path.join('files', 'lp-sch-tba.md')
+ self.MD_FILE = path.join("files", "lp-sch-tba.md")
self.MD_FILE_CONTENT = read_file(self.MD_FILE)
self.markdown = LPSMarkdown()
self.lps_dict = self.markdown(self.MD_FILE_CONTENT)
-
def setup(self):
"""Runs before each test in this class.
"""
- lp_html = RenderHTML(self.lps_dict, 'schedule')
- self.soup = BeautifulSoup(lp_html, 'html.parser')
-
+ lp_html = RenderHTML(self.lps_dict, "schedule")
+ self.soup = BeautifulSoup(lp_html, "html.parser")
def cleanup_speaker(self, sp):
- return ' '.join([s.strip() for s in sp.string.split('\n')
- if len(s.strip())])
-
+ return " ".join([s.strip() for s in sp.string.split("\n") if len(s.strip())])
def cleanup_desc(self, desc):
- return desc.replace('\n', '').strip()
-
+ return desc.replace("\n", "").strip()
def test_LP_speakers(self):
"""Tests the non-existence of `SpeakerTBA` in gen. HTML.
"""
speakers = [
- 'Paige Peterson, MaidSoft',
- 'George Chriss and others, Kat Walsh (moderator)',
- 'Andrew Seeder, Dudley Street Neighborhood Initiative',
- 'Marina Zhurakhinskaya, Red Hat',
- 'Marianne Corvellec, April and Jonathan Le Lous, April',
- 'Scott Dexter and Evan Misshula, CUNY, and Erin Glass, UCSD',
- 'Michaela R. Brown',
+ "Paige Peterson, MaidSoft",
+ "George Chriss and others, Kat Walsh (moderator)",
+ "Andrew Seeder, Dudley Street Neighborhood Initiative",
+ "Marina Zhurakhinskaya, Red Hat",
+ "Marianne Corvellec, April and Jonathan Le Lous, April",
+ "Scott Dexter and Evan Misshula, CUNY, and Erin Glass, UCSD",
+ "Michaela R. Brown",
]
- for sp in self.soup.find_all(class_='program-session-speaker'):
+ for sp in self.soup.find_all(class_="program-session-speaker"):
sp_block = self.cleanup_speaker(sp)
assert_equal(sp_block, speakers.pop(0))
-
def test_LP_room(self):
"""Tests the non-existence of `RoomTBA` in gen. HTML.
"""
rooms = [
- 'Room 32-141',
- 'Room 32-144',
- 'Room 31-123',
- 'Room 32-144',
- 'Room 42-042',
+ "Room 32-141",
+ "Room 32-144",
+ "Room 31-123",
+ "Room 32-144",
+ "Room 42-042",
]
- for sp in self.soup.find_all(class_='room'):
+ for sp in self.soup.find_all(class_="room"):
room_block = sp.string
assert_equal(room_block, rooms.pop(0))
-
def test_LP_description(self):
"""Tests the non-existence of `DescTBA` in gen. HTML.
"""
descriptions = [
- 'Your workplace can exert a lot of control over how',
- 'Free software developers and users tend to be most',
- 'This talk will help you gather information, frame',
- 'A look back at free software history',
- 'Academic Institutions and their researchers',
- 'At CUNY, we have taken steps to change this',
- 'Being a free software user isn\'t easy,',
- 'In this session, I\'ll give students tips',
+ "Your workplace can exert a lot of control over how",
+ "Free software developers and users tend to be most",
+ "This talk will help you gather information, frame",
+ "A look back at free software history",
+ "Academic Institutions and their researchers",
+ "At CUNY, we have taken steps to change this",
+ "Being a free software user isn't easy,",
+ "In this session, I'll give students tips",
]
- for descs in self.soup.find_all(class_='session-desc'):
+ for descs in self.soup.find_all(class_="session-desc"):
for desc in descs.strings:
desc = self.cleanup_desc(desc)
if desc:
assert desc.startswith(descriptions.pop(0))
-
def teardown(self):
"""Cleans up things after each test in this class.
"""
# Remove `speakers.noids` file if it exists.
- if path.isfile('speakers.noids'):
- os.remove('speakers.noids')
-
+ if path.isfile("speakers.noids"):
+ os.remove("speakers.noids")
@classmethod
def teardown_class(self):
@@ -717,262 +676,257 @@ class TestLPSpeakers(object):
# Change current working directory to the tests directory.
self.old_cwd = os.getcwd()
- os.chdir('tests')
+ os.chdir("tests")
- self.MD_FILE = path.join('files', 'lp-speakers.md')
+ self.MD_FILE = path.join("files", "lp-speakers.md")
self.MD_FILE_CONTENT = read_file(self.MD_FILE)
self.markdown = LPSpeakersMarkdown()
self.lpspeakers_dict = self.markdown(self.MD_FILE_CONTENT)
-
def setup(self):
"""Runs before each test in this class."""
pass
-
def test_speakers_id_file_exists(self):
"""
Testing if LPSpeakersMardown created speakers.ids file.
"""
speakers_ids = self.markdown.speakers_renderer.speakers_ids
- assert path.isfile('speakers.ids')
- assert_equal(json_read('speakers.ids'), speakers_ids)
-
+ assert path.isfile("speakers.ids")
+ assert_equal(json_read("speakers.ids"), speakers_ids)
def test_LPSpeakersMarkdown_keynotespeakers_name(self):
"""Testing LPSpeakersMarkdown keynote speakers' names.
"""
- keynote_speakers = ['Daniel Kahn Gillmor',
- 'Edward Snowden',
- 'Richard Stallman',
- 'Clara Snowden',
- 'Ludovic Courtès']
+ keynote_speakers = [
+ "Daniel Kahn Gillmor",
+ "Edward Snowden",
+ "Richard Stallman",
+ "Clara Snowden",
+ "Ludovic Courtès",
+ ]
i = 0
- for kspeaker in self.lpspeakers_dict['keynote-speakers']:
- assert_equal(kspeaker['speaker'], keynote_speakers[i])
+ for kspeaker in self.lpspeakers_dict["keynote-speakers"]:
+ assert_equal(kspeaker["speaker"], keynote_speakers[i])
i = i + 1
-
def test_LPSpeakersMarkdown_keynotespeakers_id(self):
"""Testing LPSpeakersMarkdown keynote speakers' id.
"""
- keynote_speaker_ids = ['gillmor',
- 'snowden',
- 'stallman',
- 'clara_snowden',
- 'courtes']
-
+ keynote_speaker_ids = [
+ "gillmor",
+ "snowden",
+ "stallman",
+ "clara_snowden",
+ "courtes",
+ ]
i = 0
- for kspeaker in self.lpspeakers_dict['keynote-speakers']:
- assert_equal(kspeaker['id'], keynote_speaker_ids[i])
+ for kspeaker in self.lpspeakers_dict["keynote-speakers"]:
+ assert_equal(kspeaker["id"], keynote_speaker_ids[i])
i = i + 1
-
def test_LPSpeakersMarkdown_keynotespeakers_imgurl(self):
"""Testing LPSpeakersMarkdown keynote speakers' image url.
"""
keynote_speaker_img_urls = [
- '//static.fsf.org/nosvn/libreplanet/speaker-pics/dkg.jpg',
- '//static.fsf.org/nosvn/libreplanet/speaker-pics/snowden.jpg',
- '//static.fsf.org/nosvn/libreplanet/speaker-pics/stallman.jpg',
- '//static.fsf.org/nosvn/libreplanet/speaker-pics/c_snowden.jpg'
+ "//static.fsf.org/nosvn/libreplanet/speaker-pics/dkg.jpg",
+ "//static.fsf.org/nosvn/libreplanet/speaker-pics/snowden.jpg",
+ "//static.fsf.org/nosvn/libreplanet/speaker-pics/stallman.jpg",
+ "//static.fsf.org/nosvn/libreplanet/speaker-pics/c_snowden.jpg",
]
-
-
i = 0
- for kspeaker in self.lpspeakers_dict['keynote-speakers']:
- if 'img_url' in kspeaker:
- assert_equal(kspeaker['img_url'],
- keynote_speaker_img_urls[i])
+ for kspeaker in self.lpspeakers_dict["keynote-speakers"]:
+ if "img_url" in kspeaker:
+ assert_equal(kspeaker["img_url"], keynote_speaker_img_urls[i])
i = i + 1
-
def test_LPSpeakersMarkdown_keynotespeakers_imgalt(self):
"""Testing LPSpeakersMarkdown keynote speakers' image alt text.
"""
- keynote_speaker_img_alts = ['Daniel Kahn Gillmor - Photo',
- 'Edward Snowden - Photo',
- 'Richard Stallman - Photo',
- '']
-
-
+ keynote_speaker_img_alts = [
+ "Daniel Kahn Gillmor - Photo",
+ "Edward Snowden - Photo",
+ "Richard Stallman - Photo",
+ "",
+ ]
i = 0
- for kspeaker in self.lpspeakers_dict['keynote-speakers']:
- if 'img_alt' in kspeaker:
- assert_equal(kspeaker['img_alt'],
- keynote_speaker_img_alts[i])
+ for kspeaker in self.lpspeakers_dict["keynote-speakers"]:
+ if "img_alt" in kspeaker:
+ assert_equal(kspeaker["img_alt"], keynote_speaker_img_alts[i])
i = i + 1
-
def test_LPSpeakersMarkdown_keynotespeakers_bio(self):
"""Testing LPSpeakersMarkdown keynote speakers' bio.
"""
keynote_speaker_bios = [
- ['Daniel Kahn Gillmor is a technologist with the ACLU\'s Speech, Privacy'],
- ['Edward Snowden is a former intelligence officer who served the CIA,'],
- ['Richard is a software developer and software freedom activist. In 1983',
- 'Since the mid-1990s, Richard has spent most of his time in political',],
+ ["Daniel Kahn Gillmor is a technologist with the ACLU's Speech, Privacy"],
+ ["Edward Snowden is a former intelligence officer who served the CIA,"],
+ [
+ "Richard is a software developer and software freedom activist. In 1983",
+ "Since the mid-1990s, Richard has spent most of his time in political",
+ ],
[],
- ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam',
- 'Ut turpis felis, pulvinar a semper sed, adipiscing id']
+ [
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam",
+ "Ut turpis felis, pulvinar a semper sed, adipiscing id",
+ ],
]
i = 0
- for kspeaker in self.lpspeakers_dict['keynote-speakers']:
- if 'bio' in kspeaker:
+ for kspeaker in self.lpspeakers_dict["keynote-speakers"]:
+ if "bio" in kspeaker:
j = 0
- for p in kspeaker['bio']:
+ for p in kspeaker["bio"]:
p.startswith(keynote_speaker_bios[i][j])
j = j + 1
i = i + 1
-
def test_LPSpeakersMarkdown_speakers_name(self):
"""Testing LPSpeakersMarkdown speakers' names.
"""
- speakers = ['Emmanuel',
- 'George Chriss',
- 'Marianne Corvellec',
- 'Richard Fontana',
- 'Mike Gerwitz',
- 'Bassam Kurdali',
- 'Jonathan Le Lous',
- 'M. C. McGrath',
- 'Deb Nicholson',
- 'Stefano Zacchiroli']
+ speakers = [
+ "Emmanuel",
+ "George Chriss",
+ "Marianne Corvellec",
+ "Richard Fontana",
+ "Mike Gerwitz",
+ "Bassam Kurdali",
+ "Jonathan Le Lous",
+ "M. C. McGrath",
+ "Deb Nicholson",
+ "Stefano Zacchiroli",
+ ]
i = 0
- for kspeaker in self.lpspeakers_dict['speakers']:
- assert_equal(kspeaker['speaker'], speakers[i])
+ for kspeaker in self.lpspeakers_dict["speakers"]:
+ assert_equal(kspeaker["speaker"], speakers[i])
i = i + 1
-
def test_LPSpeakersMarkdown_speakers_id(self):
"""Testing LPSpeakersMarkdown speakers' id.
"""
- speaker_ids = ['emmanuel',
- 'chriss',
- 'corvellec',
- 'fontana',
- 'gerwitz',
- 'kurdali',
- 'lous',
- 'mcgrath',
- 'nicholson',
- 'zacchiroli']
+ speaker_ids = [
+ "emmanuel",
+ "chriss",
+ "corvellec",
+ "fontana",
+ "gerwitz",
+ "kurdali",
+ "lous",
+ "mcgrath",
+ "nicholson",
+ "zacchiroli",
+ ]
i = 0
- for kspeaker in self.lpspeakers_dict['speakers']:
- assert_equal(kspeaker['id'], speaker_ids[i])
+ for kspeaker in self.lpspeakers_dict["speakers"]:
+ assert_equal(kspeaker["id"], speaker_ids[i])
i = i + 1
-
def test_LPSpeakersMarkdown_speakers_imgurl(self):
"""Testing LPSpeakersMarkdown speakers' image url.
"""
speaker_img_urls = [
- '', '',
- '//static.fsf.org/nosvn/libreplanet/speaker-pics/corvellec.jpg',
- '', '',
- '//static.fsf.org/nosvn/libreplanet/speaker-pics/kurdali.png',
- '//static.fsf.org/nosvn/libreplanet/speaker-pics/lelous.jpg',
- '',
- '//static.fsf.org/nosvn/libreplanet/speaker-pics/nicholson.jpg',
- '//static.fsf.org/nosvn/libreplanet/speaker-pics/zacchiroli.jpg'
+ "",
+ "",
+ "//static.fsf.org/nosvn/libreplanet/speaker-pics/corvellec.jpg",
+ "",
+ "",
+ "//static.fsf.org/nosvn/libreplanet/speaker-pics/kurdali.png",
+ "//static.fsf.org/nosvn/libreplanet/speaker-pics/lelous.jpg",
+ "",
+ "//static.fsf.org/nosvn/libreplanet/speaker-pics/nicholson.jpg",
+ "//static.fsf.org/nosvn/libreplanet/speaker-pics/zacchiroli.jpg",
]
i = 0
- for kspeaker in self.lpspeakers_dict['speakers']:
- if 'img_url' in kspeaker:
- assert_equal(kspeaker['img_url'],
- speaker_img_urls[i])
+ for kspeaker in self.lpspeakers_dict["speakers"]:
+ if "img_url" in kspeaker:
+ assert_equal(kspeaker["img_url"], speaker_img_urls[i])
i = i + 1
-
def test_LPSpeakersMarkdown_speakers_imgalt(self):
"""Testing LPSpeakersMarkdown speakers' image alt text.
"""
speaker_img_alts = [
- '', '',
- 'Marianne Corvellec - Photo',
- '', '',
- 'Bassam Kurdali - Photo',
- 'Jonathan Le Lous - Photo',
- '',
- 'Deb Nicholson - Photo',
- 'Stefano Zacchiroli - Photo']
+ "",
+ "",
+ "Marianne Corvellec - Photo",
+ "",
+ "",
+ "Bassam Kurdali - Photo",
+ "Jonathan Le Lous - Photo",
+ "",
+ "Deb Nicholson - Photo",
+ "Stefano Zacchiroli - Photo",
+ ]
i = 0
- for kspeaker in self.lpspeakers_dict['speakers']:
- if 'img_alt' in kspeaker:
- assert_equal(kspeaker['img_alt'],
- speaker_img_alts[i])
+ for kspeaker in self.lpspeakers_dict["speakers"]:
+ if "img_alt" in kspeaker:
+ assert_equal(kspeaker["img_alt"], speaker_img_alts[i])
i = i + 1
-
def test_LPSpeakersMarkdown_speakers_bio(self):
"""Testing LPSpeakersMarkdown speakers' bio.
"""
speaker_bios = [
- ['Emmanuel is a Division III student at Hampshire College, studying how'],
+ ["Emmanuel is a Division III student at Hampshire College, studying how"],
[],
- ['Marianne Corvellec has been a Free Software activist with April'],
- ['Richard Fontana is a lawyer at Red Hat. He leads support for Red Hat\'s'],
+ ["Marianne Corvellec has been a Free Software activist with April"],
+ ["Richard Fontana is a lawyer at Red Hat. He leads support for Red Hat's"],
[],
- ['Bassam is a 3D animator/filmmaker whose 2006 short, Elephants Dream,'],
- ['Jonathan has been involved with the Free Software Movement for ten'],
- ['M. C. is the founder of Transparency Toolkit, a free software project'],
+ ["Bassam is a 3D animator/filmmaker whose 2006 short, Elephants Dream,"],
+ ["Jonathan has been involved with the Free Software Movement for ten"],
+ ["M. C. is the founder of Transparency Toolkit, a free software project"],
[],
- ['Stefano Zacchiroli is Associate Professor of Computer Science at']
+ ["Stefano Zacchiroli is Associate Professor of Computer Science at"],
]
i = 0
- for kspeaker in self.lpspeakers_dict['speakers']:
- if 'bio' in kspeaker:
+ for kspeaker in self.lpspeakers_dict["speakers"]:
+ if "bio" in kspeaker:
j = 0
- for p in kspeaker['bio']:
+ for p in kspeaker["bio"]:
p.startswith(speaker_bios[i][j])
j = j + 1
i = i + 1
-
def test_RenderHTML(self):
"""Testing `RenderHTML` function with LP speakers
"""
- lps_html = RenderHTML(self.lpspeakers_dict, 'speakers')
- print(lps_html) # TODO: Scrape and test html output.
-
+ lps_html = RenderHTML(self.lpspeakers_dict, "speakers")
+ print(lps_html) # TODO: Scrape and test html output.
def teardown(self):
"""Cleans up things after each test in this class."""
pass
-
@classmethod
def teardown_class(self):
"""Purge the mess created by this test."""
# Remove `speakers.ids` file if it exists.
- if path.isfile('speakers.ids'):
- os.remove('speakers.ids')
+ if path.isfile("speakers.ids"):
+ os.remove("speakers.ids")
# Change back to the old cwd
os.chdir(self.old_cwd)
@@ -981,43 +935,43 @@ class TestLPSpeakers(object):
class TestSpeakersAutoLinking(object):
"""Class tests autolinking of speakers in sessions MD.
"""
+
@classmethod
def setup_class(self):
"""Runs before running any tests in this class."""
# Change current working directory to the tests directory.
self.old_cwd = os.getcwd()
- os.chdir('tests')
+ os.chdir("tests")
- self.ids_filename = 'speakers.ids'
- self.noids_filename = 'speakers.noids'
+ self.ids_filename = "speakers.ids"
+ self.noids_filename = "speakers.noids"
- self.SPEAKERS_MD = path.join('files', 'lp-speakers-autolink.md')
+ self.SPEAKERS_MD = path.join("files", "lp-speakers-autolink.md")
self.SPEAKERS_MD_CONTENT = read_file(self.SPEAKERS_MD)
- self.SESSIONS_MD = path.join('files', 'lp-sessions-autolink.md')
+ self.SESSIONS_MD = path.join("files", "lp-sessions-autolink.md")
self.SESSIONS_MD_CONTENT = read_file(self.SESSIONS_MD)
-
def setup(self):
"""Runs before each test in this class."""
pass
-
def test_sessions_autolinking(self):
"""Testing autolinking of speakers in sessions. """
self.speakers_markdown = LPSpeakersMarkdown()
- self.lpspeakers_dict = self.speakers_markdown(
- self.SPEAKERS_MD_CONTENT)
+ self.lpspeakers_dict = self.speakers_markdown(self.SPEAKERS_MD_CONTENT)
- assert (path.isfile(self.ids_filename) and
- json.loads(read_file(self.ids_filename)))
+ assert path.isfile(self.ids_filename) and json.loads(
+ read_file(self.ids_filename)
+ )
self.sessions_markdown = LPSMarkdown()
self.lps_dict = self.sessions_markdown(self.SESSIONS_MD_CONTENT)
- assert (path.isfile(self.noids_filename) and
- json.loads(read_file(self.noids_filename)))
+ assert path.isfile(self.noids_filename) and json.loads(
+ read_file(self.noids_filename)
+ )
speakers = [
[
@@ -1028,32 +982,25 @@ class TestSpeakersAutoLinking(object):
'<a href="speakers.html#nicholson">Deb Nicholson</a>',
'<a href="speakers.html#fontana">Richard Fontana</a>',
],
- [
- 'Paige Peterson', 'MaidSoft'
- ],
- [
- 'George Chriss',
- 'Kat Walsh (moderator)',
- ],
+ ["Paige Peterson", "MaidSoft"],
+ ["George Chriss", "Kat Walsh (moderator)",],
[
'<a href="speakers.html#zacchiroli">Stefano Zacchiroli</a>',
- 'Debian', 'OSI', 'IRILL'
+ "Debian",
+ "OSI",
+ "IRILL",
],
[
'<a href="speakers.html#corvellec">Marianne Corvellec</a>',
- 'April and Jonathan Le Lous',
- 'April'
- ],
- [
- '<a href="speakers.html#brown">Michaela R. Brown</a>',
+ "April and Jonathan Le Lous",
+ "April",
],
+ ['<a href="speakers.html#brown">Michaela R. Brown</a>',],
+ ['<a href="speakers.html#gott">Molly Gott</a>'],
[
- '<a href="speakers.html#gott">Molly Gott</a>'
- ],
- [
- 'Christopher Webber',
+ "Christopher Webber",
'<a href="speakers.html#thompson">David Thompson</a>',
- 'Ludovic Courtès',
+ "Ludovic Courtès",
],
]
@@ -1061,20 +1008,19 @@ class TestSpeakersAutoLinking(object):
for lps_timeslots in self.lps_dict.values():
for lps_sessions in lps_timeslots.values():
for session_info in lps_sessions.values():
- assert_equal(session_info['speakers'], speakers[i])
+ assert_equal(session_info["speakers"], speakers[i])
i = i + 1
speakers_noids = [
- 'Paige Peterson',
- 'George Chriss',
- 'Kat Walsh',
- 'Jonathan Le Lous',
- 'Christopher Webber',
- 'Ludovic Courtès',
+ "Paige Peterson",
+ "George Chriss",
+ "Kat Walsh",
+ "Jonathan Le Lous",
+ "Christopher Webber",
+ "Ludovic Courtès",
]
assert_equal(json_read(self.noids_filename), speakers_noids)
-
def test_sessions_autolinking_nospeakerids(self):
"""Testing autolinked speakrs in sessions MD when speakers.id not available. """
@@ -1083,85 +1029,58 @@ class TestSpeakersAutoLinking(object):
self.sessions_markdown = LPSMarkdown()
self.lps_dict = self.sessions_markdown(self.SESSIONS_MD_CONTENT)
- assert (path.isfile(self.noids_filename) and
- json.loads(read_file(self.noids_filename)))
+ assert path.isfile(self.noids_filename) and json.loads(
+ read_file(self.noids_filename)
+ )
speakers = [
- [
- 'Edward Snowden',
- 'Daniel Kahn Gillmor',
- ],
- [
- 'Deb Nicholson',
- 'Richard Fontana',
- ],
- [
- 'Paige Peterson', 'MaidSoft'
- ],
- [
- 'George Chriss',
- 'Kat Walsh (moderator)',
- ],
- [
- 'Stefano Zacchiroli',
- 'Debian', 'OSI', 'IRILL'
- ],
- [
- 'Marianne Corvellec',
- 'April and Jonathan Le Lous',
- 'April'
- ],
- [
- 'Michaela R. Brown',
- ],
- [
- 'Molly Gott'
- ],
- [
- 'Christopher Webber',
- 'David Thompson',
- 'Ludovic Courtès',
- ],
+ ["Edward Snowden", "Daniel Kahn Gillmor",],
+ ["Deb Nicholson", "Richard Fontana",],
+ ["Paige Peterson", "MaidSoft"],
+ ["George Chriss", "Kat Walsh (moderator)",],
+ ["Stefano Zacchiroli", "Debian", "OSI", "IRILL"],
+ ["Marianne Corvellec", "April and Jonathan Le Lous", "April"],
+ ["Michaela R. Brown",],
+ ["Molly Gott"],
+ ["Christopher Webber", "David Thompson", "Ludovic Courtès",],
]
i = 0
for lps_timeslots in self.lps_dict.values():
for lps_sessions in lps_timeslots.values():
for session_info in lps_sessions.values():
- assert_equal(session_info['speakers'], speakers[i])
+ assert_equal(session_info["speakers"], speakers[i])
i = i + 1
speakers_noids = [
- 'Edward Snowden',
- 'Daniel Kahn Gillmor',
- 'Deb Nicholson',
- 'Richard Fontana',
- 'Paige Peterson',
- 'George Chriss',
- 'Kat Walsh',
- 'Stefano Zacchiroli',
- 'Marianne Corvellec',
- 'Jonathan Le Lous',
- 'Michaela R. Brown',
- 'Molly Gott',
- 'Christopher Webber',
- 'David Thompson',
- 'Ludovic Courtès',
+ "Edward Snowden",
+ "Daniel Kahn Gillmor",
+ "Deb Nicholson",
+ "Richard Fontana",
+ "Paige Peterson",
+ "George Chriss",
+ "Kat Walsh",
+ "Stefano Zacchiroli",
+ "Marianne Corvellec",
+ "Jonathan Le Lous",
+ "Michaela R. Brown",
+ "Molly Gott",
+ "Christopher Webber",
+ "David Thompson",
+ "Ludovic Courtès",
]
assert_equal(json_read(self.noids_filename), speakers_noids)
-
def teardown(self):
"""Cleans up things after each test in this class."""
# Remove `speakers.ids` file if it exists.
if path.isfile(self.ids_filename):
- os.remove(self.ids_filename)
+ os.remove(self.ids_filename)
# Remove `speakers.noids` file if it exists.
if path.isfile(self.noids_filename):
- os.remove(self.noids_filename)
-
+ os.remove(self.noids_filename)
@classmethod
def teardown_class(self):