This commit is contained in:
Samuel Mehrbrodt 2014-07-05 22:04:17 +02:00
parent 5d7b60f714
commit 8e8288ddaa
2 changed files with 14 additions and 1 deletions

View File

@ -104,7 +104,7 @@ class AuthorType(object):
for key, value in AuthorType.Types.items():
if value == translated_type:
return key
return None
return AuthorType.NoType
class Book(BaseModel):

View File

@ -112,3 +112,16 @@ class TestDB(TestCase):
# THEN: It should have been removed and the other author should still be there
self.assertEqual(1, len(song.authors_songs))
self.assertEqual(None, song.authors_songs[0].author_type)
def test_get_author_type_from_translated_text(self):
"""
Test getting an author type from translated text
"""
# GIVEN: A string with an author type
author_type_name = AuthorType.Types[AuthorType.Words]
# WHEN: We call the method
author_type = AuthorType.from_translated_text(author_type_name)
# THEN: The type should be correct
self.assertEqual(author_type, AuthorType.Words)