diff --git a/test/test_content/custom.control b/test/test_content/custom.control index b549c6a3..52e29862 100644 --- a/test/test_content/custom.control +++ b/test/test_content/custom.control @@ -1 +1 @@ -- "{'customname:': ''}" \ No newline at end of file +- customname: '' \ No newline at end of file diff --git a/test/test_content/custom.source b/test/test_content/custom.source index ded39db8..52e29862 100644 --- a/test/test_content/custom.source +++ b/test/test_content/custom.source @@ -1 +1 @@ -- customname: \ No newline at end of file +- customname: '' \ No newline at end of file diff --git a/test/test_content/customzipped.control b/test/test_content/customzipped.control index 6d3fd533..8a6bbc0d 100644 --- a/test/test_content/customzipped.control +++ b/test/test_content/customzipped.control @@ -1 +1 @@ -- "{'customzippedname:': ''}" \ No newline at end of file +- customzippedname: '' diff --git a/test/test_content/customzipped.source b/test/test_content/customzipped.source index 7c67530d..8a6bbc0d 100644 --- a/test/test_content/customzipped.source +++ b/test/test_content/customzipped.source @@ -1 +1 @@ -- customzippedname: +- customzippedname: '' diff --git a/test/test_content/cwd.control b/test/test_content/cwd.control index e1ed6693..9ea8e105 100644 --- a/test/test_content/cwd.control +++ b/test/test_content/cwd.control @@ -1 +1 @@ -- subdir/chordpro.csg \ No newline at end of file +- song: datadir/songs/subdir/chordpro.csg \ No newline at end of file diff --git a/test/test_content/cwd_list.control b/test/test_content/cwd_list.control index 3c9377a4..c52db118 100644 --- a/test/test_content/cwd_list.control +++ b/test/test_content/cwd_list.control @@ -1,2 +1,2 @@ -- subdir/chordpro.csg -- exsong.sg \ No newline at end of file +- song: datadir/songs/subdir/chordpro.csg +- song: datadir/songs/exsong.sg \ No newline at end of file diff --git a/test/test_content/datadir/python/content/customplugin.py b/test/test_content/datadir/python/content/customplugin.py index e7333b30..d579aca8 100755 --- a/test/test_content/datadir/python/content/customplugin.py +++ b/test/test_content/datadir/python/content/customplugin.py @@ -6,7 +6,7 @@ class FakeContent(ContentItem): """Fake content.""" def file_entry(self): - return {'customname:':''} + return {'customname':''} def parse(keyword, argument, config): return ContentList([FakeContent()]) diff --git a/test/test_content/datadir_zippedcontent/python/content b/test/test_content/datadir_zippedcontent/python/content index a333d318..9c4371ff 100644 Binary files a/test/test_content/datadir_zippedcontent/python/content and b/test/test_content/datadir_zippedcontent/python/content differ diff --git a/test/test_content/glob.control b/test/test_content/glob.control index 177bc945..2cb022f2 100644 --- a/test/test_content/glob.control +++ b/test/test_content/glob.control @@ -1 +1 @@ -- chordpro.csg \ No newline at end of file +- song: datadir/songs/chordpro.csg \ No newline at end of file diff --git a/test/test_content/include.control b/test/test_content/include.control index 6aba97ae..4b39aced 100644 --- a/test/test_content/include.control +++ b/test/test_content/include.control @@ -1,6 +1,6 @@ -- exsong.sg -- chordpro.csg -- subdir/chordpro.csg -- chordpro.csg -- subdir/chordpro.csg -- exsong.sg \ No newline at end of file +- song: datadir/songs/exsong.sg +- song: datadir/songs/chordpro.csg +- song: datadir/songs/subdir/chordpro.csg +- song: datadir/songs/chordpro.csg +- song: datadir/songs/subdir/chordpro.csg +- song: datadir/songs/exsong.sg \ No newline at end of file diff --git a/test/test_content/sections.control b/test/test_content/sections.control index 5a87c67c..f96345f2 100644 --- a/test/test_content/sections.control +++ b/test/test_content/sections.control @@ -1,11 +1,13 @@ -- section{First Section!} -- section{Named section} -- section[section_short_name]{Section with short name} -- section*{Section* with short name} -- part{part section test} -- chapter{chapter section test} -- section{section section test} -- subsection{subsection section test} -- subsubsection{subsubsection section test} -- paragraph{paragraph section test} -- subparagraph{subparagraph section test} \ No newline at end of file +- section: First Section! +- section: Named section +- section: + name: Section with short name + short: section_short_name +- section*: Section* with short name +- part: part section test +- chapter: chapter section test +- section: section section test +- subsection: subsection section test +- subsubsection: subsubsection section test +- paragraph: paragraph section test +- subparagraph: subparagraph section test \ No newline at end of file diff --git a/test/test_content/setcounter.control b/test/test_content/setcounter.control index dff14be1..453c67e4 100644 --- a/test/test_content/setcounter.control +++ b/test/test_content/setcounter.control @@ -1,4 +1,12 @@ -- setcounter{songnum}{101} -- setcounter{songnum}{1} -- setcounter{songnum}{5} -- setcounter{counter_name}{-1} \ No newline at end of file +- setcounter: + name: songnum + value: 101 +- setcounter: + name: songnum + value: 1 +- setcounter: + name: songnum + value: 5 +- setcounter: + name: counter_name + value: -1 \ No newline at end of file diff --git a/test/test_content/songs.control b/test/test_content/songs.control index 6ad0622a..61723113 100644 --- a/test/test_content/songs.control +++ b/test/test_content/songs.control @@ -1,4 +1,4 @@ -- exsong.sg -- texsong.tsg -- chordpro.csg -- subdir/chordpro.csg \ No newline at end of file +- song: datadir/songs/exsong.sg +- song: datadir/songs/texsong.tsg +- song: datadir/songs/chordpro.csg +- song: datadir/songs/subdir/chordpro.csg \ No newline at end of file diff --git a/test/test_content/songsection.control b/test/test_content/songsection.control index 81197f08..4bbd48f8 100644 --- a/test/test_content/songsection.control +++ b/test/test_content/songsection.control @@ -1,6 +1,6 @@ -- songsection{Traditional} -- exsong.sg -- songchapter{English} -- texsong.tsg -- chordpro.csg -- exsong.sg \ No newline at end of file +- songsection: Traditional +- song: datadir/songs/exsong.sg +- songchapter: English +- song: datadir/songs/texsong.tsg +- song: datadir/songs/chordpro.csg +- song: datadir/songs/exsong.sg \ No newline at end of file diff --git a/test/test_content/sort.control b/test/test_content/sort.control index a7430273..4778a6e5 100644 --- a/test/test_content/sort.control +++ b/test/test_content/sort.control @@ -1,27 +1,27 @@ -- section{Title} -- "@TEST_FOLDER@/datadir_sort/path1_title1_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path1_title1_author2.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title1_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title1_author2.csg" -- "@TEST_FOLDER@/datadir_sort/path1_title2_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path1_title2_author2.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title2_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title2_author2.csg" -- section{Author, Title} -- "@TEST_FOLDER@/datadir_sort/path1_title1_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title1_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path1_title2_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title2_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path1_title1_author2.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title1_author2.csg" -- "@TEST_FOLDER@/datadir_sort/path1_title2_author2.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title2_author2.csg" -- section{Path, Title} -- "@TEST_FOLDER@/datadir_sort/path1_title1_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path1_title1_author2.csg" -- "@TEST_FOLDER@/datadir_sort/path1_title2_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path1_title2_author2.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title1_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title1_author2.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title2_author1.csg" -- "@TEST_FOLDER@/datadir_sort/path2_title2_author2.csg" +- section: Title +- song: datadir_sort/path1_title1_author1.csg +- song: datadir_sort/path1_title1_author2.csg +- song: datadir_sort/path2_title1_author1.csg +- song: datadir_sort/path2_title1_author2.csg +- song: datadir_sort/path1_title2_author1.csg +- song: datadir_sort/path1_title2_author2.csg +- song: datadir_sort/path2_title2_author1.csg +- song: datadir_sort/path2_title2_author2.csg +- section: Author, Title +- song: datadir_sort/path1_title1_author1.csg +- song: datadir_sort/path2_title1_author1.csg +- song: datadir_sort/path1_title2_author1.csg +- song: datadir_sort/path2_title2_author1.csg +- song: datadir_sort/path1_title1_author2.csg +- song: datadir_sort/path2_title1_author2.csg +- song: datadir_sort/path1_title2_author2.csg +- song: datadir_sort/path2_title2_author2.csg +- section: Path, Title +- song: datadir_sort/path1_title1_author1.csg +- song: datadir_sort/path1_title1_author2.csg +- song: datadir_sort/path1_title2_author1.csg +- song: datadir_sort/path1_title2_author2.csg +- song: datadir_sort/path2_title1_author1.csg +- song: datadir_sort/path2_title1_author2.csg +- song: datadir_sort/path2_title2_author1.csg +- song: datadir_sort/path2_title2_author2.csg diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 1ca8c67d..14a56800 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -10,7 +10,6 @@ import yaml from pkg_resources import resource_filename from patacrep import content, files -from patacrep.content import song, section, setcounter, songsection, tex from patacrep.songbook import prepare_songbook from .. import logging_reduced @@ -55,16 +54,13 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): with logging_reduced('patacrep.content.song'): expandedlist = content.process_content(sbcontent, config) - sourcelist = [cls._clean_path(elem) for elem in expandedlist] + sourcelist = [cls._clean_path(elem.file_entry()) for elem in expandedlist] controlname = "{}.control".format(base) if not os.path.exists(controlname): - raise Exception("Missing control:" + str(sourcelist).replace("'", '"')) + raise Exception("Missing control:" + str(controlname).replace("'", '"')) with open(controlname, mode="r", encoding="utf8") as controlfile: - controllist = [ - elem.replace("@TEST_FOLDER@", files.path2posix(resource_filename(__name__, ""))) - for elem in yaml.load(controlfile) - ] + controllist = yaml.load(controlfile) self.assertEqual(controllist, sourcelist) @@ -75,25 +71,15 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): @classmethod def _clean_path(cls, elem): - """Shorten the path relative to the `songs` directory""" - - latex_command_classes = ( - section.Section, - songsection.SongSection, - setcounter.CounterSetter, - ) - if isinstance(elem, latex_command_classes): - return elem.render(None)[1:] - - elif 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, tex.LaTeX): - return files.path2posix(elem.filename) - - else: - return str(elem.file_entry()) + """Shorten the path relative to the test directory""" + if not isinstance(elem, dict): + return elem + + test_path = files.path2posix(resource_filename(__name__, ""))+"/" + for key in ['song', 'tex']: + if key in elem: + elem[key] = os.path.normpath(elem[key]).replace(test_path, "") + return elem @classmethod def _generate_config(cls, sbcontent, outputdir, base): diff --git a/test/test_content/tex.control b/test/test_content/tex.control index 47d8fe2c..6a9a4749 100644 --- a/test/test_content/tex.control +++ b/test/test_content/tex.control @@ -1,3 +1,3 @@ -- test/test_content/datadir/songs/texfile.tex -- test/test_content/datadir/songs/texfile.tex -- test/test_content/datadir/songs/texfile.tex \ No newline at end of file +- tex: test/test_content/datadir/songs/texfile.tex +- tex: test/test_content/datadir/songs/texfile.tex +- tex: test/test_content/datadir/songs/texfile.tex \ No newline at end of file