Browse Source

Update test

pull/232/head
Oliverpool 8 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 - song: datadir/songs/subdir/chordpro.csg
- exsong.sg - song: datadir/songs/exsong.sg

2
test/test_content/datadir/python/content/customplugin.py

@ -6,7 +6,7 @@ class FakeContent(ContentItem):
"""Fake content.""" """Fake content."""
def file_entry(self): def file_entry(self):
return {'customname:':''} return {'customname':''}
def parse(keyword, argument, config): def parse(keyword, argument, config):
return ContentList([FakeContent()]) 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 - song: datadir/songs/exsong.sg
- chordpro.csg - song: datadir/songs/chordpro.csg
- subdir/chordpro.csg - song: datadir/songs/subdir/chordpro.csg
- chordpro.csg - song: datadir/songs/chordpro.csg
- subdir/chordpro.csg - song: datadir/songs/subdir/chordpro.csg
- exsong.sg - song: datadir/songs/exsong.sg

24
test/test_content/sections.control

@ -1,11 +1,13 @@
- section{First Section!} - section: First Section!
- section{Named section} - section: Named section
- section[section_short_name]{Section with short name} - section:
- section*{Section* with short name} name: Section with short name
- part{part section test} short: section_short_name
- chapter{chapter section test} - section*: Section* with short name
- section{section section test} - part: part section test
- subsection{subsection section test} - chapter: chapter section test
- subsubsection{subsubsection section test} - section: section section test
- paragraph{paragraph section test} - subsection: subsection section test
- subparagraph{subparagraph 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:
- setcounter{songnum}{1} name: songnum
- setcounter{songnum}{5} value: 101
- setcounter{counter_name}{-1} - 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 - song: datadir/songs/exsong.sg
- texsong.tsg - song: datadir/songs/texsong.tsg
- chordpro.csg - song: datadir/songs/chordpro.csg
- subdir/chordpro.csg - song: datadir/songs/subdir/chordpro.csg

12
test/test_content/songsection.control

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

54
test/test_content/sort.control

@ -1,27 +1,27 @@
- section{Title} - section: Title
- "@TEST_FOLDER@/datadir_sort/path1_title1_author1.csg" - song: datadir_sort/path1_title1_author1.csg
- "@TEST_FOLDER@/datadir_sort/path1_title1_author2.csg" - song: datadir_sort/path1_title1_author2.csg
- "@TEST_FOLDER@/datadir_sort/path2_title1_author1.csg" - song: datadir_sort/path2_title1_author1.csg
- "@TEST_FOLDER@/datadir_sort/path2_title1_author2.csg" - song: datadir_sort/path2_title1_author2.csg
- "@TEST_FOLDER@/datadir_sort/path1_title2_author1.csg" - song: datadir_sort/path1_title2_author1.csg
- "@TEST_FOLDER@/datadir_sort/path1_title2_author2.csg" - song: datadir_sort/path1_title2_author2.csg
- "@TEST_FOLDER@/datadir_sort/path2_title2_author1.csg" - song: datadir_sort/path2_title2_author1.csg
- "@TEST_FOLDER@/datadir_sort/path2_title2_author2.csg" - song: datadir_sort/path2_title2_author2.csg
- section{Author, Title} - section: Author, Title
- "@TEST_FOLDER@/datadir_sort/path1_title1_author1.csg" - song: datadir_sort/path1_title1_author1.csg
- "@TEST_FOLDER@/datadir_sort/path2_title1_author1.csg" - song: datadir_sort/path2_title1_author1.csg
- "@TEST_FOLDER@/datadir_sort/path1_title2_author1.csg" - song: datadir_sort/path1_title2_author1.csg
- "@TEST_FOLDER@/datadir_sort/path2_title2_author1.csg" - song: datadir_sort/path2_title2_author1.csg
- "@TEST_FOLDER@/datadir_sort/path1_title1_author2.csg" - song: datadir_sort/path1_title1_author2.csg
- "@TEST_FOLDER@/datadir_sort/path2_title1_author2.csg" - song: datadir_sort/path2_title1_author2.csg
- "@TEST_FOLDER@/datadir_sort/path1_title2_author2.csg" - song: datadir_sort/path1_title2_author2.csg
- "@TEST_FOLDER@/datadir_sort/path2_title2_author2.csg" - song: datadir_sort/path2_title2_author2.csg
- section{Path, Title} - section: Path, Title
- "@TEST_FOLDER@/datadir_sort/path1_title1_author1.csg" - song: datadir_sort/path1_title1_author1.csg
- "@TEST_FOLDER@/datadir_sort/path1_title1_author2.csg" - song: datadir_sort/path1_title1_author2.csg
- "@TEST_FOLDER@/datadir_sort/path1_title2_author1.csg" - song: datadir_sort/path1_title2_author1.csg
- "@TEST_FOLDER@/datadir_sort/path1_title2_author2.csg" - song: datadir_sort/path1_title2_author2.csg
- "@TEST_FOLDER@/datadir_sort/path2_title1_author1.csg" - song: datadir_sort/path2_title1_author1.csg
- "@TEST_FOLDER@/datadir_sort/path2_title1_author2.csg" - song: datadir_sort/path2_title1_author2.csg
- "@TEST_FOLDER@/datadir_sort/path2_title2_author1.csg" - song: datadir_sort/path2_title2_author1.csg
- "@TEST_FOLDER@/datadir_sort/path2_title2_author2.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 pkg_resources import resource_filename
from patacrep import content, files from patacrep import content, files
from patacrep.content import song, section, setcounter, songsection, tex
from patacrep.songbook import prepare_songbook from patacrep.songbook import prepare_songbook
from .. import logging_reduced from .. import logging_reduced
@ -55,16 +54,13 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
with logging_reduced('patacrep.content.song'): with logging_reduced('patacrep.content.song'):
expandedlist = content.process_content(sbcontent, config) 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) controlname = "{}.control".format(base)
if not os.path.exists(controlname): 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: with open(controlname, mode="r", encoding="utf8") as controlfile:
controllist = [ controllist = yaml.load(controlfile)
elem.replace("@TEST_FOLDER@", files.path2posix(resource_filename(__name__, "")))
for elem in yaml.load(controlfile)
]
self.assertEqual(controllist, sourcelist) self.assertEqual(controllist, sourcelist)
@ -75,25 +71,15 @@ 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 test directory"""
if not isinstance(elem, dict):
latex_command_classes = ( return elem
section.Section,
songsection.SongSection, test_path = files.path2posix(resource_filename(__name__, ""))+"/"
setcounter.CounterSetter, for key in ['song', 'tex']:
) if key in elem:
if isinstance(elem, latex_command_classes): elem[key] = os.path.normpath(elem[key]).replace(test_path, "")
return elem.render(None)[1:] return elem
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())
@classmethod @classmethod
def _generate_config(cls, sbcontent, outputdir, base): def _generate_config(cls, sbcontent, outputdir, base):

6
test/test_content/tex.control

@ -1,3 +1,3 @@
- test/test_content/datadir/songs/texfile.tex - tex: test/test_content/datadir/songs/texfile.tex
- test/test_content/datadir/songs/texfile.tex - tex: test/test_content/datadir/songs/texfile.tex
- test/test_content/datadir/songs/texfile.tex - tex: test/test_content/datadir/songs/texfile.tex
Loading…
Cancel
Save