Browse Source

Update test

pull/232/head
Oliverpool 9 years ago
parent
commit
d304578ca0
  1. 2
      test/test_content/custom.control
  2. 2
      test/test_content/custom.source
  3. 2
      test/test_content/customzipped.control
  4. 2
      test/test_content/customzipped.source
  5. 2
      test/test_content/cwd.control
  6. 4
      test/test_content/cwd_list.control
  7. 2
      test/test_content/datadir/python/content/customplugin.py
  8. BIN
      test/test_content/datadir_zippedcontent/python/content
  9. 2
      test/test_content/glob.control
  10. 12
      test/test_content/include.control
  11. 24
      test/test_content/sections.control
  12. 16
      test/test_content/setcounter.control
  13. 8
      test/test_content/songs.control
  14. 12
      test/test_content/songsection.control
  15. 54
      test/test_content/sort.control
  16. 38
      test/test_content/test_content.py
  17. 6
      test/test_content/tex.control

2
test/test_content/custom.control

@ -1 +1 @@
- "{'customname:': ''}"
- customname: ''

2
test/test_content/custom.source

@ -1 +1 @@
- customname:
- customname: ''

2
test/test_content/customzipped.control

@ -1 +1 @@
- "{'customzippedname:': ''}"
- customzippedname: ''

2
test/test_content/customzipped.source

@ -1 +1 @@
- customzippedname:
- customzippedname: ''

2
test/test_content/cwd.control

@ -1 +1 @@
- subdir/chordpro.csg
- song: datadir/songs/subdir/chordpro.csg

4
test/test_content/cwd_list.control

@ -1,2 +1,2 @@
- subdir/chordpro.csg
- exsong.sg
- song: datadir/songs/subdir/chordpro.csg
- song: datadir/songs/exsong.sg

2
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()])

BIN
test/test_content/datadir_zippedcontent/python/content

Binary file not shown.

2
test/test_content/glob.control

@ -1 +1 @@
- chordpro.csg
- song: datadir/songs/chordpro.csg

12
test/test_content/include.control

@ -1,6 +1,6 @@
- exsong.sg
- chordpro.csg
- subdir/chordpro.csg
- chordpro.csg
- subdir/chordpro.csg
- exsong.sg
- 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

24
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}
- 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

16
test/test_content/setcounter.control

@ -1,4 +1,12 @@
- setcounter{songnum}{101}
- setcounter{songnum}{1}
- setcounter{songnum}{5}
- setcounter{counter_name}{-1}
- setcounter:
name: songnum
value: 101
- setcounter:
name: songnum
value: 1
- setcounter:
name: songnum
value: 5
- setcounter:
name: counter_name
value: -1

8
test/test_content/songs.control

@ -1,4 +1,4 @@
- exsong.sg
- texsong.tsg
- chordpro.csg
- subdir/chordpro.csg
- song: datadir/songs/exsong.sg
- song: datadir/songs/texsong.tsg
- song: datadir/songs/chordpro.csg
- song: datadir/songs/subdir/chordpro.csg

12
test/test_content/songsection.control

@ -1,6 +1,6 @@
- songsection{Traditional}
- exsong.sg
- songchapter{English}
- texsong.tsg
- chordpro.csg
- exsong.sg
- songsection: Traditional
- song: datadir/songs/exsong.sg
- songchapter: English
- song: datadir/songs/texsong.tsg
- song: datadir/songs/chordpro.csg
- song: datadir/songs/exsong.sg

54
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

38
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):

6
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
- tex: test/test_content/datadir/songs/texfile.tex
- tex: test/test_content/datadir/songs/texfile.tex
- tex: test/test_content/datadir/songs/texfile.tex
Loading…
Cancel
Save