def user(): user = AuthUserFactory() user.external_identity = { 'ORCID': { '0000-0001-9143-4653': 'VERIFIED' }, 'LOTUS': { '0000-0001-9143-4652': 'LINK' } } user.save() return user
def user(): user = AuthUserFactory() user.external_identity = { 'ORCID': { '0000-0001-9143-4653': 'VERIFIED' }, 'LOTUS': { '0000-0001-9143-4652': 'LINK' } } user.save() return user
def test_serialize_record_datacite(self, node, osf_file): # Test all of the parts of serialize_json that are auto-generated # from relationships and properties on the node and file # add a contributor with an ORCID contributor = AuthUserFactory() contributor.external_identity = { 'ORCID': { '0000-0001-9143-4653': 'VERIFIED' } } contributor.save() node.add_contributor(contributor, save=False) # add subjects, tags, license, and guid tags = ['fish', 'scale'] [ osf_file.add_tag(tag, auth=Auth(node.creator), save=False) for tag in tags ] bepress_subject = SubjectFactory(text='BePress Text') new_subject = SubjectFactory(bepress_subject=bepress_subject) node.subjects.add(new_subject) no_license = NodeLicense.objects.get(name='CC0 1.0 Universal') license_detail = { 'id': no_license.license_id, 'year': '2018', 'copyrightHolders': ['Woop', 'Yeah'] } set_license(node, license_detail, Auth(node.creator)) osf_file.save() node.save() osf_file.target.reload() record = osf_file.records.get(schema___id='datacite') serialized_record = json.loads(record.serialize()) # test titles titles = [title['title'] for title in serialized_record['titles']] assert osf_file.name in titles assert node.title in titles # test dates dates = [date['date'] for date in serialized_record['dates']] assert str(osf_file.created) in dates assert str(osf_file.modified) in dates assert str( osf_file.created.year) == serialized_record['publicationYear'] # no resource type provided assert serialized_record['resourceType']['resourceType'] == '(:unas)' assert serialized_record['resourceType'][ 'resourceTypeGeneral'] == 'Other' # guid in alternate identifiers file_guid = osf_file.guids.first()._id alternate_identifier = serialized_record['alternateIdentifiers'][0] assert file_guid in alternate_identifier['alternateIdentifier'] # check for tags and subjects subjects_in_record = [ sub['subject'] for sub in serialized_record['subjects'] ] assert bepress_subject.text in subjects_in_record for tag in tags: assert tag in subjects_in_record # node license rights = serialized_record['rightsList'][0] assert rights['rights'] == no_license.name assert rights['rightsURI'] == no_license.url # test most recent version assert serialized_record['version'] == osf_file.versions.first( ).identifier
def test_serialize_record_datacite(self, node, osf_file): # Test all of the parts of serialize_json that are auto-generated # from relationships and properties on the node and file # add a contributor with an ORCID contributor = AuthUserFactory() contributor.external_identity = { 'ORCID': { '0000-0001-9143-4653': 'VERIFIED' } } contributor.save() node.add_contributor(contributor, save=False) # add subjects, tags, license, and guid tags = ['fish', 'scale'] [osf_file.add_tag(tag, auth=Auth(node.creator), save=False) for tag in tags] bepress_subject = SubjectFactory(text='BePress Text') new_subject = SubjectFactory(bepress_subject=bepress_subject) node.subjects.add(new_subject) no_license = NodeLicense.objects.get(name='CC0 1.0 Universal') license_detail = { 'id': no_license.license_id, 'year': '2018', 'copyrightHolders': ['Woop', 'Yeah'] } set_license(node, license_detail, Auth(node.creator)) osf_file.save() node.save() osf_file.target.reload() record = osf_file.records.get(schema___id='datacite') serialized_record = json.loads(record.serialize()) # test titles titles = [title['title'] for title in serialized_record['titles']] assert osf_file.name in titles assert node.title in titles # test dates dates = [date['date'] for date in serialized_record['dates']] assert str(osf_file.created) in dates assert str(osf_file.modified) in dates assert str(osf_file.created.year) == serialized_record['publicationYear'] # no resource type provided assert serialized_record['resourceType']['resourceType'] == '(:unas)' assert serialized_record['resourceType']['resourceTypeGeneral'] == 'Other' # guid in alternate identifiers file_guid = osf_file.guids.first()._id alternate_identifier = serialized_record['alternateIdentifiers'][0] assert file_guid in alternate_identifier['alternateIdentifier'] # check for tags and subjects subjects_in_record = [sub['subject'] for sub in serialized_record['subjects']] assert bepress_subject.text in subjects_in_record for tag in tags: assert tag in subjects_in_record # node license rights = serialized_record['rightsList'][0] assert rights['rights'] == no_license.name assert rights['rightsURI'] == no_license.url # test most recent version assert serialized_record['version'] == osf_file.versions.first().identifier