-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest_byline.py
53 lines (43 loc) · 2.27 KB
/
test_byline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from models.byline import Byline
from models.person import Person
import unittest
from nose.tools import assert_equals
from nose.tools import assert_not_equals
from nose.tools import assert_true
from nose.tools import assert_items_equal
class TestByline(unittest.TestCase):
test_bylines = """David Bronaugh <[email protected]>, Arelia Werner <[email protected]> for the Pacific Climate Impacts Consortium
Keon-Woong Moon [aut, cre]
Corentin M Barbu [aut, cre],<U+000a>Sebastian Gibb [ctb]
Philippe Grosjean [aut, cre],
Kevin Denis [aut]
Erik Otarola-Castillo, Jesse Wolfhagen, Max D. Price
Achim Zeileis [aut, cre],<U+000a>Gabor Grothendieck [aut],<U+000a>Jeffrey A. Ryan [aut],<U+000a>Felix Andrews [ctb]
David Beiner
Fang Liu <[email protected]> with contributions from Yunchuan Kong <[email protected]>
Jonathan M. Lees <[email protected]>
Stefan Evert <[email protected]>, Marco Baroni<U+000a><[email protected]>
""".split("\n")
def test_clean_byline_string(self):
byline = Byline(self.test_bylines[2])
expected = ' Corentin M Barbu [aut, cre], Sebastian Gibb [ctb]'
assert_equals(byline._clean_byline(), expected)
def test_author_email_pairs(self):
for byline_string in self.test_bylines:
byline = Byline(byline_string)
print "\n{}\n{}\n".format(byline.author_email_pairs(), byline_string)
# assert_equals(byline.author_email_pairs(), "hi")
def test_author_halt(self):
test_string = """Fortran code by H. Akima<U+000a>R port by Albrecht Gebhardt <[email protected]><U+000a>aspline function by Thomas Petzoldt <[email protected]><U+000a>interp2xyz, enhancements and corrections by Martin Maechler <[email protected]>"""
byline = Byline(test_string)
response = byline.author_email_pairs()
expected = None
assert_equals(response, expected)
def test_author_square_brackets(self):
test_string = """Jie (Kate) Hu [aut, cre],
Norman Breslow [aut],
Gary Chan [aut]"""
byline = Byline(test_string)
response = byline.author_email_pairs()
expected = None
assert_equals(response, expected)