Skip to content
Permalink
Browse files

quickfix of partialdate/fuzzy date

  • Loading branch information...
nad2000 committed Aug 14, 2019
1 parent d168ffb commit 1ea58e60a6071d750b567c74c0ea22db36116e64
Showing with 30 additions and 1 deletion.
  1. +3 −1 orcid_hub/models.py
  2. +27 −0 tests/test_models.py
@@ -230,7 +230,9 @@ def create(cls, value):

return cls(*[int(v) for v in value0.split('-')])

return cls(**{k: int(v.get("value")) if v else None for k, v in value.items()})
return cls(
**{k: int(v.get("value")) if v and v.get("value") else None
for k, v in value.items()})

def as_datetime(self):
"""Get 'datetime' data representation."""
@@ -448,6 +448,33 @@ def test_partial_date():
}
}
assert pd.year == 2003 and pd.month == 7 and pd.day == 31

pd = PartialDate.create({
"year": {
"value": "2003"
},
"month": {
"value": "11"
},
"day": {
"value": None
}
})
assert pd.year == 2003 and pd.month == 11 and pd.day is None

pd = PartialDate.create({
"year": {
"value": "2003"
},
"month": {
"value": None
},
"day": {
"value": None
}
})
assert pd.year == 2003 and pd.month is None and pd.day is None

assert PartialDate().as_orcid_dict() is None
assert PartialDate.create(None) is None
assert PartialDate.create({}) is None

0 comments on commit 1ea58e6

Please sign in to comment.
You can’t perform that action at this time.