Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #37 from MITLibraries/grant-info
Browse files Browse the repository at this point in the history
Add grant number information field
  • Loading branch information
ehanson8 committed Oct 16, 2020
2 parents e530580 + 2c710fe commit 0c8ccca
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion hoard/models.py
Expand Up @@ -40,6 +40,7 @@ class Distributor:
class GrantNumber:
grantNumberValue: Optional[str] = None
grantNumberAgency: Optional[str] = None
grantNumberInformation: Optional[str] = None


@attr.s(auto_attribs=True)
Expand Down Expand Up @@ -164,7 +165,7 @@ def asdict(self) -> dict:
compound(
self.grantNumbers,
"grantNumber",
["grantNumberValue", "grantNumberAgency"],
["grantNumberValue", "grantNumberAgency", "grantNumberInformation"],
)
)
fields.append(compound(self.keywords, "keyword", ["keywordValue"]))
Expand Down
2 changes: 1 addition & 1 deletion hoard/sources/whoas.py
Expand Up @@ -114,7 +114,7 @@ def create_from_whoas_dim_xml(data: str, client: OAIClient) -> Dataset:
and field.attrib["qualifier"] == "sponsorship"
):
kwargs.setdefault("grantNumbers", []).append(
GrantNumber(grantNumberValue=field.text, grantNumberAgency=field.text)
GrantNumber(grantNumberInformation=field.text)
)
if field.attrib["element"] == "description" and "qualifier" not in field.attrib:
if field.text is not None and notesText == "":
Expand Down
6 changes: 6 additions & 0 deletions tests/data/all_fields.json
Expand Up @@ -164,6 +164,12 @@
"multiple": false,
"typeClass": "primitive",
"value": "GrantInformationGrantNumber1"
},
"grantNumberInformation": {
"typeName": "grantNumberInformation",
"multiple": false,
"typeClass": "primitive",
"value": "GrantInformationInformation1"
}
}
]
Expand Down
1 change: 1 addition & 0 deletions tests/test_models.py
Expand Up @@ -64,6 +64,7 @@ def test_full_dataset(dataverse_full_json_record):
grantNumbers = GrantNumber(
grantNumberValue="GrantInformationGrantNumber1",
grantNumberAgency="GrantInformationGrantAgency1",
grantNumberInformation="GrantInformationInformation1",
)
otherIds = OtherId(
otherIdValue="OtherIDIdentifier1", otherIdAgency="OtherIDAgency1",
Expand Down
5 changes: 1 addition & 4 deletions tests/test_whoas.py
Expand Up @@ -59,10 +59,7 @@ def test_create_whoas_dim_xml(whoas_oai_server, dspace_oai_xml_series_name_recor
]
distributors = [Distributor(distributorName="Esteemed Publishing Conglomerate")]
grantNumbers = [
GrantNumber(
grantNumberValue="Funding for this educational package.",
grantNumberAgency="Funding for this educational package.",
)
GrantNumber(grantNumberInformation="Funding for this educational package.")
]
keywords = [
Keyword(keywordValue="Migration"),
Expand Down

0 comments on commit 0c8ccca

Please sign in to comment.