From 6c46368d31f2fde1962d3a8a48791ba1cf257c5e Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 20 Nov 2015 14:25:53 +0100 Subject: [PATCH] Add SongSection tests --- test/test_content/songsection.control | 1 + test/test_content/songsection.source | 6 ++++++ test/test_content/test_content.py | 12 ++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 test/test_content/songsection.control create mode 100644 test/test_content/songsection.source diff --git a/test/test_content/songsection.control b/test/test_content/songsection.control new file mode 100644 index 00000000..69dd034b --- /dev/null +++ b/test/test_content/songsection.control @@ -0,0 +1 @@ +["songsection:Traditional", "exsong.sg", "songchapter:English", "texsong.tsg", "chordpro.csg", "exsong.sg"] \ No newline at end of file diff --git a/test/test_content/songsection.source b/test/test_content/songsection.source new file mode 100644 index 00000000..089322c4 --- /dev/null +++ b/test/test_content/songsection.source @@ -0,0 +1,6 @@ +[["songsection", "Traditional"], + "exsong.sg", + ["songchapter", "English"], + "texsong.tsg", + "chordpro.csg", + "exsong.sg"] \ No newline at end of file diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 8b279793..ec164a52 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -9,8 +9,7 @@ import json from patacrep.songs import DataSubpath, DEFAULT_CONFIG from patacrep import content, files -from patacrep.content.song import SongRenderer -from patacrep.content.section import Section +from patacrep.content import song, section, songsection from .. import dynamic # pylint: disable=unused-import @@ -71,14 +70,19 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): @classmethod def _clean_path(cls, elem): """Shorten the path relative to the `songs` directory""" - if isinstance(elem, SongRenderer): + if isinstance(elem, song.SongRenderer): songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs') return files.path2posix(files.relpath(elem.song.fullpath, songpath)) - elif isinstance(elem, Section): + + elif isinstance(elem, section.Section): if elem.short is None: return "{}:{}".format(elem.keyword, elem.name) else: return "{}:({}){}".format(elem.keyword, elem.short, elem.name) + + elif isinstance(elem, songsection.SongSection): + return "{}:{}".format(elem.keyword, elem.name) + else: raise Exception(elem)