def test_string_field(): """ Text#pretty() should return a prettified version of the field. """ text = Text(title='war and peace') assert text.pretty('title') == prettify('war and peace')
def test_empty_field(): """ If the field is empty, return None. """ text = Text(title=None) assert text.pretty('title') == None
def test_surname_blacklisted(surname, blacklisted): surnames = map(tokenize_field, [ 'may', 'world bank', ]) text = Text(surname=surname) assert text.surname_blacklisted(surnames) == blacklisted
def test_title_blacklisted(title, blacklisted): titles = map(tokenize_field, [ 'letter', 'the white house', ]) text = Text(title=title) assert text.title_blacklisted(titles) == blacklisted
def test_array_field(): """ If the requested field is an array, prettify each element. """ text = Text(authors=[ 'david mcclure', 'joe karaganis', ]) assert text.pretty('authors') == [ prettify('david mcclure'), prettify('joe karaganis'), ]
def test_surname_is_toponym(surname, is_toponym): text = Text(surname=surname) assert text.surname_is_toponym == is_toponym
def test_title_is_toponym(title, is_toponym): text = Text(title=title) assert text.title_is_toponym == is_toponym
def test_title_and_author_overlap(title, author, result): text = Text(title=title, authors=[author]) assert text.title_and_author_overlap == result