Browse Source

Add SongSection tests

pull/179/head
Oliverpool 9 years ago
parent
commit
6c46368d31
  1. 1
      test/test_content/songsection.control
  2. 6
      test/test_content/songsection.source
  3. 12
      test/test_content/test_content.py

1
test/test_content/songsection.control

@ -0,0 +1 @@
["songsection:Traditional", "exsong.sg", "songchapter:English", "texsong.tsg", "chordpro.csg", "exsong.sg"]

6
test/test_content/songsection.source

@ -0,0 +1,6 @@
[["songsection", "Traditional"],
"exsong.sg",
["songchapter", "English"],
"texsong.tsg",
"chordpro.csg",
"exsong.sg"]

12
test/test_content/test_content.py

@ -9,8 +9,7 @@ import json
from patacrep.songs import DataSubpath, DEFAULT_CONFIG from patacrep.songs import DataSubpath, DEFAULT_CONFIG
from patacrep import content, files from patacrep import content, files
from patacrep.content.song import SongRenderer from patacrep.content import song, section, songsection
from patacrep.content.section import Section
from .. import dynamic # pylint: disable=unused-import from .. import dynamic # pylint: disable=unused-import
@ -71,14 +70,19 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
@classmethod @classmethod
def _clean_path(cls, elem): def _clean_path(cls, elem):
"""Shorten the path relative to the `songs` directory""" """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') songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs')
return files.path2posix(files.relpath(elem.song.fullpath, songpath)) return files.path2posix(files.relpath(elem.song.fullpath, songpath))
elif isinstance(elem, Section):
elif isinstance(elem, section.Section):
if elem.short is None: if elem.short is None:
return "{}:{}".format(elem.keyword, elem.name) return "{}:{}".format(elem.keyword, elem.name)
else: else:
return "{}:({}){}".format(elem.keyword, elem.short, elem.name) return "{}:({}){}".format(elem.keyword, elem.short, elem.name)
elif isinstance(elem, songsection.SongSection):
return "{}:{}".format(elem.keyword, elem.name)
else: else:
raise Exception(elem) raise Exception(elem)

Loading…
Cancel
Save