Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7450890
D3290.id11665.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D3290.id11665.diff
View Options
diff --git a/swh/storage/converters.py b/swh/storage/converters.py
--- a/swh/storage/converters.py
+++ b/swh/storage/converters.py
@@ -5,6 +5,8 @@
import datetime
+from typing import Optional, Dict
+
from swh.core.utils import decode_with_escape, encode_with_unescape
from swh.model import identifiers
from swh.model.hashutil import MultiHash
@@ -39,19 +41,22 @@
return author
-def db_to_author(fullname, name, email):
+def db_to_author(
+ fullname: Optional[bytes], name: Optional[bytes], email: Optional[bytes]
+) -> Optional[Dict[str, Optional[bytes]]]:
"""Convert the DB representation of an author to a swh-model author.
Args:
- id (long): the author's identifier
fullname (bytes): the author's fullname
name (bytes): the author's name
email (bytes): the author's email
Returns:
- dict: a dictionary with four keys: id, fullname, name and email, or
- None if the id is None
+ a dictionary with three keys (fullname, name and email), or
+ None if all the arguments are None.
"""
+ if (fullname, name, email) == (None, None, None):
+ return None
return {
"fullname": fullname,
"name": name,
diff --git a/swh/storage/tests/test_converters.py b/swh/storage/tests/test_converters.py
--- a/swh/storage/tests/test_converters.py
+++ b/swh/storage/tests/test_converters.py
@@ -55,6 +55,14 @@
}
+def test_db_to_author_none():
+ # when
+ actual_author = converters.db_to_author(None, None, None)
+
+ # then
+ assert actual_author is None
+
+
def test_db_to_revision():
# when
actual_revision = converters.db_to_revision(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 16, 9:03 AM (6 d, 7 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3221115
Attached To
D3290: Fix db_to_author() converter to return None is all fields are None
Event Timeline
Log In to Comment