Skip to content

Commit

Permalink
Add 1st set of Datacite field methods (#178)
Browse files Browse the repository at this point in the history
* Add 1st set of Datacite field methods

Why these changes are being introduced:
* Refactor Datacite to use field methods

How this addresses that need:
* Add comments to organize conftest.py by source
* Add additional Datacite fixtures to conftest.py
* Update datacite_record_all_fields.xml to align with other source fixtures
* Add create_datacite_source_record_stub function to Datacite test module
* Rename param xml > source_record
* Add field methods and associated private methods for alternate_titles, content_type, and contributors
* Add unit tests for new field methods
* Shift note-related code block from content_type to notes

Side effects of this change:
* None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/TIMX-284

* Updates based on discussion in PR #178

* Shift "or None" logic to field methods and update type hinting
* Update unit tests to all use stub records
* Remove unnecessary fixtures from conftest.py

* Further updates based on discussion in PR #178

* Add default value to create_datacite_source_record_stub's xml_insert param
* Replace calls of source_record_id variable with calls of get_source_record_id method inside field methods

* Update get_alternate_titles method
  • Loading branch information
ehanson8 authored May 24, 2024
1 parent 5f91403 commit 526705e
Show file tree
Hide file tree
Showing 4 changed files with 436 additions and 222 deletions.
21 changes: 18 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,24 @@ def runner():
return CliRunner()


# aardvark ##########################


@pytest.fixture
def aardvark_records():
return JSONTransformer.parse_source_file("tests/fixtures/aardvark_records.jsonl")


@pytest.fixture
def aardvark_record_all_fields():
return JSONTransformer.parse_source_file(
"tests/fixtures/aardvark/aardvark_record_all_fields.jsonl"
)


# datacite ##########################


@pytest.fixture
def datacite_records():
return XMLTransformer.parse_source_file(
Expand All @@ -65,9 +76,7 @@ def datacite_record_all_fields():
return Datacite("cool-repo", source_records)


@pytest.fixture
def aardvark_records():
return JSONTransformer.parse_source_file("tests/fixtures/aardvark_records.jsonl")
# marc ##########################


@pytest.fixture
Expand All @@ -80,11 +89,17 @@ def marc_content_type_crosswalk():
return load_external_config("config/marc_content_type_crosswalk.json", "json")


# oaidc ##########################


@pytest.fixture
def oai_pmh_records():
return XMLTransformer.parse_source_file("tests/fixtures/oai_pmh_records.xml")


# timdex ##########################


@pytest.fixture
def timdex_record_required_fields():
return timdex.TimdexRecord(
Expand Down
251 changes: 127 additions & 124 deletions tests/fixtures/datacite/datacite_record_all_fields.xml
Original file line number Diff line number Diff line change
@@ -1,125 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<record xmlns="http://www.openarchives.org/OAI/2.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<identifier>doi:10.7910/DVN/19PPE7</identifier>
<datestamp>2022-03-26T06:04:55Z</datestamp>
<setSpec>Jameel_Poverty_Action_Lab</setSpec>
<setSpec>IQSS</setSpec>
</header>
<metadata>
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.1/metadata.xsd">
<identifier identifierType="DOI">10.7910/DVN/19PPE7</identifier>
<creators>
<creator>
<creatorName nameType="Personal">Banerji, Rukmini</creatorName>
<givenName>Rukmini</givenName>
<familyName>Banerji</familyName>
<affiliation>Pratham and ASER Centre</affiliation>
<nameIdentifier nameIdentifierScheme="ORCID">0000-0000-0000-0000</nameIdentifier>
</creator>
<creator>
<creatorName nameType="Personal">Berry, James</creatorName>
<givenName>James</givenName>
<familyName>Berry</familyName>
<affiliation>University of Delaware</affiliation>
<nameIdentifier nameIdentifierScheme="TREX">0000-0000-0000-0001</nameIdentifier>
</creator>
<creator>
<creatorName nameType="Personal">Shotland, Marc</creatorName>
<givenName>Marc</givenName>
<familyName>Shotland</familyName>
<affiliation>Abdul Latif Jameel Poverty Action Lab</affiliation>
<nameIdentifier>0000-0000-0000-0002</nameIdentifier>
</creator>
</creators>
<titles>
<title>The Impact of Maternal Literacy and Participation Programs</title>
<title titleType="AlternativeTitle">An Alternative Title</title>
<title titleType="Subtitle">Baseline Data</title>
</titles>
<publisher>Harvard Dataverse</publisher>
<publicationYear>2017</publicationYear>
<subjects>
<subject>Social Sciences</subject>
<subject>Educational materials</subject>
<subject subjectScheme="LCSH">Adult education, education inputs, field experiments</subject>
<subject subjectScheme="LCSH">Education</subject>
</subjects>
<alternateIdentifiers>
<alternateIdentifier alternateIdentifierType="url">https://zenodo.org/record/5524465</alternateIdentifier>
</alternateIdentifiers>
<contributors>
<contributor contributorType="ContactPerson">
<contributorName nameType="Personal">Banerji, Rukmini</contributorName>
<givenName>Rukmini</givenName>
<familyName>Banerji</familyName>
<nameIdentifier nameIdentifierScheme="ORCID">0000-0000-0000-0000</nameIdentifier>
<affiliation>Pratham and ASER Centre</affiliation>
</contributor>
</contributors>
<dates>
<date dateType="Submitted">2017-02-27</date>
<date dateType="Updated" dateInformation="This was updated on this date">2019-06-24</date>
<date dateType="Collected">2007-01-01/2007-02-28</date>
</dates>
<resourceType resourceTypeGeneral="Dataset">Survey Data</resourceType>
<relatedIdentifiers>
<relatedIdentifier relatedIdentifierType="DOI" relationType="IsCitedBy">10.1257/app.20150390</relatedIdentifier>
<relatedIdentifier relationType="IsVersionOf">10.5281/zenodo.5524464</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="ISBN" relationType="IsIdenticalTo">1234567.5524464</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="ISBN" relationType="Other">1234567.5524464</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="URL" relationType="IsPartOf">https://zenodo.org/communities/astronomy-general</relatedIdentifier>
</relatedIdentifiers>
<language>en_US</language>
<sizes>
<size>124903</size>
<size>48958</size>
<size>199070</size>
<size>186674</size>
<size>139605</size>
<size>97304</size>
<size>9907</size>
<size>178534602</size>
<size>4032103</size>
<size>43589</size>
<size>15697</size>
</sizes>
<formats>
<format>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</format>
<format>application/pdf</format>
<format>application/pdf</format>
<format>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</format>
<format>application/pdf</format>
<format>application/x-stata-syntax</format>
<format>application/x-stata</format>
<format>application/x-stata</format>
<format>application/zip</format>
<format>application/pdf</format>
<format>application/pdf</format>
</formats>
<version>1.2</version>
<rightsList>
<rights rightsURI="info:eu-repo/semantics/openAccess" />
<rights rightsURI="http://creativecommons.org/publicdomain/zero/1.0">CC0 1.0</rights>
</rightsList>
<descriptions>
<description descriptionType="Abstract">Using a randomized field experiment in India, we evaluate the effectiveness of adult literacy and parental involvement interventions in improving children's learning. Households were assigned to receive either adult literacy (language and math) classes for mothers, training for mothers on how to enhance their children's learning at home, or a combination of the two programs. All three interventions had significant but modest impacts on childrens math scores. The interventions also increased mothers' test scores in both language and math, as well as a range of other outcomes reflecting greater involvement of mothers in their children's education.</description>
<description descriptionType="TechnicalInfo">Stata, 13</description>
</descriptions>
<geoLocations>
<geoLocation>
<geoLocationPlace>A point on the globe</geoLocationPlace>
</geoLocation>
</geoLocations>
<fundingReferences>
<fundingReference>
<funderName>3ie, Nike Foundation</funderName>
<funderIdentifier funderIdentifierType="Crossref FunderID">0987</funderIdentifier>
<awardNumber awardURI="http://awards.example/7689">OW1/1012 (3ie)</awardNumber>
</fundingReference>
</fundingReferences>
</resource>
</metadata>
</record>
<records>
<record xmlns="http://www.openarchives.org/OAI/2.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<identifier>doi:10.7910/DVN/19PPE7</identifier>
<datestamp>2022-03-26T06:04:55Z</datestamp>
<setSpec>Jameel_Poverty_Action_Lab</setSpec>
<setSpec>IQSS</setSpec>
</header>
<metadata>
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://datacite.org/schema/kernel-4"
xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.1/metadata.xsd">
<identifier identifierType="DOI">10.7910/DVN/19PPE7</identifier>
<creators>
<creator>
<creatorName nameType="Personal">Banerji, Rukmini</creatorName>
<givenName>Rukmini</givenName>
<familyName>Banerji</familyName>
<affiliation>Pratham and ASER Centre</affiliation>
<nameIdentifier nameIdentifierScheme="ORCID">0000-0000-0000-0000</nameIdentifier>
</creator>
<creator>
<creatorName nameType="Personal">Berry, James</creatorName>
<givenName>James</givenName>
<familyName>Berry</familyName>
<affiliation>University of Delaware</affiliation>
<nameIdentifier nameIdentifierScheme="TREX">0000-0000-0000-0001</nameIdentifier>
</creator>
<creator>
<creatorName nameType="Personal">Shotland, Marc</creatorName>
<givenName>Marc</givenName>
<familyName>Shotland</familyName>
<affiliation>Abdul Latif Jameel Poverty Action Lab</affiliation>
<nameIdentifier>0000-0000-0000-0002</nameIdentifier>
</creator>
</creators>
<titles>
<title>The Impact of Maternal Literacy and Participation Programs</title>
<title titleType="AlternativeTitle">An Alternative Title</title>
<title titleType="Subtitle">Baseline Data</title>
</titles>
<publisher>Harvard Dataverse</publisher>
<publicationYear>2017</publicationYear>
<subjects>
<subject>Social Sciences</subject>
<subject>Educational materials</subject>
<subject subjectScheme="LCSH">Adult education, education inputs, field experiments</subject>
<subject subjectScheme="LCSH">Education</subject>
</subjects>
<alternateIdentifiers>
<alternateIdentifier alternateIdentifierType="url">https://zenodo.org/record/5524465</alternateIdentifier>
</alternateIdentifiers>
<contributors>
<contributor contributorType="ContactPerson">
<contributorName nameType="Personal">Banerji, Rukmini</contributorName>
<givenName>Rukmini</givenName>
<familyName>Banerji</familyName>
<nameIdentifier nameIdentifierScheme="ORCID">0000-0000-0000-0000</nameIdentifier>
<affiliation>Pratham and ASER Centre</affiliation>
</contributor>
</contributors>
<dates>
<date dateType="Submitted">2017-02-27</date>
<date dateType="Updated" dateInformation="This was updated on this date">2019-06-24</date>
<date dateType="Collected">2007-01-01/2007-02-28</date>
</dates>
<resourceType resourceTypeGeneral="Dataset">Survey Data</resourceType>
<relatedIdentifiers>
<relatedIdentifier relatedIdentifierType="DOI" relationType="IsCitedBy">10.1257/app.20150390</relatedIdentifier>
<relatedIdentifier relationType="IsVersionOf">10.5281/zenodo.5524464</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="ISBN" relationType="IsIdenticalTo">1234567.5524464</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="ISBN" relationType="Other">1234567.5524464</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="URL" relationType="IsPartOf">https://zenodo.org/communities/astronomy-general</relatedIdentifier>
</relatedIdentifiers>
<language>en_US</language>
<sizes>
<size>124903</size>
<size>48958</size>
<size>199070</size>
<size>186674</size>
<size>139605</size>
<size>97304</size>
<size>9907</size>
<size>178534602</size>
<size>4032103</size>
<size>43589</size>
<size>15697</size>
</sizes>
<formats>
<format>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</format>
<format>application/pdf</format>
<format>application/pdf</format>
<format>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</format>
<format>application/pdf</format>
<format>application/x-stata-syntax</format>
<format>application/x-stata</format>
<format>application/x-stata</format>
<format>application/zip</format>
<format>application/pdf</format>
<format>application/pdf</format>
</formats>
<version>1.2</version>
<rightsList>
<rights rightsURI="info:eu-repo/semantics/openAccess" />
<rights rightsURI="http://creativecommons.org/publicdomain/zero/1.0">CC0 1.0</rights>
</rightsList>
<descriptions>
<description descriptionType="Abstract">Using a randomized field experiment in India, we evaluate the effectiveness of adult literacy and parental involvement interventions in improving children's learning. Households were assigned to receive either adult literacy (language and math) classes for mothers, training for mothers on how to enhance their children's learning at home, or a combination of the two programs. All three interventions had significant but modest impacts on childrens math scores. The interventions also increased mothers' test scores in both language and math, as well as a range of other outcomes reflecting greater involvement of mothers in their children's education.</description>
<description descriptionType="TechnicalInfo">Stata, 13</description>
</descriptions>
<geoLocations>
<geoLocation>
<geoLocationPlace>A point on the globe</geoLocationPlace>
</geoLocation>
</geoLocations>
<fundingReferences>
<fundingReference>
<funderName>3ie, Nike Foundation</funderName>
<funderIdentifier funderIdentifierType="Crossref FunderID">0987</funderIdentifier>
<awardNumber awardURI="http://awards.example/7689">OW1/1012 (3ie)</awardNumber>
</fundingReference>
</fundingReferences>
</resource>
</metadata>
</record>
</records>
Loading

0 comments on commit 526705e

Please sign in to comment.