Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDS Schema 3 Deprecation Tasks. #71

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions spec/concerns/metadatable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@
let(:doi) { "10.5438/08a0-3f64" }
let(:url) { "https://blog.datacite.org/" }
let(:data) { file_fixture("datacite.xml").read }
let(:datav3) { file_fixture("datacite-v3.xml").read }
let(:datav3a) { file_fixture("datacite-v3a.xml").read }
let(:datav4a) { file_fixture("datacite-v4a.xml").read }
let(:doiv3) { "10.14454/0000-v3" }
let(:doiv3a) { "10.14454/0000-0003" }
let(:doiv4a) { "10.14454/0000-0003" }

context "versions" do
subject { MetadataController }

it "should not register invalid version of metadata" do
options = { data: datav3, username: username, password: password }
response = subject.create_metadata(doiv3, options)
expect(response.status).to eq(422)
expect(response.body.dig("errors")).to eq([{"status"=>422, "title"=>"DOI 10.14454/0000-v3: Schema http://datacite.org/schema/kernel-3 is no longer supported"}])
end

it "should get v3 metadata and update registered metadata as v4" do
options = { username: username, password: password }
expect(subject.get_metadata(doiv3a, options).body.dig("data")).to eq(datav3a.strip)

options = { data: datav4a, username: username, password: password }
response = subject.create_metadata(doiv3a, options)
expect(response.status).to eq(200)
expect(::Base64.decode64(response.body.dig("data", "attributes", "xml"))).to eq(datav4a.strip)
end

end

context "class_methods" do
subject { MetadataController }
Expand Down
40 changes: 40 additions & 0 deletions spec/fixtures/files/datacite-v3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datacite.org/schema/kernel-3" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
<identifier identifierType="DOI">10.14454/0000-0003</identifier>
<creators>
<creator>
<creatorName>Fenner, Martin</creatorName>
<givenName>Martin</givenName>
<familyName>Fenner</familyName>
<nameIdentifier schemeURI="http://orcid.org/" nameIdentifierScheme="ORCID">0000-0003-1419-2405</nameIdentifier>
</creator>
</creators>
<titles>
<title>Eating your own Dog Food</title>
</titles>
<publisher>DataCite</publisher>
<publicationYear>2016</publicationYear>
<resourceType resourceTypeGeneral="Text">BlogPosting</resourceType>
<alternateIdentifiers>
<alternateIdentifier alternateIdentifierType="Local accession number">MS-49-3632-5083</alternateIdentifier>
</alternateIdentifiers>
<subjects>
<subject>datacite</subject>
<subject>doi</subject>
<subject>metadata</subject>
</subjects>
<dates>
<date dateType="Created">2016-12-20</date>
<date dateType="Issued">2016-12-20</date>
<date dateType="Updated">2016-12-20</date>
</dates>
<relatedIdentifiers>
<relatedIdentifier relatedIdentifierType="DOI" relationType="References">10.5438/0012</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="DOI" relationType="References">10.5438/55E5-T5C0</relatedIdentifier>
<relatedIdentifier relatedIdentifierType="DOI" relationType="IsPartOf">10.5438/0000-00SS</relatedIdentifier>
</relatedIdentifiers>
<version>1.0</version>
<descriptions>
<description descriptionType="Abstract">Eating your own dog food is a slang term to describe that an organization should itself use the products and services it provides. For DataCite this means that we should use DOIs with appropriate metadata and strategies for long-term preservation for...</description>
</descriptions>
</resource>
40 changes: 40 additions & 0 deletions spec/fixtures/files/datacite-v3a.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datacite.org/schema/kernel-3" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
<identifier identifierType="DOI">10.14454/0000-0003</identifier>
<creators>
<creator>
<creatorName nameType="Personal">Travolta, John</creatorName>
<givenName>John</givenName>
<familyName>Travolta</familyName>
</creator>
<creator>
<creatorName nameType="Personal">X, Mr</creatorName>
<givenName>Mr</givenName>
<familyName>X</familyName>
</creator>
<creator>
<creatorName nameType="Personal">Mozart, Wolfgang Amadeus</creatorName>
<givenName>Wolfgang Amadeus</givenName>
<familyName>Mozart</familyName>
</creator>
</creators>
<titles>
<title>Test Title</title>
</titles>
<publisher>University of Illinois at Chicago</publisher>
<publicationYear>2024</publicationYear>
<contributors>
<contributor contributorType="RightsHolder">
<contributorName>Durham University</contributorName>
</contributor>
<contributor contributorType="HostingInstitution">
<contributorName>Durham University</contributorName>
</contributor>
<contributor contributorType="Funder">
<contributorName>Durham University</contributorName>
</contributor>
</contributors>
<sizes/>
<formats/>
<version/>
</resource>
44 changes: 44 additions & 0 deletions spec/fixtures/files/datacite-v4a.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/metadata.xsd">
<identifier identifierType="DOI">10.14454/0000-0003</identifier>
<creators>
<creator>
<creatorName nameType="Personal">Travolta, John</creatorName>
<givenName>John</givenName>
<familyName>Travolta</familyName>
</creator>
<creator>
<creatorName nameType="Personal">X, Mr</creatorName>
<givenName>Mr</givenName>
<familyName>X</familyName>
</creator>
<creator>
<creatorName nameType="Personal">Mozart, Wolfgang Amadeus</creatorName>
<givenName>Wolfgang Amadeus</givenName>
<familyName>Mozart</familyName>
</creator>
</creators>
<titles>
<title>Test Title</title>
</titles>
<resourceType resourceTypeGeneral="Dataset">Census Data</resourceType>
<publisher>University of Illinois at Chicago</publisher>
<publicationYear>2024</publicationYear>
<contributors>
<contributor contributorType="RightsHolder">
<contributorName>Durham University</contributorName>
</contributor>
<contributor contributorType="HostingInstitution">
<contributorName>Durham University</contributorName>
</contributor>
</contributors>
<fundingReferences>
<fundingReference>
<funderName>Durham University</funderName>
<funderIdentifier funderIdentifierType="Crossref Funder ID">https://doi.org/10.13039/501100001314</funderIdentifier>
</fundingReference>
</fundingReferences>
<sizes/>
<formats/>
<version/>
</resource>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading