diff --git a/conftest.py b/conftest.py
index 77e5993ff7f1..24afe25f0b47 100644
--- a/conftest.py
+++ b/conftest.py
@@ -56,6 +56,8 @@ def override_settings():
website_settings.BCRYPT_LOG_ROUNDS = 1
# Make sure we don't accidentally send any emails
website_settings.SENDGRID_API_KEY = None
+ # or try to contact a SHARE
+ website_settings.SHARE_ENABLED = False
# Set this here instead of in SILENT_LOGGERS, in case developers
# call setLevel in local.py
logging.getLogger('website.mails.mails').setLevel(logging.CRITICAL)
diff --git a/osf/metadata/osf_gathering.py b/osf/metadata/osf_gathering.py
index 2044c8389aaa..1175e101cfd0 100644
--- a/osf/metadata/osf_gathering.py
+++ b/osf/metadata/osf_gathering.py
@@ -430,16 +430,8 @@ def gather_versions(focus):
if hasattr(focus.dbmodel, 'versions'): # quacks like BaseFileNode
last_fileversion = focus.dbmodel.versions.last() # just the last version, for now
if last_fileversion is not None: # quacks like OsfStorageFileNode
- from api.base.utils import absolute_reverse as apiv2_absolute_reverse
fileversion_iri = rdflib.URIRef(
- apiv2_absolute_reverse(
- 'files:version-detail',
- kwargs={
- 'version': 'v2', # api version
- 'file_id': focus.dbmodel._id,
- 'version_id': last_fileversion.identifier,
- },
- ),
+ f'{focus.iri}?revision={last_fileversion.identifier}'
)
yield (OSF.hasFileVersion, fileversion_iri)
yield from _gather_fileversion(last_fileversion, fileversion_iri)
@@ -661,6 +653,7 @@ def gather_agents(focus):
# TODO: contributor roles
for user in getattr(focus.dbmodel, 'visible_contributors', ()):
yield (DCTERMS.creator, OsfFocus(user))
+ # TODO: preserve order via rdflib.Seq
@gather.er(OSF.affiliatedInstitution)
diff --git a/osf/metadata/serializers/datacite/datacite_tree_walker.py b/osf/metadata/serializers/datacite/datacite_tree_walker.py
index 677407ca3259..b52b6c44ecaf 100644
--- a/osf/metadata/serializers/datacite/datacite_tree_walker.py
+++ b/osf/metadata/serializers/datacite/datacite_tree_walker.py
@@ -379,7 +379,7 @@ def _visit_related(self, parent_el):
relation_pairs.add((datacite_relation, related_iri))
related_identifiers_el = self.visit(parent_el, 'relatedIdentifiers', is_list=True)
related_items_el = self.visit(parent_el, 'relatedItems', is_list=True)
- for datacite_relation, related_iri in relation_pairs:
+ for datacite_relation, related_iri in sorted(relation_pairs):
self._visit_related_identifier_and_item(
related_identifiers_el,
related_items_el,
@@ -396,11 +396,11 @@ def _visit_name_identifiers(self, parent_el, agent_iri):
def _visit_subjects(self, parent_el):
subjects_el = self.visit(parent_el, 'subjects', is_list=True)
- for subject in self.basket[DCTERMS.subject]:
+ for subject in sorted(self.basket[DCTERMS.subject]):
self.visit(subjects_el, 'subject', text=subject, attrib={
'subjectScheme': BEPRESS_SUBJECT_SCHEME,
})
- for keyword in self.basket[OSF.keyword]:
+ for keyword in sorted(self.basket[OSF.keyword]):
self.visit(subjects_el, 'subject', text=keyword)
def _visit_resource_type(self, parent_el):
@@ -417,6 +417,7 @@ def _visit_resource_type(self, parent_el):
})
def _get_resource_type_general(self, focus_iri):
+ # return just the first recognized type, preferably from dcterms:type
type_terms = itertools.chain(
self.basket[focus_iri:DCTERMS.type],
self.basket[focus_iri:RDF.type],
diff --git a/osf/metadata/tools.py b/osf/metadata/tools.py
index 592ee78ba8cc..2cd4699413f3 100644
--- a/osf/metadata/tools.py
+++ b/osf/metadata/tools.py
@@ -37,7 +37,7 @@ def pls_gather_metadata_file(osf_item, format_key, serializer_config=None) -> Se
basket = pls_get_magic_metadata_basket(osfguid.referent)
serializer = get_metadata_serializer(format_key, basket, serializer_config)
return SerializedMetadataFile(
- serializer.mediatype,
- serializer.filename_for_itemid(osfguid._id),
- serializer.serialize(),
+ mediatype=serializer.mediatype,
+ filename=serializer.filename_for_itemid(osfguid._id),
+ serialized_metadata=serializer.serialize(),
)
diff --git a/osf_tests/metadata/expected_metadata_files/file_basic.datacite.json b/osf_tests/metadata/expected_metadata_files/file_basic.datacite.json
new file mode 100644
index 000000000000..73ecf1b1a1b4
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/file_basic.datacite.json
@@ -0,0 +1,86 @@
+{
+ "alternateIdentifiers": [
+ {
+ "alternateIdentifier": "http://localhost:5000/w3ibb",
+ "alternateIdentifierType": "URL"
+ }
+ ],
+ "contributors": [
+ {
+ "contributorName": {
+ "contributorName": "Center for Open Science",
+ "nameType": "Organizational"
+ },
+ "contributorType": "HostingInstitution",
+ "nameIdentifier": {
+ "nameIdentifier": "https://cos.io/",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "creators": [
+ {
+ "creatorName": {
+ "creatorName": "Person McNamington",
+ "nameType": "Personal"
+ },
+ "nameIdentifier": {
+ "nameIdentifier": "http://localhost:5000/w1ibb",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "dates": [
+ {
+ "date": "2123-05-04",
+ "dateType": "Created"
+ },
+ {
+ "date": "2123-05-04",
+ "dateType": "Updated"
+ }
+ ],
+ "descriptions": [],
+ "fundingReferences": [],
+ "identifier": {
+ "identifier": "http://localhost:5000/w3ibb",
+ "identifierType": "URL"
+ },
+ "publicationYear": "2123",
+ "publisher": "OSF",
+ "relatedIdentifiers": [
+ {
+ "relatedIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedIdentifierType": "DOI",
+ "relationType": "IsPartOf"
+ }
+ ],
+ "relatedItems": [
+ {
+ "publicationYear": "2252",
+ "publisher": "OSF",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedItemIdentifierType": "DOI"
+ },
+ "relatedItemType": "Text",
+ "relationType": "IsPartOf",
+ "titles": [
+ {
+ "title": "this is a project title!"
+ }
+ ]
+ }
+ ],
+ "resourceType": {
+ "resourceType": "File",
+ "resourceTypeGeneral": "Text"
+ },
+ "rightsList": [],
+ "subjects": [],
+ "titles": [
+ {
+ "title": "my-file.blarg"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/file_basic.datacite.xml b/osf_tests/metadata/expected_metadata_files/file_basic.datacite.xml
new file mode 100644
index 000000000000..e6d3d614e997
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/file_basic.datacite.xml
@@ -0,0 +1,47 @@
+
+
+ http://localhost:5000/w3ibb
+
+
+ Person McNamington
+ http://localhost:5000/w1ibb
+
+
+
+ my-file.blarg
+
+ OSF
+ 2123
+
+
+
+ Center for Open Science
+ https://ror.org/05d5mza29
+ https://cos.io/
+
+
+
+ 2123-05-04
+ 2123-05-04
+
+ File
+
+ http://localhost:5000/w3ibb
+
+
+
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+ this is a project title!
+
+ 2252
+ OSF
+
+
+
diff --git a/osf_tests/metadata/expected_metadata_files/file_basic.turtle b/osf_tests/metadata/expected_metadata_files/file_basic.turtle
new file mode 100644
index 000000000000..2ad93bf05ea0
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/file_basic.turtle
@@ -0,0 +1,41 @@
+@prefix dcterms: .
+@prefix foaf: .
+@prefix osf: .
+@prefix owl: .
+
+ a osf:File ;
+ dcterms:created "2123-05-04" ;
+ dcterms:identifier "http://localhost:5000/w3ibb" ;
+ dcterms:modified "2123-05-04" ;
+ osf:fileName "my-file.blarg" ;
+ osf:filePath "/my-file.blarg" ;
+ osf:hasFileVersion ;
+ osf:isContainedBy .
+
+ a osf:Project ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:identifier "http://localhost:5000/w2ibb",
+ "https://doi.org/10.70102/FK2osf.io/w2ibb" ;
+ dcterms:publisher ;
+ dcterms:title "this is a project title!" ;
+ owl:sameAs .
+
+ a osf:FileVersion ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:extent "0.000007 MB" ;
+ dcterms:format "img/png" ;
+ dcterms:modified "2123-05-04" ;
+ dcterms:requires ;
+ osf:versionNumber "1" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/w1ibb" ;
+ dcterms:type foaf:Person ;
+ foaf:name "Person McNamington" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "OSF" .
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/file_full.datacite.json b/osf_tests/metadata/expected_metadata_files/file_full.datacite.json
new file mode 100644
index 000000000000..11f7ef9d6383
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/file_full.datacite.json
@@ -0,0 +1,87 @@
+{
+ "alternateIdentifiers": [
+ {
+ "alternateIdentifier": "http://localhost:5000/w3ibb",
+ "alternateIdentifierType": "URL"
+ }
+ ],
+ "contributors": [
+ {
+ "contributorName": {
+ "contributorName": "Center for Open Science",
+ "nameType": "Organizational"
+ },
+ "contributorType": "HostingInstitution",
+ "nameIdentifier": {
+ "nameIdentifier": "https://cos.io/",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "creators": [
+ {
+ "creatorName": {
+ "creatorName": "Person McNamington",
+ "nameType": "Personal"
+ },
+ "nameIdentifier": {
+ "nameIdentifier": "http://localhost:5000/w1ibb",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "dates": [
+ {
+ "date": "2123-05-04",
+ "dateType": "Created"
+ },
+ {
+ "date": "2123-05-04",
+ "dateType": "Updated"
+ }
+ ],
+ "descriptions": [],
+ "fundingReferences": [],
+ "identifier": {
+ "identifier": "http://localhost:5000/w3ibb",
+ "identifierType": "URL"
+ },
+ "publicationYear": "2123",
+ "publisher": "OSF",
+ "relatedIdentifiers": [
+ {
+ "relatedIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedIdentifierType": "DOI",
+ "relationType": "IsPartOf"
+ }
+ ],
+ "relatedItems": [
+ {
+ "publicationYear": "2123",
+ "publisher": "OSF",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedItemIdentifierType": "DOI"
+ },
+ "relatedItemType": "Dataset",
+ "relationType": "IsPartOf",
+ "titles": [
+ {
+ "lang": "en",
+ "title": "this is a project title!"
+ }
+ ]
+ }
+ ],
+ "resourceType": {
+ "resourceType": "File",
+ "resourceTypeGeneral": "Text"
+ },
+ "rightsList": [],
+ "subjects": [],
+ "titles": [
+ {
+ "title": "my-file.blarg"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/file_full.datacite.xml b/osf_tests/metadata/expected_metadata_files/file_full.datacite.xml
new file mode 100644
index 000000000000..f56df1233001
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/file_full.datacite.xml
@@ -0,0 +1,47 @@
+
+
+ http://localhost:5000/w3ibb
+
+
+ Person McNamington
+ http://localhost:5000/w1ibb
+
+
+
+ my-file.blarg
+
+ OSF
+ 2123
+
+
+
+ Center for Open Science
+ https://ror.org/05d5mza29
+ https://cos.io/
+
+
+
+ 2123-05-04
+ 2123-05-04
+
+ File
+
+ http://localhost:5000/w3ibb
+
+
+
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+ this is a project title!
+
+ 2123
+ OSF
+
+
+
diff --git a/osf_tests/metadata/expected_metadata_files/file_full.turtle b/osf_tests/metadata/expected_metadata_files/file_full.turtle
new file mode 100644
index 000000000000..352da04e5c05
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/file_full.turtle
@@ -0,0 +1,42 @@
+@prefix dcterms: .
+@prefix foaf: .
+@prefix osf: .
+@prefix owl: .
+
+ a osf:File ;
+ dcterms:created "2123-05-04" ;
+ dcterms:identifier "http://localhost:5000/w3ibb" ;
+ dcterms:modified "2123-05-04" ;
+ osf:fileName "my-file.blarg" ;
+ osf:filePath "/my-file.blarg" ;
+ osf:hasFileVersion ;
+ osf:isContainedBy .
+
+ a osf:Project ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:identifier "http://localhost:5000/w2ibb",
+ "https://doi.org/10.70102/FK2osf.io/w2ibb" ;
+ dcterms:publisher ;
+ dcterms:title "this is a project title!"@en ;
+ dcterms:type "Dataset" ;
+ owl:sameAs .
+
+ a osf:FileVersion ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:extent "0.000007 MB" ;
+ dcterms:format "img/png" ;
+ dcterms:modified "2123-05-04" ;
+ dcterms:requires ;
+ osf:versionNumber "1" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/w1ibb" ;
+ dcterms:type foaf:Person ;
+ foaf:name "Person McNamington" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "OSF" .
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/preprint_basic.datacite.json b/osf_tests/metadata/expected_metadata_files/preprint_basic.datacite.json
new file mode 100644
index 000000000000..627df29da271
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/preprint_basic.datacite.json
@@ -0,0 +1,123 @@
+{
+ "alternateIdentifiers": [
+ {
+ "alternateIdentifier": "http://localhost:5000/w4ibb",
+ "alternateIdentifierType": "URL"
+ }
+ ],
+ "contributors": [
+ {
+ "contributorName": {
+ "contributorName": "Center for Open Science",
+ "nameType": "Organizational"
+ },
+ "contributorType": "HostingInstitution",
+ "nameIdentifier": {
+ "nameIdentifier": "https://cos.io/",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "creators": [
+ {
+ "creatorName": {
+ "creatorName": "Person McNamington",
+ "nameType": "Personal"
+ },
+ "nameIdentifier": {
+ "nameIdentifier": "http://localhost:5000/w1ibb",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "dates": [
+ {
+ "date": "2123-05-04",
+ "dateType": "Created"
+ },
+ {
+ "date": "2123-05-04",
+ "dateType": "Updated"
+ }
+ ],
+ "descriptions": [
+ {
+ "description": "this is a preprint description!",
+ "descriptionType": "Abstract"
+ }
+ ],
+ "fundingReferences": [],
+ "identifier": {
+ "identifier": "11.pp/FK2osf.io/w4ibb",
+ "identifierType": "DOI"
+ },
+ "publicationYear": "2123",
+ "publisher": "PP the Preprint Provider",
+ "relatedIdentifiers": [
+ {
+ "relatedIdentifier": "11.111/something-or-other",
+ "relatedIdentifierType": "DOI",
+ "relationType": "HasVersion"
+ },
+ {
+ "relatedIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedIdentifierType": "DOI",
+ "relationType": "IsSupplementedBy"
+ }
+ ],
+ "relatedItems": [
+ {
+ "publisher": "OSF",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "11.111/something-or-other",
+ "relatedItemIdentifierType": "DOI"
+ },
+ "relatedItemType": "Text",
+ "relationType": "HasVersion",
+ "titles": []
+ },
+ {
+ "publicationYear": "2252",
+ "publisher": "OSF",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedItemIdentifierType": "DOI"
+ },
+ "relatedItemType": "Text",
+ "relationType": "IsSupplementedBy",
+ "titles": [
+ {
+ "title": "this is a project title!"
+ }
+ ]
+ }
+ ],
+ "resourceType": {
+ "resourceType": "Preprint",
+ "resourceTypeGeneral": "Preprint"
+ },
+ "rightsList": [],
+ "subjects": [
+ {
+ "subject": "wibbble",
+ "subjectScheme": "bepress Digital Commons Three-Tiered Taxonomy"
+ },
+ {
+ "subject": "wibble",
+ "subjectScheme": "bepress Digital Commons Three-Tiered Taxonomy"
+ },
+ {
+ "subject": "wobbble",
+ "subjectScheme": "bepress Digital Commons Three-Tiered Taxonomy"
+ },
+ {
+ "subject": "wobble",
+ "subjectScheme": "bepress Digital Commons Three-Tiered Taxonomy"
+ }
+ ],
+ "titles": [
+ {
+ "title": "this is a preprint title!"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/preprint_basic.datacite.xml b/osf_tests/metadata/expected_metadata_files/preprint_basic.datacite.xml
new file mode 100644
index 000000000000..93fbf8f9823f
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/preprint_basic.datacite.xml
@@ -0,0 +1,60 @@
+
+
+ 11.pp/FK2osf.io/w4ibb
+
+
+ Person McNamington
+ http://localhost:5000/w1ibb
+
+
+
+ this is a preprint title!
+
+ PP the Preprint Provider
+ 2123
+
+ wibbble
+ wibble
+ wobbble
+ wobble
+
+
+
+ Center for Open Science
+ https://ror.org/05d5mza29
+ https://cos.io/
+
+
+
+ 2123-05-04
+ 2123-05-04
+
+ Preprint
+
+ http://localhost:5000/w4ibb
+
+
+
+ this is a preprint description!
+
+
+
+ 11.111/something-or-other
+ 10.70102/FK2osf.io/w2ibb
+
+
+
+ 11.111/something-or-other
+
+ OSF
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+ this is a project title!
+
+ 2252
+ OSF
+
+
+
diff --git a/osf_tests/metadata/expected_metadata_files/preprint_basic.turtle b/osf_tests/metadata/expected_metadata_files/preprint_basic.turtle
new file mode 100644
index 000000000000..2a44d43d8ef1
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/preprint_basic.turtle
@@ -0,0 +1,48 @@
+@prefix dcterms: .
+@prefix foaf: .
+@prefix osf: .
+@prefix owl: .
+
+ a osf:Preprint ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:description "this is a preprint description!" ;
+ dcterms:hasVersion ;
+ dcterms:identifier "http://localhost:5000/w4ibb",
+ "https://doi.org/11.pp/FK2osf.io/w4ibb" ;
+ dcterms:modified "2123-05-04" ;
+ dcterms:publisher ;
+ dcterms:subject "wibbble",
+ "wibble",
+ "wobbble",
+ "wobble" ;
+ dcterms:title "this is a preprint title!" ;
+ owl:sameAs ;
+ osf:isSupplementedBy ;
+ osf:statedConflictOfInterest osf:no-conflict-of-interest .
+
+ a osf:Project ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:identifier "http://localhost:5000/w2ibb",
+ "https://doi.org/10.70102/FK2osf.io/w2ibb" ;
+ dcterms:publisher ;
+ dcterms:title "this is a project title!" ;
+ owl:sameAs .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/preprints/preprovi" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "PP the Preprint Provider" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/w1ibb" ;
+ dcterms:type foaf:Person ;
+ foaf:name "Person McNamington" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "OSF" .
+
+ dcterms:identifier "https://doi.org/11.111/something-or-other" .
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/preprint_full.datacite.json b/osf_tests/metadata/expected_metadata_files/preprint_full.datacite.json
new file mode 100644
index 000000000000..b5a0e3a1918d
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/preprint_full.datacite.json
@@ -0,0 +1,124 @@
+{
+ "alternateIdentifiers": [
+ {
+ "alternateIdentifier": "http://localhost:5000/w4ibb",
+ "alternateIdentifierType": "URL"
+ }
+ ],
+ "contributors": [
+ {
+ "contributorName": {
+ "contributorName": "Center for Open Science",
+ "nameType": "Organizational"
+ },
+ "contributorType": "HostingInstitution",
+ "nameIdentifier": {
+ "nameIdentifier": "https://cos.io/",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "creators": [
+ {
+ "creatorName": {
+ "creatorName": "Person McNamington",
+ "nameType": "Personal"
+ },
+ "nameIdentifier": {
+ "nameIdentifier": "http://localhost:5000/w1ibb",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "dates": [
+ {
+ "date": "2123-05-04",
+ "dateType": "Created"
+ },
+ {
+ "date": "2123-05-04",
+ "dateType": "Updated"
+ }
+ ],
+ "descriptions": [
+ {
+ "description": "this is a preprint description!",
+ "descriptionType": "Abstract"
+ }
+ ],
+ "fundingReferences": [],
+ "identifier": {
+ "identifier": "11.pp/FK2osf.io/w4ibb",
+ "identifierType": "DOI"
+ },
+ "publicationYear": "2123",
+ "publisher": "PP the Preprint Provider",
+ "relatedIdentifiers": [
+ {
+ "relatedIdentifier": "11.111/something-or-other",
+ "relatedIdentifierType": "DOI",
+ "relationType": "HasVersion"
+ },
+ {
+ "relatedIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedIdentifierType": "DOI",
+ "relationType": "IsSupplementedBy"
+ }
+ ],
+ "relatedItems": [
+ {
+ "publisher": "OSF",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "11.111/something-or-other",
+ "relatedItemIdentifierType": "DOI"
+ },
+ "relatedItemType": "Text",
+ "relationType": "HasVersion",
+ "titles": []
+ },
+ {
+ "publicationYear": "2123",
+ "publisher": "OSF",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedItemIdentifierType": "DOI"
+ },
+ "relatedItemType": "Dataset",
+ "relationType": "IsSupplementedBy",
+ "titles": [
+ {
+ "lang": "en",
+ "title": "this is a project title!"
+ }
+ ]
+ }
+ ],
+ "resourceType": {
+ "resourceType": "Preprint",
+ "resourceTypeGeneral": "Preprint"
+ },
+ "rightsList": [],
+ "subjects": [
+ {
+ "subject": "wibbble",
+ "subjectScheme": "bepress Digital Commons Three-Tiered Taxonomy"
+ },
+ {
+ "subject": "wibble",
+ "subjectScheme": "bepress Digital Commons Three-Tiered Taxonomy"
+ },
+ {
+ "subject": "wobbble",
+ "subjectScheme": "bepress Digital Commons Three-Tiered Taxonomy"
+ },
+ {
+ "subject": "wobble",
+ "subjectScheme": "bepress Digital Commons Three-Tiered Taxonomy"
+ }
+ ],
+ "titles": [
+ {
+ "title": "this is a preprint title!"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/preprint_full.datacite.xml b/osf_tests/metadata/expected_metadata_files/preprint_full.datacite.xml
new file mode 100644
index 000000000000..e14b0ee5e19d
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/preprint_full.datacite.xml
@@ -0,0 +1,60 @@
+
+
+ 11.pp/FK2osf.io/w4ibb
+
+
+ Person McNamington
+ http://localhost:5000/w1ibb
+
+
+
+ this is a preprint title!
+
+ PP the Preprint Provider
+ 2123
+
+ wibbble
+ wibble
+ wobbble
+ wobble
+
+
+
+ Center for Open Science
+ https://ror.org/05d5mza29
+ https://cos.io/
+
+
+
+ 2123-05-04
+ 2123-05-04
+
+ Preprint
+
+ http://localhost:5000/w4ibb
+
+
+
+ this is a preprint description!
+
+
+
+ 11.111/something-or-other
+ 10.70102/FK2osf.io/w2ibb
+
+
+
+ 11.111/something-or-other
+
+ OSF
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+ this is a project title!
+
+ 2123
+ OSF
+
+
+
diff --git a/osf_tests/metadata/expected_metadata_files/preprint_full.turtle b/osf_tests/metadata/expected_metadata_files/preprint_full.turtle
new file mode 100644
index 000000000000..1f09276e5f82
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/preprint_full.turtle
@@ -0,0 +1,49 @@
+@prefix dcterms: .
+@prefix foaf: .
+@prefix osf: .
+@prefix owl: .
+
+ a osf:Preprint ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:description "this is a preprint description!" ;
+ dcterms:hasVersion ;
+ dcterms:identifier "http://localhost:5000/w4ibb",
+ "https://doi.org/11.pp/FK2osf.io/w4ibb" ;
+ dcterms:modified "2123-05-04" ;
+ dcterms:publisher ;
+ dcterms:subject "wibbble",
+ "wibble",
+ "wobbble",
+ "wobble" ;
+ dcterms:title "this is a preprint title!" ;
+ owl:sameAs ;
+ osf:isSupplementedBy ;
+ osf:statedConflictOfInterest osf:no-conflict-of-interest .
+
+ a osf:Project ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:identifier "http://localhost:5000/w2ibb",
+ "https://doi.org/10.70102/FK2osf.io/w2ibb" ;
+ dcterms:publisher ;
+ dcterms:title "this is a project title!"@en ;
+ dcterms:type "Dataset" ;
+ owl:sameAs .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/preprints/preprovi" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "PP the Preprint Provider" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/w1ibb" ;
+ dcterms:type foaf:Person ;
+ foaf:name "Person McNamington" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "OSF" .
+
+ dcterms:identifier "https://doi.org/11.111/something-or-other" .
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/project_basic.datacite.json b/osf_tests/metadata/expected_metadata_files/project_basic.datacite.json
new file mode 100644
index 000000000000..6ac9aa93d916
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/project_basic.datacite.json
@@ -0,0 +1,115 @@
+{
+ "alternateIdentifiers": [
+ {
+ "alternateIdentifier": "http://localhost:5000/w2ibb",
+ "alternateIdentifierType": "URL"
+ }
+ ],
+ "contributors": [
+ {
+ "contributorName": {
+ "contributorName": "Center for Open Science",
+ "nameType": "Organizational"
+ },
+ "contributorType": "HostingInstitution",
+ "nameIdentifier": {
+ "nameIdentifier": "https://cos.io/",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "creators": [
+ {
+ "creatorName": {
+ "creatorName": "Person McNamington",
+ "nameType": "Personal"
+ },
+ "nameIdentifier": {
+ "nameIdentifier": "http://localhost:5000/w1ibb",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "dates": [
+ {
+ "date": "2123-05-04",
+ "dateType": "Created"
+ },
+ {
+ "date": "2123-05-04",
+ "dateType": "Updated"
+ }
+ ],
+ "descriptions": [
+ {
+ "description": "this is a project description!",
+ "descriptionType": "Abstract"
+ }
+ ],
+ "fundingReferences": [],
+ "identifier": {
+ "identifier": "10.70102/FK2osf.io/w2ibb",
+ "identifierType": "DOI"
+ },
+ "publicationYear": "2252",
+ "publisher": "OSF",
+ "relatedIdentifiers": [
+ {
+ "relatedIdentifier": "http://localhost:5000/w5ibb",
+ "relatedIdentifierType": "URL",
+ "relationType": "HasVersion"
+ },
+ {
+ "relatedIdentifier": "11.pp/FK2osf.io/w4ibb",
+ "relatedIdentifierType": "DOI",
+ "relationType": "IsSupplementTo"
+ }
+ ],
+ "relatedItems": [
+ {
+ "publicationYear": "2252",
+ "publisher": "RegiProvi the Registration Provider",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "http://localhost:5000/w5ibb",
+ "relatedItemIdentifierType": "URL"
+ },
+ "relatedItemType": "Text",
+ "relationType": "HasVersion",
+ "titles": [
+ {
+ "title": "this is a project title!"
+ }
+ ]
+ },
+ {
+ "publicationYear": "2123",
+ "publisher": "PP the Preprint Provider",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "11.pp/FK2osf.io/w4ibb",
+ "relatedItemIdentifierType": "DOI"
+ },
+ "relatedItemType": "Preprint",
+ "relationType": "IsSupplementTo",
+ "titles": [
+ {
+ "title": "this is a preprint title!"
+ }
+ ]
+ }
+ ],
+ "resourceType": {
+ "resourceType": "Project",
+ "resourceTypeGeneral": "Text"
+ },
+ "rightsList": [
+ {
+ "rights": "No license"
+ }
+ ],
+ "subjects": [],
+ "titles": [
+ {
+ "title": "this is a project title!"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/project_basic.datacite.xml b/osf_tests/metadata/expected_metadata_files/project_basic.datacite.xml
new file mode 100644
index 000000000000..2460a1c4e208
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/project_basic.datacite.xml
@@ -0,0 +1,60 @@
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+
+ Person McNamington
+ http://localhost:5000/w1ibb
+
+
+
+ this is a project title!
+
+ OSF
+ 2252
+
+
+
+ Center for Open Science
+ https://ror.org/05d5mza29
+ https://cos.io/
+
+
+
+ 2123-05-04
+ 2123-05-04
+
+ Project
+
+ http://localhost:5000/w2ibb
+
+
+ No license
+
+
+ this is a project description!
+
+
+
+ http://localhost:5000/w5ibb
+ 11.pp/FK2osf.io/w4ibb
+
+
+
+ http://localhost:5000/w5ibb
+
+ this is a project title!
+
+ 2252
+ RegiProvi the Registration Provider
+
+
+ 11.pp/FK2osf.io/w4ibb
+
+ this is a preprint title!
+
+ 2123
+ PP the Preprint Provider
+
+
+
diff --git a/osf_tests/metadata/expected_metadata_files/project_basic.turtle b/osf_tests/metadata/expected_metadata_files/project_basic.turtle
new file mode 100644
index 000000000000..a3daa77ef9a4
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/project_basic.turtle
@@ -0,0 +1,66 @@
+@prefix dcterms: .
+@prefix foaf: .
+@prefix osf: .
+@prefix owl: .
+
+ a osf:Project ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:dateCopyrighted "2252" ;
+ dcterms:description "this is a project description!" ;
+ dcterms:hasVersion ;
+ dcterms:identifier "http://localhost:5000/w2ibb",
+ "https://doi.org/10.70102/FK2osf.io/w2ibb" ;
+ dcterms:modified "2123-05-04" ;
+ dcterms:publisher ;
+ dcterms:rights [ foaf:name "No license" ] ;
+ dcterms:rightsHolder "Me",
+ "You" ;
+ dcterms:title "this is a project title!" ;
+ owl:sameAs ;
+ osf:contains ;
+ osf:supplements .
+
+ a osf:Preprint ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:identifier "http://localhost:5000/w4ibb",
+ "https://doi.org/11.pp/FK2osf.io/w4ibb" ;
+ dcterms:publisher ;
+ dcterms:title "this is a preprint title!" ;
+ owl:sameAs .
+
+ a osf:Registration ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:identifier "http://localhost:5000/w5ibb" ;
+ dcterms:publisher ;
+ dcterms:title "this is a project title!" .
+
+ a osf:File ;
+ dcterms:created "2123-05-04" ;
+ dcterms:identifier "http://localhost:5000/w3ibb" ;
+ dcterms:modified "2123-05-04" ;
+ osf:fileName "my-file.blarg" ;
+ osf:filePath "/my-file.blarg" ;
+ osf:isContainedBy .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/registries/regiprovi" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "RegiProvi the Registration Provider" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/preprints/preprovi" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "PP the Preprint Provider" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/w1ibb" ;
+ dcterms:type foaf:Person ;
+ foaf:name "Person McNamington" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "OSF" .
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/project_full.datacite.json b/osf_tests/metadata/expected_metadata_files/project_full.datacite.json
new file mode 100644
index 000000000000..0a5d1c1db77d
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/project_full.datacite.json
@@ -0,0 +1,132 @@
+{
+ "alternateIdentifiers": [
+ {
+ "alternateIdentifier": "http://localhost:5000/w2ibb",
+ "alternateIdentifierType": "URL"
+ }
+ ],
+ "contributors": [
+ {
+ "contributorName": {
+ "contributorName": "Center for Open Science",
+ "nameType": "Organizational"
+ },
+ "contributorType": "HostingInstitution",
+ "nameIdentifier": {
+ "nameIdentifier": "https://cos.io/",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "creators": [
+ {
+ "creatorName": {
+ "creatorName": "Person McNamington",
+ "nameType": "Personal"
+ },
+ "nameIdentifier": {
+ "nameIdentifier": "http://localhost:5000/w1ibb",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "dates": [
+ {
+ "date": "2123-05-04",
+ "dateType": "Created"
+ },
+ {
+ "date": "2123-05-04",
+ "dateType": "Updated"
+ }
+ ],
+ "descriptions": [
+ {
+ "description": "this is a project description!",
+ "descriptionType": "Abstract",
+ "lang": "en"
+ }
+ ],
+ "fundingReferences": [
+ {
+ "awardNumber": {
+ "awardNumber": "10000000",
+ "awardURI": "https://moneypockets.example/millions"
+ },
+ "awardTitle": "because reasons",
+ "funderIdentifier": {
+ "funderIdentifier": "https://doi.org/10.$$$$",
+ "funderIdentifierType": "Crossref Funder ID"
+ },
+ "funderName": "Mx. Moneypockets"
+ }
+ ],
+ "identifier": {
+ "identifier": "10.70102/FK2osf.io/w2ibb",
+ "identifierType": "DOI"
+ },
+ "language": "en",
+ "publicationYear": "2123",
+ "publisher": "OSF",
+ "relatedIdentifiers": [
+ {
+ "relatedIdentifier": "http://localhost:5000/w5ibb",
+ "relatedIdentifierType": "URL",
+ "relationType": "HasVersion"
+ },
+ {
+ "relatedIdentifier": "11.pp/FK2osf.io/w4ibb",
+ "relatedIdentifierType": "DOI",
+ "relationType": "IsSupplementTo"
+ }
+ ],
+ "relatedItems": [
+ {
+ "publicationYear": "2123",
+ "publisher": "RegiProvi the Registration Provider",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "http://localhost:5000/w5ibb",
+ "relatedItemIdentifierType": "URL"
+ },
+ "relatedItemType": "Text",
+ "relationType": "HasVersion",
+ "titles": [
+ {
+ "title": "this is a project title!"
+ }
+ ]
+ },
+ {
+ "publicationYear": "2123",
+ "publisher": "PP the Preprint Provider",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "11.pp/FK2osf.io/w4ibb",
+ "relatedItemIdentifierType": "DOI"
+ },
+ "relatedItemType": "Preprint",
+ "relationType": "IsSupplementTo",
+ "titles": [
+ {
+ "title": "this is a preprint title!"
+ }
+ ]
+ }
+ ],
+ "resourceType": {
+ "resourceType": "Project",
+ "resourceTypeGeneral": "Dataset"
+ },
+ "rightsList": [
+ {
+ "rights": "CC-By Attribution-NonCommercial-NoDerivatives 4.0 International",
+ "rightsURI": "https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode"
+ }
+ ],
+ "subjects": [],
+ "titles": [
+ {
+ "lang": "en",
+ "title": "this is a project title!"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/project_full.datacite.xml b/osf_tests/metadata/expected_metadata_files/project_full.datacite.xml
new file mode 100644
index 000000000000..3e923f76cc97
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/project_full.datacite.xml
@@ -0,0 +1,68 @@
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+
+ Person McNamington
+ http://localhost:5000/w1ibb
+
+
+
+ this is a project title!
+
+ OSF
+ 2123
+
+
+
+ Center for Open Science
+ https://ror.org/05d5mza29
+ https://cos.io/
+
+
+
+ 2123-05-04
+ 2123-05-04
+
+ en
+ Project
+
+ http://localhost:5000/w2ibb
+
+
+ CC-By Attribution-NonCommercial-NoDerivatives 4.0 International
+
+
+ this is a project description!
+
+
+
+ Mx. Moneypockets
+ https://doi.org/10.$$$$
+ 10000000
+ because reasons
+
+
+
+ http://localhost:5000/w5ibb
+ 11.pp/FK2osf.io/w4ibb
+
+
+
+ http://localhost:5000/w5ibb
+
+ this is a project title!
+
+ 2123
+ RegiProvi the Registration Provider
+
+
+ 11.pp/FK2osf.io/w4ibb
+
+ this is a preprint title!
+
+ 2123
+ PP the Preprint Provider
+
+
+
diff --git a/osf_tests/metadata/expected_metadata_files/project_full.turtle b/osf_tests/metadata/expected_metadata_files/project_full.turtle
new file mode 100644
index 000000000000..dc9a2757cb1d
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/project_full.turtle
@@ -0,0 +1,78 @@
+@prefix dcterms: .
+@prefix foaf: .
+@prefix osf: .
+@prefix owl: .
+
+ a osf:Project ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:dateCopyrighted "2250-2254" ;
+ dcterms:description "this is a project description!"@en ;
+ dcterms:hasVersion ;
+ dcterms:identifier "http://localhost:5000/w2ibb",
+ "https://doi.org/10.70102/FK2osf.io/w2ibb" ;
+ dcterms:language "en" ;
+ dcterms:modified "2123-05-04" ;
+ dcterms:publisher ;
+ dcterms:rights ;
+ dcterms:rightsHolder "Me",
+ "You" ;
+ dcterms:title "this is a project title!"@en ;
+ dcterms:type "Dataset" ;
+ owl:sameAs ;
+ osf:contains ;
+ osf:funder [ a osf:FundingReference ;
+ dcterms:identifier "https://doi.org/10.$$$$" ;
+ foaf:name "Mx. Moneypockets" ;
+ osf:awardNumber "10000000" ;
+ osf:awardTitle "because reasons" ;
+ osf:awardUri "https://moneypockets.example/millions" ;
+ osf:funderIdentifierType "Crossref Funder ID" ] ;
+ osf:supplements .
+
+ a osf:Preprint ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:identifier "http://localhost:5000/w4ibb",
+ "https://doi.org/11.pp/FK2osf.io/w4ibb" ;
+ dcterms:publisher ;
+ dcterms:title "this is a preprint title!" ;
+ owl:sameAs .
+
+ a osf:Registration ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:identifier "http://localhost:5000/w5ibb" ;
+ dcterms:publisher ;
+ dcterms:title "this is a project title!" .
+
+ a osf:File ;
+ dcterms:created "2123-05-04" ;
+ dcterms:identifier "http://localhost:5000/w3ibb" ;
+ dcterms:modified "2123-05-04" ;
+ osf:fileName "my-file.blarg" ;
+ osf:filePath "/my-file.blarg" ;
+ osf:isContainedBy .
+
+ dcterms:identifier "https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode" ;
+ foaf:name "CC-By Attribution-NonCommercial-NoDerivatives 4.0 International" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/registries/regiprovi" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "RegiProvi the Registration Provider" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/preprints/preprovi" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "PP the Preprint Provider" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/w1ibb" ;
+ dcterms:type foaf:Person ;
+ foaf:name "Person McNamington" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "OSF" .
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/registration_basic.datacite.json b/osf_tests/metadata/expected_metadata_files/registration_basic.datacite.json
new file mode 100644
index 000000000000..0104ee7feed7
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/registration_basic.datacite.json
@@ -0,0 +1,95 @@
+{
+ "alternateIdentifiers": [
+ {
+ "alternateIdentifier": "http://localhost:5000/w5ibb",
+ "alternateIdentifierType": "URL"
+ }
+ ],
+ "contributors": [
+ {
+ "contributorName": {
+ "contributorName": "Center for Open Science",
+ "nameType": "Organizational"
+ },
+ "contributorType": "HostingInstitution",
+ "nameIdentifier": {
+ "nameIdentifier": "https://cos.io/",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "creators": [
+ {
+ "creatorName": {
+ "creatorName": "Person McNamington",
+ "nameType": "Personal"
+ },
+ "nameIdentifier": {
+ "nameIdentifier": "http://localhost:5000/w1ibb",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "dates": [
+ {
+ "date": "2123-05-04",
+ "dateType": "Created"
+ },
+ {
+ "date": "2123-05-04",
+ "dateType": "Updated"
+ }
+ ],
+ "descriptions": [
+ {
+ "description": "this is a project description!",
+ "descriptionType": "Abstract"
+ }
+ ],
+ "fundingReferences": [],
+ "identifier": {
+ "identifier": "http://localhost:5000/w5ibb",
+ "identifierType": "URL"
+ },
+ "publicationYear": "2252",
+ "publisher": "RegiProvi the Registration Provider",
+ "relatedIdentifiers": [
+ {
+ "relatedIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedIdentifierType": "DOI",
+ "relationType": "IsVersionOf"
+ }
+ ],
+ "relatedItems": [
+ {
+ "publicationYear": "2252",
+ "publisher": "OSF",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedItemIdentifierType": "DOI"
+ },
+ "relatedItemType": "Text",
+ "relationType": "IsVersionOf",
+ "titles": [
+ {
+ "title": "this is a project title!"
+ }
+ ]
+ }
+ ],
+ "resourceType": {
+ "resourceType": "Pre-registration",
+ "resourceTypeGeneral": "Text"
+ },
+ "rightsList": [
+ {
+ "rights": "No license"
+ }
+ ],
+ "subjects": [],
+ "titles": [
+ {
+ "title": "this is a project title!"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/registration_basic.datacite.xml b/osf_tests/metadata/expected_metadata_files/registration_basic.datacite.xml
new file mode 100644
index 000000000000..8b4c0977f9c8
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/registration_basic.datacite.xml
@@ -0,0 +1,51 @@
+
+
+ http://localhost:5000/w5ibb
+
+
+ Person McNamington
+ http://localhost:5000/w1ibb
+
+
+
+ this is a project title!
+
+ RegiProvi the Registration Provider
+ 2252
+
+
+
+ Center for Open Science
+ https://ror.org/05d5mza29
+ https://cos.io/
+
+
+
+ 2123-05-04
+ 2123-05-04
+
+ Pre-registration
+
+ http://localhost:5000/w5ibb
+
+
+ No license
+
+
+ this is a project description!
+
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+ this is a project title!
+
+ 2252
+ OSF
+
+
+
diff --git a/osf_tests/metadata/expected_metadata_files/registration_basic.turtle b/osf_tests/metadata/expected_metadata_files/registration_basic.turtle
new file mode 100644
index 000000000000..b8cfcd694699
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/registration_basic.turtle
@@ -0,0 +1,42 @@
+@prefix dcterms: .
+@prefix foaf: .
+@prefix osf: .
+@prefix owl: .
+
+ a osf:Registration ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:dateCopyrighted "2252" ;
+ dcterms:description "this is a project description!" ;
+ dcterms:identifier "http://localhost:5000/w5ibb" ;
+ dcterms:isVersionOf ;
+ dcterms:modified "2123-05-04" ;
+ dcterms:publisher ;
+ dcterms:rights [ foaf:name "No license" ] ;
+ dcterms:rightsHolder "Me",
+ "You" ;
+ dcterms:title "this is a project title!" .
+
+ a osf:Project ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:identifier "http://localhost:5000/w2ibb",
+ "https://doi.org/10.70102/FK2osf.io/w2ibb" ;
+ dcterms:publisher ;
+ dcterms:title "this is a project title!" ;
+ owl:sameAs .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/registries/regiprovi" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "RegiProvi the Registration Provider" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/w1ibb" ;
+ dcterms:type foaf:Person ;
+ foaf:name "Person McNamington" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "OSF" .
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/registration_full.datacite.json b/osf_tests/metadata/expected_metadata_files/registration_full.datacite.json
new file mode 100644
index 000000000000..01b095d09bb0
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/registration_full.datacite.json
@@ -0,0 +1,97 @@
+{
+ "alternateIdentifiers": [
+ {
+ "alternateIdentifier": "http://localhost:5000/w5ibb",
+ "alternateIdentifierType": "URL"
+ }
+ ],
+ "contributors": [
+ {
+ "contributorName": {
+ "contributorName": "Center for Open Science",
+ "nameType": "Organizational"
+ },
+ "contributorType": "HostingInstitution",
+ "nameIdentifier": {
+ "nameIdentifier": "https://cos.io/",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "creators": [
+ {
+ "creatorName": {
+ "creatorName": "Person McNamington",
+ "nameType": "Personal"
+ },
+ "nameIdentifier": {
+ "nameIdentifier": "http://localhost:5000/w1ibb",
+ "nameIdentifierScheme": "URL"
+ }
+ }
+ ],
+ "dates": [
+ {
+ "date": "2123-05-04",
+ "dateType": "Created"
+ },
+ {
+ "date": "2123-05-04",
+ "dateType": "Updated"
+ }
+ ],
+ "descriptions": [
+ {
+ "description": "this is a project description!",
+ "descriptionType": "Abstract"
+ }
+ ],
+ "fundingReferences": [],
+ "identifier": {
+ "identifier": "http://localhost:5000/w5ibb",
+ "identifierType": "URL"
+ },
+ "publicationYear": "2123",
+ "publisher": "RegiProvi the Registration Provider",
+ "relatedIdentifiers": [
+ {
+ "relatedIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedIdentifierType": "DOI",
+ "relationType": "IsVersionOf"
+ }
+ ],
+ "relatedItems": [
+ {
+ "publicationYear": "2123",
+ "publisher": "OSF",
+ "relatedItemIdentifier": {
+ "relatedItemIdentifier": "10.70102/FK2osf.io/w2ibb",
+ "relatedItemIdentifierType": "DOI"
+ },
+ "relatedItemType": "Dataset",
+ "relationType": "IsVersionOf",
+ "titles": [
+ {
+ "lang": "en",
+ "title": "this is a project title!"
+ }
+ ]
+ }
+ ],
+ "resourceType": {
+ "resourceType": "Pre-registration",
+ "resourceTypeGeneral": "Text"
+ },
+ "rightsList": [
+ {
+ "rights": "CC-By Attribution-NonCommercial-NoDerivatives 4.0 International",
+ "rightsURI": "https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode"
+ }
+ ],
+ "subjects": [],
+ "titles": [
+ {
+ "title": "this is a project title!"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/registration_full.datacite.xml b/osf_tests/metadata/expected_metadata_files/registration_full.datacite.xml
new file mode 100644
index 000000000000..a0f669ff9acc
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/registration_full.datacite.xml
@@ -0,0 +1,51 @@
+
+
+ http://localhost:5000/w5ibb
+
+
+ Person McNamington
+ http://localhost:5000/w1ibb
+
+
+
+ this is a project title!
+
+ RegiProvi the Registration Provider
+ 2123
+
+
+
+ Center for Open Science
+ https://ror.org/05d5mza29
+ https://cos.io/
+
+
+
+ 2123-05-04
+ 2123-05-04
+
+ Pre-registration
+
+ http://localhost:5000/w5ibb
+
+
+ CC-By Attribution-NonCommercial-NoDerivatives 4.0 International
+
+
+ this is a project description!
+
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+
+
+ 10.70102/FK2osf.io/w2ibb
+
+ this is a project title!
+
+ 2123
+ OSF
+
+
+
diff --git a/osf_tests/metadata/expected_metadata_files/registration_full.turtle b/osf_tests/metadata/expected_metadata_files/registration_full.turtle
new file mode 100644
index 000000000000..72dcd4d28e61
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/registration_full.turtle
@@ -0,0 +1,46 @@
+@prefix dcterms: .
+@prefix foaf: .
+@prefix osf: .
+@prefix owl: .
+
+ a osf:Registration ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:dateCopyrighted "2250-2254" ;
+ dcterms:description "this is a project description!" ;
+ dcterms:identifier "http://localhost:5000/w5ibb" ;
+ dcterms:isVersionOf ;
+ dcterms:modified "2123-05-04" ;
+ dcterms:publisher ;
+ dcterms:rights ;
+ dcterms:rightsHolder "Me",
+ "You" ;
+ dcterms:title "this is a project title!" .
+
+ a osf:Project ;
+ dcterms:created "2123-05-04" ;
+ dcterms:creator ;
+ dcterms:identifier "http://localhost:5000/w2ibb",
+ "https://doi.org/10.70102/FK2osf.io/w2ibb" ;
+ dcterms:publisher ;
+ dcterms:title "this is a project title!"@en ;
+ dcterms:type "Dataset" ;
+ owl:sameAs .
+
+ dcterms:identifier "https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode" ;
+ foaf:name "CC-By Attribution-NonCommercial-NoDerivatives 4.0 International" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/registries/regiprovi" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "RegiProvi the Registration Provider" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/w1ibb" ;
+ dcterms:type foaf:Person ;
+ foaf:name "Person McNamington" .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000" ;
+ dcterms:type foaf:Organization ;
+ foaf:name "OSF" .
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/user_basic.turtle b/osf_tests/metadata/expected_metadata_files/user_basic.turtle
new file mode 100644
index 000000000000..3ec5dc0c74a0
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/user_basic.turtle
@@ -0,0 +1,8 @@
+@prefix dcterms: .
+@prefix foaf: .
+@prefix osf: .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/w1ibb" ;
+ dcterms:type foaf:Person ;
+ foaf:name "Person McNamington" .
\ No newline at end of file
diff --git a/osf_tests/metadata/expected_metadata_files/user_full.turtle b/osf_tests/metadata/expected_metadata_files/user_full.turtle
new file mode 100644
index 000000000000..3ec5dc0c74a0
--- /dev/null
+++ b/osf_tests/metadata/expected_metadata_files/user_full.turtle
@@ -0,0 +1,8 @@
+@prefix dcterms: .
+@prefix foaf: .
+@prefix osf: .
+
+ a osf:Agent ;
+ dcterms:identifier "http://localhost:5000/w1ibb" ;
+ dcterms:type foaf:Person ;
+ foaf:name "Person McNamington" .
\ No newline at end of file
diff --git a/osf_tests/metadata/test_metadata_download.py b/osf_tests/metadata/test_metadata_download.py
deleted file mode 100644
index 1ac062acd056..000000000000
--- a/osf_tests/metadata/test_metadata_download.py
+++ /dev/null
@@ -1,655 +0,0 @@
-from api_tests.utils import create_test_file
-from osf.models import GuidMetadataRecord
-from osf.models.licenses import NodeLicense
-from osf_tests import factories
-from tests.base import OsfTestCase
-
-
-class TestMetadataDownload(OsfTestCase):
- def test_metadata_download(self):
- user = factories.AuthUserFactory(
- fullname='Person McNamington',
- )
- project = factories.ProjectFactory(
- creator=user,
- title='this is a project title!',
- description='this is a project description!',
- node_license=factories.NodeLicenseRecordFactory(
- node_license=NodeLicense.objects.get(
- name='No license',
- ),
- year='2252',
- copyright_holders=['Me', 'You'],
- ),
- )
- project.set_identifier_value(category='doi', value=f'10.70102/FK2osf.io/{project._id}')
-
- # unauthed, private project
- resp = self.app.get(f'/{project._id}/metadata/?format=datacite-xml')
- assert resp.status_code == 302
-
- today = project.created.date()
- format_kwargs = {
- 'project_id': project._id,
- 'user_id': user._id,
- 'date': str(today),
- 'license_year': project.node_license.year,
- 'project_created_year': project.created.year,
- }
-
- resp = self.app.get(f'/{project._id}/metadata/?format=turtle', auth=user.auth)
- assert resp.status_code == 200
- assert resp.content_type == 'text/turtle'
- assert resp.content_disposition == f'attachment; filename={project._id}-metadata.ttl'
- assert resp.unicode_body == BASIC_TURTLE.format(**format_kwargs)
-
- resp = self.app.get(f'/{project._id}/metadata/?format=datacite-xml', auth=user.auth)
- assert resp.status_code == 200
- assert resp.content_type == 'application/xml'
- assert resp.content_disposition == f'attachment; filename={project._id}-datacite.xml'
- assert resp.unicode_body == BASIC_DATACITE_XML.format(**format_kwargs)
-
- resp = self.app.get(f'/{project._id}/metadata/?format=datacite-json', auth=user.auth)
- assert resp.status_code == 200
- assert resp.content_type == 'application/json'
- assert resp.content_disposition == f'attachment; filename={project._id}-datacite.json'
- assert resp.unicode_body == BASIC_DATACITE_JSON.format(**format_kwargs)
-
- metadata_record = GuidMetadataRecord.objects.for_guid(project._id)
- metadata_record.update({
- 'language': 'en',
- 'resource_type_general': 'Dataset',
- 'funding_info': [
- {
- 'funder_name': 'Mx. Moneypockets',
- 'funder_identifier': 'https://doi.org/10.$$$$',
- 'funder_identifier_type': 'Crossref Funder ID',
- 'award_number': '10000000',
- 'award_uri': 'https://moneypockets.example/millions',
- 'award_title': 'because reasons',
- },
- ],
- }, auth=user)
- project.node_license.node_license = NodeLicense.objects.get(
- name='CC-By Attribution-NonCommercial-NoDerivatives 4.0 International',
- )
- project.node_license.year = '2250-2254'
- project.node_license.save()
-
- file = create_test_file(
- project,
- user,
- filename='my-file.blarg',
- size=7,
- sha256='6ac3c336e4094835293a3fed8a4b5fedde1b5e2626d9838fed50693bba00af0e',
- )
- file_guid = file.get_guid()._id
- format_kwargs['file_id'] = file_guid
- format_kwargs['raw_file_id'] = file._id
- format_kwargs['fileversion_id'] = file.versions.first().identifier
-
- resp = self.app.get(f'/{project._id}/metadata/?format=turtle', auth=user.auth)
- assert resp.status_code == 200
- assert resp.content_type == 'text/turtle'
- assert resp.content_disposition == f'attachment; filename={project._id}-metadata.ttl'
- assert resp.unicode_body == COMPLICATED_TURTLE.format(**format_kwargs)
-
- resp = self.app.get(f'/{project._id}/metadata/?format=datacite-xml', auth=user.auth)
- assert resp.status_code == 200
- assert resp.content_type == 'application/xml'
- assert resp.content_disposition == f'attachment; filename={project._id}-datacite.xml'
- assert resp.unicode_body == COMPLICATED_DATACITE_XML.format(**format_kwargs)
-
- resp = self.app.get(f'/{project._id}/metadata/?format=datacite-json', auth=user.auth)
- assert resp.status_code == 200
- assert resp.content_type == 'application/json'
- assert resp.content_disposition == f'attachment; filename={project._id}-datacite.json'
- assert resp.unicode_body == COMPLICATED_DATACITE_JSON.format(**format_kwargs)
-
- ### now check that file
- format_kwargs['file_created_year'] = file.created.year
- resp = self.app.get(f'/{file_guid}/metadata/?format=turtle', auth=user.auth)
- assert resp.status_code == 200
- assert resp.content_type == 'text/turtle'
- assert resp.content_disposition == f'attachment; filename={file_guid}-metadata.ttl'
- assert resp.unicode_body == FILE_TURTLE.format(**format_kwargs)
-
- resp = self.app.get(f'/{file_guid}/metadata/?format=datacite-xml', auth=user.auth)
- assert resp.status_code == 200
- assert resp.content_type == 'application/xml'
- assert resp.content_disposition == f'attachment; filename={file_guid}-datacite.xml'
- assert resp.unicode_body == FILE_DATACITE_XML.format(**format_kwargs)
-
- resp = self.app.get(f'/{file_guid}/metadata/?format=datacite-json', auth=user.auth)
- assert resp.status_code == 200
- assert resp.content_type == 'application/json'
- assert resp.content_disposition == f'attachment; filename={file_guid}-datacite.json'
- assert resp.unicode_body == FILE_DATACITE_JSON.format(**format_kwargs)
-
-
-BASIC_TURTLE = '''@prefix dcterms: .
-@prefix foaf: .
-@prefix osf: .
-@prefix owl: .
-
- a osf:Project ;
- dcterms:created "{date}" ;
- dcterms:creator ;
- dcterms:dateCopyrighted "2252" ;
- dcterms:description "this is a project description!" ;
- dcterms:identifier "http://localhost:5000/{project_id}",
- "https://doi.org/10.70102/FK2osf.io/{project_id}" ;
- dcterms:modified "{date}" ;
- dcterms:publisher ;
- dcterms:rights [ foaf:name "No license" ] ;
- dcterms:rightsHolder "Me",
- "You" ;
- dcterms:title "this is a project title!" ;
- owl:sameAs .
-
- a osf:Agent ;
- dcterms:identifier "http://localhost:5000/{user_id}" ;
- dcterms:type foaf:Person ;
- foaf:name "Person McNamington" .
-
- a osf:Agent ;
- dcterms:identifier "http://localhost:5000" ;
- dcterms:type foaf:Organization ;
- foaf:name "OSF" .'''
-
-
-BASIC_DATACITE_XML = '''
-
- 10.70102/FK2osf.io/{project_id}
-
-
- Person McNamington
- http://localhost:5000/{user_id}
-
-
-
- this is a project title!
-
- OSF
- {license_year}
-
-
-
- Center for Open Science
- https://ror.org/05d5mza29
- https://cos.io/
-
-
-
- {date}
- {date}
-
- Project
-
- http://localhost:5000/{project_id}
-
-
- No license
-
-
- this is a project description!
-
-
-
-
-
-'''
-
-
-# doubled {{}} cleaned by (and necessary for) a call to str.format
-BASIC_DATACITE_JSON = '''{{
- "alternateIdentifiers": [
- {{
- "alternateIdentifier": "http://localhost:5000/{project_id}",
- "alternateIdentifierType": "URL"
- }}
- ],
- "contributors": [
- {{
- "contributorName": {{
- "contributorName": "Center for Open Science",
- "nameType": "Organizational"
- }},
- "contributorType": "HostingInstitution",
- "nameIdentifier": {{
- "nameIdentifier": "https://cos.io/",
- "nameIdentifierScheme": "URL"
- }}
- }}
- ],
- "creators": [
- {{
- "creatorName": {{
- "creatorName": "Person McNamington",
- "nameType": "Personal"
- }},
- "nameIdentifier": {{
- "nameIdentifier": "http://localhost:5000/{user_id}",
- "nameIdentifierScheme": "URL"
- }}
- }}
- ],
- "dates": [
- {{
- "date": "{date}",
- "dateType": "Created"
- }},
- {{
- "date": "{date}",
- "dateType": "Updated"
- }}
- ],
- "descriptions": [
- {{
- "description": "this is a project description!",
- "descriptionType": "Abstract"
- }}
- ],
- "fundingReferences": [],
- "identifier": {{
- "identifier": "10.70102/FK2osf.io/{project_id}",
- "identifierType": "DOI"
- }},
- "publicationYear": "{license_year}",
- "publisher": "OSF",
- "relatedIdentifiers": [],
- "relatedItems": [],
- "resourceType": {{
- "resourceType": "Project",
- "resourceTypeGeneral": "Text"
- }},
- "rightsList": [
- {{
- "rights": "No license"
- }}
- ],
- "subjects": [],
- "titles": [
- {{
- "title": "this is a project title!"
- }}
- ]
-}}'''
-
-
-COMPLICATED_TURTLE = '''@prefix dcterms: .
-@prefix foaf: .
-@prefix osf: .
-@prefix owl: .
-
- a osf:Project ;
- dcterms:created "{date}" ;
- dcterms:creator ;
- dcterms:dateCopyrighted "2250-2254" ;
- dcterms:description "this is a project description!"@en ;
- dcterms:identifier "http://localhost:5000/{project_id}",
- "https://doi.org/10.70102/FK2osf.io/{project_id}" ;
- dcterms:language "en" ;
- dcterms:modified "{date}" ;
- dcterms:publisher ;
- dcterms:rights ;
- dcterms:rightsHolder "Me",
- "You" ;
- dcterms:title "this is a project title!"@en ;
- dcterms:type "Dataset" ;
- owl:sameAs ;
- osf:contains ;
- osf:funder [ a osf:FundingReference ;
- dcterms:identifier "https://doi.org/10.$$$$" ;
- foaf:name "Mx. Moneypockets" ;
- osf:awardNumber "10000000" ;
- osf:awardTitle "because reasons" ;
- osf:awardUri "https://moneypockets.example/millions" ;
- osf:funderIdentifierType "Crossref Funder ID" ] .
-
- a osf:File ;
- dcterms:created "{date}" ;
- dcterms:identifier "http://localhost:5000/{file_id}" ;
- dcterms:modified "{date}" ;
- osf:fileName "my-file.blarg" ;
- osf:filePath "/my-file.blarg" ;
- osf:isContainedBy .
-
- dcterms:identifier "https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode" ;
- foaf:name "CC-By Attribution-NonCommercial-NoDerivatives 4.0 International" .
-
- a osf:Agent ;
- dcterms:identifier "http://localhost:5000/{user_id}" ;
- dcterms:type foaf:Person ;
- foaf:name "Person McNamington" .
-
- a osf:Agent ;
- dcterms:identifier "http://localhost:5000" ;
- dcterms:type foaf:Organization ;
- foaf:name "OSF" .'''
-
-
-COMPLICATED_DATACITE_XML = '''
-
- 10.70102/FK2osf.io/{project_id}
-
-
- Person McNamington
- http://localhost:5000/{user_id}
-
-
-
- this is a project title!
-
- OSF
- {project_created_year}
-
-
-
- Center for Open Science
- https://ror.org/05d5mza29
- https://cos.io/
-
-
-
- {date}
- {date}
-
- en
- Project
-
- http://localhost:5000/{project_id}
-
-
- CC-By Attribution-NonCommercial-NoDerivatives 4.0 International
-
-
- this is a project description!
-
-
-
- Mx. Moneypockets
- https://doi.org/10.$$$$
- 10000000
- because reasons
-
-
-
-
-
-'''
-
-
-COMPLICATED_DATACITE_JSON = '''{{
- "alternateIdentifiers": [
- {{
- "alternateIdentifier": "http://localhost:5000/{project_id}",
- "alternateIdentifierType": "URL"
- }}
- ],
- "contributors": [
- {{
- "contributorName": {{
- "contributorName": "Center for Open Science",
- "nameType": "Organizational"
- }},
- "contributorType": "HostingInstitution",
- "nameIdentifier": {{
- "nameIdentifier": "https://cos.io/",
- "nameIdentifierScheme": "URL"
- }}
- }}
- ],
- "creators": [
- {{
- "creatorName": {{
- "creatorName": "Person McNamington",
- "nameType": "Personal"
- }},
- "nameIdentifier": {{
- "nameIdentifier": "http://localhost:5000/{user_id}",
- "nameIdentifierScheme": "URL"
- }}
- }}
- ],
- "dates": [
- {{
- "date": "{date}",
- "dateType": "Created"
- }},
- {{
- "date": "{date}",
- "dateType": "Updated"
- }}
- ],
- "descriptions": [
- {{
- "description": "this is a project description!",
- "descriptionType": "Abstract",
- "lang": "en"
- }}
- ],
- "fundingReferences": [
- {{
- "awardNumber": {{
- "awardNumber": "10000000",
- "awardURI": "https://moneypockets.example/millions"
- }},
- "awardTitle": "because reasons",
- "funderIdentifier": {{
- "funderIdentifier": "https://doi.org/10.$$$$",
- "funderIdentifierType": "Crossref Funder ID"
- }},
- "funderName": "Mx. Moneypockets"
- }}
- ],
- "identifier": {{
- "identifier": "10.70102/FK2osf.io/{project_id}",
- "identifierType": "DOI"
- }},
- "language": "en",
- "publicationYear": "{project_created_year}",
- "publisher": "OSF",
- "relatedIdentifiers": [],
- "relatedItems": [],
- "resourceType": {{
- "resourceType": "Project",
- "resourceTypeGeneral": "Dataset"
- }},
- "rightsList": [
- {{
- "rights": "CC-By Attribution-NonCommercial-NoDerivatives 4.0 International",
- "rightsURI": "https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode"
- }}
- ],
- "subjects": [],
- "titles": [
- {{
- "lang": "en",
- "title": "this is a project title!"
- }}
- ]
-}}'''
-
-
-FILE_TURTLE = '''@prefix dcterms: .
-@prefix foaf: .
-@prefix osf: .
-@prefix owl: .
-
- a osf:File ;
- dcterms:created "{date}" ;
- dcterms:identifier "http://localhost:5000/{file_id}" ;
- dcterms:modified "{date}" ;
- osf:fileName "my-file.blarg" ;
- osf:filePath "/my-file.blarg" ;
- osf:hasFileVersion ;
- osf:isContainedBy .
-
- a osf:Project ;
- dcterms:created "{date}" ;
- dcterms:creator ;
- dcterms:identifier "http://localhost:5000/{project_id}",
- "https://doi.org/10.70102/FK2osf.io/{project_id}" ;
- dcterms:publisher ;
- dcterms:title "this is a project title!"@en ;
- dcterms:type "Dataset" ;
- owl:sameAs .
-
- a osf:FileVersion ;
- dcterms:created "{date}" ;
- dcterms:creator ;
- dcterms:extent "0.000007 MB" ;
- dcterms:format "img/png" ;
- dcterms:modified "{date}" ;
- dcterms:requires ;
- osf:versionNumber "1" .
-
- a osf:Agent ;
- dcterms:identifier "http://localhost:5000/{user_id}" ;
- dcterms:type foaf:Person ;
- foaf:name "Person McNamington" .
-
- a osf:Agent ;
- dcterms:identifier "http://localhost:5000" ;
- dcterms:type foaf:Organization ;
- foaf:name "OSF" .'''
-
-
-FILE_DATACITE_XML = '''
-
- http://localhost:5000/{file_id}
-
-
- Person McNamington
- http://localhost:5000/{user_id}
-
-
-
- my-file.blarg
-
- OSF
- {project_created_year}
-
-
-
- Center for Open Science
- https://ror.org/05d5mza29
- https://cos.io/
-
-
-
- {date}
- {date}
-
- File
-
- http://localhost:5000/{file_id}
-
-
-
-
-
- 10.70102/FK2osf.io/{project_id}
-
-
-
- 10.70102/FK2osf.io/{project_id}
-
- this is a project title!
-
- {project_created_year}
- OSF
-
-
-
-'''
-
-
-FILE_DATACITE_JSON = '''{{
- "alternateIdentifiers": [
- {{
- "alternateIdentifier": "http://localhost:5000/{file_id}",
- "alternateIdentifierType": "URL"
- }}
- ],
- "contributors": [
- {{
- "contributorName": {{
- "contributorName": "Center for Open Science",
- "nameType": "Organizational"
- }},
- "contributorType": "HostingInstitution",
- "nameIdentifier": {{
- "nameIdentifier": "https://cos.io/",
- "nameIdentifierScheme": "URL"
- }}
- }}
- ],
- "creators": [
- {{
- "creatorName": {{
- "creatorName": "Person McNamington",
- "nameType": "Personal"
- }},
- "nameIdentifier": {{
- "nameIdentifier": "http://localhost:5000/{user_id}",
- "nameIdentifierScheme": "URL"
- }}
- }}
- ],
- "dates": [
- {{
- "date": "{date}",
- "dateType": "Created"
- }},
- {{
- "date": "{date}",
- "dateType": "Updated"
- }}
- ],
- "descriptions": [],
- "fundingReferences": [],
- "identifier": {{
- "identifier": "http://localhost:5000/{file_id}",
- "identifierType": "URL"
- }},
- "publicationYear": "{project_created_year}",
- "publisher": "OSF",
- "relatedIdentifiers": [
- {{
- "relatedIdentifier": "10.70102/FK2osf.io/{project_id}",
- "relatedIdentifierType": "DOI",
- "relationType": "IsPartOf"
- }}
- ],
- "relatedItems": [
- {{
- "publicationYear": "2023",
- "publisher": "OSF",
- "relatedItemIdentifier": {{
- "relatedItemIdentifier": "10.70102/FK2osf.io/{project_id}",
- "relatedItemIdentifierType": "DOI"
- }},
- "relatedItemType": "Dataset",
- "relationType": "IsPartOf",
- "titles": [
- {{
- "lang": "en",
- "title": "this is a project title!"
- }}
- ]
- }}
- ],
- "resourceType": {{
- "resourceType": "File",
- "resourceTypeGeneral": "Text"
- }},
- "rightsList": [],
- "subjects": [],
- "titles": [
- {{
- "title": "my-file.blarg"
- }}
- ]
-}}'''
diff --git a/osf_tests/metadata/test_osf_gathering.py b/osf_tests/metadata/test_osf_gathering.py
index 9b2d846f9610..a1b19f00c4bb 100644
--- a/osf_tests/metadata/test_osf_gathering.py
+++ b/osf_tests/metadata/test_osf_gathering.py
@@ -21,7 +21,6 @@
from osf import models as osfdb
from osf.utils import permissions
from osf_tests import factories
-from website import settings as website_settings
def _get_graph_and_focuses(triples):
@@ -362,9 +361,7 @@ def test_gather_versions(self):
_assert_triples(osf_gathering.gather_versions(self.registrationfocus), set())
# focus: file
fileversion = self.file.versions.first()
- fileversion_iri = URIRef(
- f'{website_settings.API_DOMAIN}v2/files/{self.file._id}/versions/{fileversion.identifier}/',
- )
+ fileversion_iri = URIRef(f'{self.filefocus.iri}?revision={fileversion.identifier}')
_assert_triples(osf_gathering.gather_versions(self.filefocus), {
(self.filefocus.iri, OSF.hasFileVersion, fileversion_iri),
(fileversion_iri, RDF.type, OSF.FileVersion),
diff --git a/osf_tests/metadata/test_serialized_metadata.py b/osf_tests/metadata/test_serialized_metadata.py
new file mode 100644
index 000000000000..48de99eb0fc1
--- /dev/null
+++ b/osf_tests/metadata/test_serialized_metadata.py
@@ -0,0 +1,263 @@
+import datetime
+import pathlib
+from unittest import mock
+
+from osf import models as osfdb
+from osf.metadata.rdfutils import OSF
+from osf.metadata.tools import pls_gather_metadata_file
+from osf.models.licenses import NodeLicense
+from api_tests.utils import create_test_file
+from osf_tests import factories
+from tests.base import OsfTestCase
+
+
+# a directory of metadata files that will be expected as test outputs
+METADATA_SCENARIO_DIR = (
+ pathlib.Path(__file__).parent # alongside this `.py` file
+ / 'expected_metadata_files'
+)
+
+BASIC_METADATA_SCENARIO = {
+ OSF.Project: {
+ 'turtle': 'project_basic.turtle',
+ 'datacite-xml': 'project_basic.datacite.xml',
+ 'datacite-json': 'project_basic.datacite.json',
+ },
+ OSF.Preprint: {
+ 'turtle': 'preprint_basic.turtle',
+ 'datacite-xml': 'preprint_basic.datacite.xml',
+ 'datacite-json': 'preprint_basic.datacite.json',
+ },
+ OSF.Registration: {
+ 'turtle': 'registration_basic.turtle',
+ 'datacite-xml': 'registration_basic.datacite.xml',
+ 'datacite-json': 'registration_basic.datacite.json',
+ },
+ OSF.File: {
+ 'turtle': 'file_basic.turtle',
+ 'datacite-xml': 'file_basic.datacite.xml',
+ 'datacite-json': 'file_basic.datacite.json',
+ },
+ OSF.Agent: {
+ 'turtle': 'user_basic.turtle',
+ },
+}
+
+FULL_METADATA_SCENARIO = {
+ OSF.Project: {
+ 'turtle': 'project_full.turtle',
+ 'datacite-xml': 'project_full.datacite.xml',
+ 'datacite-json': 'project_full.datacite.json',
+ },
+ OSF.Preprint: {
+ 'turtle': 'preprint_full.turtle',
+ 'datacite-xml': 'preprint_full.datacite.xml',
+ 'datacite-json': 'preprint_full.datacite.json',
+ },
+ OSF.Registration: {
+ 'turtle': 'registration_full.turtle',
+ 'datacite-xml': 'registration_full.datacite.xml',
+ 'datacite-json': 'registration_full.datacite.json',
+ },
+ OSF.File: {
+ 'turtle': 'file_full.turtle',
+ 'datacite-xml': 'file_full.datacite.xml',
+ 'datacite-json': 'file_full.datacite.json',
+ },
+ OSF.Agent: {
+ 'turtle': 'user_full.turtle',
+ },
+}
+
+EXPECTED_MEDIATYPE = {
+ 'turtle': 'text/turtle',
+ 'datacite-xml': 'application/xml',
+ 'datacite-json': 'application/json',
+}
+
+
+class OsfguidSequence:
+ def __init__(self, start_str):
+ self._letter = start_str[0]
+ self._rest = start_str[1:]
+ self._count = 0
+
+ def __call__(self, length=5):
+ self._count += 1
+ return ''.join((self._letter, str(self._count), self._rest))[:length]
+
+ def get_or_create(self, defaults=None, **kwargs):
+ # avoid calling Guid.objects.get_or_create, which this patches over
+ try:
+ return (
+ osfdb.Guid.objects.get(**kwargs),
+ False, # not created
+ )
+ except osfdb.Guid.DoesNotExist:
+ return (
+ osfdb.Guid.objects.create(
+ **kwargs,
+ **(defaults or {}),
+ _id=self(), # use a guid from the sequence
+ ),
+ True # yes created
+ )
+
+
+def forever_now():
+ return datetime.datetime(2123, 5, 4, tzinfo=datetime.timezone.utc)
+
+
+class TestSerializers(OsfTestCase):
+ maxDiff = None
+
+ def setUp(self):
+ super().setUp()
+ # patch auto-generated fields into predictable values
+ osfguid_sequence = OsfguidSequence('wibble')
+ for patcher in (
+ mock.patch('osf.models.base.generate_guid', new=osfguid_sequence),
+ mock.patch('osf.models.base.Guid.objects.get_or_create', new=osfguid_sequence.get_or_create),
+ mock.patch('django.utils.timezone.now', new=forever_now)
+ ):
+ patcher.start()
+ self.addCleanup(patcher.stop)
+ # build test objects
+ self.user = factories.AuthUserFactory(
+ fullname='Person McNamington',
+ )
+ self.project = factories.ProjectFactory(
+ is_public=True,
+ creator=self.user,
+ title='this is a project title!',
+ description='this is a project description!',
+ node_license=factories.NodeLicenseRecordFactory(
+ node_license=NodeLicense.objects.get(
+ name='No license',
+ ),
+ year='2252',
+ copyright_holders=['Me', 'You'],
+ ),
+ )
+ self.project.set_identifier_value(
+ category='doi',
+ value=f'10.70102/FK2osf.io/{self.project._id}',
+ )
+ self.file = create_test_file(
+ self.project,
+ self.user,
+ filename='my-file.blarg',
+ size=7,
+ sha256='6ac3c336e4094835293a3fed8a4b5fedde1b5e2626d9838fed50693bba00af0e',
+ )
+ osf_preprint_provider = osfdb.PreprintProvider.load('osf')
+ self.preprint = factories.PreprintFactory(
+ is_public=True,
+ title='this is a preprint title!',
+ description='this is a preprint description!',
+ project=self.project,
+ creator=self.user,
+ doi='11.111/something-or-other',
+ provider=factories.PreprintProviderFactory(
+ _id='preprovi',
+ name='PP the Preprint Provider',
+ doi_prefix='11.pp',
+ ),
+ subjects=[
+ [factories.SubjectFactory(
+ text='wibble',
+ bepress_subject=factories.SubjectFactory(
+ text='wibbble',
+ provider=osf_preprint_provider,
+ ),
+ )._id],
+ [factories.SubjectFactory(
+ text='wobble',
+ bepress_subject=factories.SubjectFactory(
+ text='wobbble',
+ provider=osf_preprint_provider,
+ ),
+ )._id],
+ ],
+ )
+ self.registration = factories.RegistrationFactory(
+ is_public=True,
+ project=self.project,
+ user=self.user,
+ provider=factories.RegistrationProviderFactory(
+ _id='regiprovi',
+ name='RegiProvi the Registration Provider',
+ doi_prefix='11.rp',
+ ),
+ )
+ self.guid_dict = {
+ OSF.Project: self.project._id,
+ OSF.Preprint: self.preprint._id,
+ OSF.Registration: self.registration._id,
+ OSF.File: self.file.get_guid()._id,
+ OSF.Agent: self.user._id,
+ }
+
+ def _setUp_full(self):
+ self.metadata_record = osfdb.GuidMetadataRecord.objects.for_guid(self.project._id)
+ self.metadata_record.update({
+ 'language': 'en',
+ 'resource_type_general': 'Dataset',
+ 'funding_info': [
+ {
+ 'funder_name': 'Mx. Moneypockets',
+ 'funder_identifier': 'https://doi.org/10.$$$$',
+ 'funder_identifier_type': 'Crossref Funder ID',
+ 'award_number': '10000000',
+ 'award_uri': 'https://moneypockets.example/millions',
+ 'award_title': 'because reasons',
+ },
+ ],
+ }, auth=self.user)
+ self.project.node_license.node_license = NodeLicense.objects.get(
+ name='CC-By Attribution-NonCommercial-NoDerivatives 4.0 International',
+ )
+ self.project.node_license.year = '2250-2254'
+ self.project.node_license.save()
+
+ def test_serialized_metadata(self):
+ self._assert_scenario(BASIC_METADATA_SCENARIO)
+ self._setUp_full()
+ self._assert_scenario(FULL_METADATA_SCENARIO)
+
+ def _assert_scenario(self, scenario_dict):
+ for focus_type, expected_files in scenario_dict.items():
+ for format_key, filename in expected_files.items():
+ osfguid = self.guid_dict[focus_type]
+ gathered_file = pls_gather_metadata_file(osfguid, format_key)
+ with self.subTest(focus_type=focus_type, format_key=format_key, testpath='pls_gather_metadata_file'):
+ self.assertEqual(gathered_file.mediatype, EXPECTED_MEDIATYPE[format_key])
+ # to update expected metadata, uncomment `_write_expected_file` and this
+ # next line (being careful not to leave it uncommented...) and run tests
+ # self._write_expected_file(filename, gathered_file.serialized_metadata)
+ self._assert_expected_file(filename, gathered_file.serialized_metadata)
+
+ with self.subTest(focus_type=focus_type, format_key=format_key, testpath='metadata download'):
+ resp = self.app.get(f'/{osfguid}/metadata/?format={format_key}')
+ assert resp.status_code == 200
+ self.assertEqual(resp.status_code, 200)
+ self.assertEqual(resp.content_type, EXPECTED_MEDIATYPE[format_key])
+ self.assertEqual(
+ resp.content_disposition,
+ f'attachment; filename={gathered_file.filename}',
+ )
+ self._assert_expected_file(filename, resp.unicode_body)
+
+ def _assert_expected_file(self, filename, actual_metadata):
+ _open_mode = ('rb' if isinstance(actual_metadata, bytes) else 'r')
+ with open(METADATA_SCENARIO_DIR / filename, _open_mode) as _file:
+ _expected_metadata = _file.read() # small files; read all at once
+ self.assertEqual(actual_metadata, _expected_metadata)
+
+ # def _write_expected_file(self, filename, expected_metadata):
+ # '''for updating expected metadata files from current serializers
+ # (be careful to check that changes are, in fact, expected)
+ # '''
+ # _open_mode = ('wb' if isinstance(expected_metadata, bytes) else 'w')
+ # with open(METADATA_SCENARIO_DIR / filename, _open_mode) as _file:
+ # _file.write(expected_metadata)