lpschedule-generator

libreplanet schedule generator - ricketyspace.net/lpschedule-generator
git clone git://git.ricketyspace.net/lpschedule-generator.git
Log | Files | Refs

commit 8ca7c73df5994a30f3b1070f8c000beef454849e
parent 067cba74f598e596411e7006890646600397d767
Author: rsiddharth <rsd@gnu.org>
Date:   Sat, 13 Jul 2019 18:34:09 -0400

lps_gen.py: Add template_read.

* lps_gen.py (template_read): New function.
* tests/test_lps_gen.py (TestTemplates): New test class.

Diffstat:
lps_gen.py | 10++++++++++
tests/test_lps_gen.py | 14++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/lps_gen.py b/lps_gen.py @@ -10,6 +10,7 @@ import json import re import sys +import pkg_resources as pkgr import pytz from argparse import ArgumentParser @@ -92,6 +93,15 @@ def json_read(filename): object_pairs_hook=OrderedDict) +def template_read(name): + """Return template as `str`. + """ + p = 'lpschedule_generator' + r = 'data/{}'.format(name) + + return pkgr.resource_string(p, r).decode('utf-8') + + class LPiCal(object): """Used for producing iCal for LP schedule. """ diff --git a/tests/test_lps_gen.py b/tests/test_lps_gen.py @@ -100,6 +100,20 @@ class TestJSONUtils(object): os.chdir(self.old_cwd) +class TestTemplates(object): + """Petty tests for lp templates. + """ + + def test_read(self): + t = template_read('schedule.jinja2') + assert type(t) is str + assert len(t) > 0 + + t = template_read('speakers.jinja2') + assert type(t) is str + assert len(t) > 0 + + class TestLPiCal(object): """ Testing LPiCal class.