Browse Source

Some more tests

pull/97/head
Louis 9 years ago
parent
commit
b4e06bf77d
  1. 41
      test/test_authors.py

41
test/test_authors.py

@ -15,20 +15,40 @@ SPLIT_AUTHORS_DATA = [
("Cher", ("Cher", "")), ("Cher", ("Cher", "")),
("Red~Hot~Chili~Peppers", ("Red~Hot~Chili~Peppers", "")), ("Red~Hot~Chili~Peppers", ("Red~Hot~Chili~Peppers", "")),
("The mamas~and~the~papas", ("mamas~and~the~papas", "The")), ("The mamas~and~the~papas", ("mamas~and~the~papas", "The")),
("The mamas\ and\ the\ papas", ("mamas\ and\ the\ papas", "The")), ("The mamas and the papas", ("mamas and the papas", "The")), # Unbreakable spaces
(r"\LaTeX command", ("command", r"\LaTeX")), # LaTeX commands are ignored
(r"\emph{Some braces}", ("braces}", r"\emph{Some")), # LaTeX commands are ignored
(r"The Rolling\ Stones", (r"The Rolling\\", "Stones")), # LaTeX commands are ignored
] ]
PROCESS_AUTHORS_DATA = [ PROCESS_AUTHORS_DATA = [
( (
"Lyrics by William Blake (from Milton, 1808), music by Hubert Parry (1916), and sung by The Royal\ Choir~of~FooBar (just here to show you how processing is done)", "Lyrics by William Blake (from Milton, 1808), music by Hubert Parry (1916), and sung by The Royal~Choir~of~FooBar (just here to show you how processing is done)",
[ [
("Blake", "William"), ("Blake", "William"),
("Parry", "Hubert"), ("Parry", "Hubert"),
("Royal\ Choir~of~FooBar", "The"), ("Royal~Choir~of~FooBar", "The"),
] ]
), ),
(
"Anonyme (1967)",
[],
),
(
"Lucky Luke et Jolly Jumper",
[
("Luke", "Lucky"),
("Jumper", "Jolly"),
],
),
] ]
AUTHWORDS = authors.compile_authwords({
"after": ["by"],
"ignore": ["anonymous", "Anonyme", "anonyme"],
"sep": ['and', 'et'],
})
class TestAutors(unittest.TestCase): class TestAutors(unittest.TestCase):
"""Test of author parsing.""" """Test of author parsing."""
@ -41,13 +61,8 @@ class TestAutors(unittest.TestCase):
for argument, expected in PROCESS_AUTHORS_DATA: for argument, expected in PROCESS_AUTHORS_DATA:
with self.subTest(argument=argument, expected=expected): with self.subTest(argument=argument, expected=expected):
self.assertEqual( self.assertEqual(
authors.processauthors( set(
argument, authors.processauthors(argument, **AUTHWORDS)
**authors.compile_authwords({
"after": ["by"],
"ignore": ["anonymous"],
"sep": ['and'],
})
), ),
expected set(expected)
) )

Loading…
Cancel
Save