Skip to content

Commit

Permalink
Schema 3 deprecation - add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
svogt0511 committed Oct 28, 2024
1 parent c52e300 commit 85c944a
Show file tree
Hide file tree
Showing 6 changed files with 346 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spec/concerns/metadatable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
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-0002" }
let(:doiv4a) { "10.14454/0000-0002" }
let(:doiv3a) { "10.14454/0000-0003" }
let(:doiv4a) { "10.14454/0000-0003" }

context "versions" do
subject { MetadataController }

it "should not register metadata" do
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 and update registered metadata as v4" do
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)

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

0 comments on commit 85c944a

Please sign in to comment.