diff --git a/swh/loader/pypi/converters.py b/swh/loader/pypi/converters.py --- a/swh/loader/pypi/converters.py +++ b/swh/loader/pypi/converters.py @@ -62,13 +62,12 @@ if not fullname: return EMPTY_AUTHOR - if fullname: - fullname = fullname.encode('utf-8') + fullname = fullname.encode('utf-8') - if name: + if name is not None: name = name.encode('utf-8') - if email: + if email is not None: email = email.encode('utf-8') return {'fullname': fullname, 'name': name, 'email': email} diff --git a/swh/loader/pypi/tests/test_converters.py b/swh/loader/pypi/tests/test_converters.py --- a/swh/loader/pypi/tests/test_converters.py +++ b/swh/loader/pypi/tests/test_converters.py @@ -72,6 +72,36 @@ self.assertEqual(actual_author, expected_author) + def test_author_empty_email(self): + data = { + 'author': 'i-am-groot', + 'author_email': '', + } + actual_author = author(data) + + expected_author = { + 'fullname': b'i-am-groot', + 'name': b'i-am-groot', + 'email': b'', + } + + self.assertEqual(actual_author, expected_author) + + def test_author_empty_name(self): + data = { + 'author': "", + 'author_email': 'iam@groot.org', + } + actual_author = author(data) + + expected_author = { + 'fullname': b' ', + 'name': b'', + 'email': b'iam@groot.org', + } + + self.assertEqual(actual_author, expected_author) + def test_author_malformed(self): data = { 'author': "['pierre', 'paul', 'jacques']",