From d304578ca07ae56f5164b2e0afaabbdfd4cff6d3 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Wed, 20 Jul 2016 21:01:20 +0200 Subject: [PATCH] Update test --- test/test_content/custom.control | 2 +- test/test_content/custom.source | 2 +- test/test_content/customzipped.control | 2 +- test/test_content/customzipped.source | 2 +- test/test_content/cwd.control | 2 +- test/test_content/cwd_list.control | 4 +- .../datadir/python/content/customplugin.py | 2 +- .../datadir_zippedcontent/python/content | Bin 420 -> 418 bytes test/test_content/glob.control | 2 +- test/test_content/include.control | 12 ++-- test/test_content/sections.control | 24 ++++---- test/test_content/setcounter.control | 16 ++++-- test/test_content/songs.control | 8 +-- test/test_content/songsection.control | 12 ++-- test/test_content/sort.control | 54 +++++++++--------- test/test_content/test_content.py | 38 ++++-------- test/test_content/tex.control | 6 +- 17 files changed, 92 insertions(+), 96 deletions(-) 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 a333d318a650a18aa11e723f9930df3f4a98577d..9c4371ffabcccf1b23b62812e5283125317ec209 100644 GIT binary patch delta 337 zcmZ3&yogygz?+#xgn@y9gF(9Ki^sW}vqK&Mc?FCN45AD&lM@&v>Ny#hueSGxUjyRO z3T_5QmKV$n3}7O+-`D$yfk4~)pQ6rsxeMR$M|{|_LPsaGz_xSB1wXGFHHI^_R{yx4 zn~Z?R@p1Q|zUV9cA-+*kw5+gq`PTwzXucFBNeLE)Wo1-DvQx?SZ6ibD^QY z;l$Yfo^^Y5)hF+$Z{<%tyF%jk3Jt}tUCVCjhAXnI4r=nzYpl9_=?$xna(C3hwQ4^N z7O~~(d^@cj`?@7;x`&+8ypxB^P0w^T|28sw^kVAatoTrSrzc+JB^ zk+*!7t~JTs7qUNh>g?}s9fyO<_q{*&_w&oIA8+hEaCiTcsXH#zGX{8zGcw6BV+oV!Z delta 339 zcmZ3)yo6acz?+#xgn@y9gW=1T#~#U22lo?$#IMl^_&dMJQbDUd_Y`U z!Og(P@`9Ox0ZiofJ7yg=5ODo&b#y^*u7PF4!qpe1ITUbvhA)*!?C5vRldBH2+aX+J(LbLxUe4_gHzXHJ1v^n!~z2;%iIY_1!ZI(+sXz zC*4^8y7A(*?@u$B>aQ1sPL>o&elE(o#P6cS+al3L^Fuf$oUjbYi(2J&z{qHI>Yc1f ze9T!F(hlWSE{&EfxMVr0ZG!UI53yeiH*AhSRxOj3x>0l1q91}vNB_5+;=X4m%WHb) z=qr}XX=h4zW_@1%srGeDZHUvG_*zyJV7n2LM= 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