def test_metadata_for_node_only_includes_visible_contribs(
            self, datacite_client):
        visible_contrib = AuthUserFactory()
        visible_contrib2 = AuthUserFactory()
        visible_contrib2.given_name = u'ヽ༼ ಠ益ಠ ༽ノ'
        visible_contrib2.family_name = u'ლ(´◉❥◉`ლ)'
        visible_contrib2.save()
        invisible_contrib = AuthUserFactory()
        invisible_contrib.given_name = 'Shady'
        invisible_contrib.family_name = 'McCoy'
        invisible_contrib.save()
        registration = RegistrationFactory(is_public=True)

        registration.add_contributor(visible_contrib, visible=True)
        registration.add_contributor(invisible_contrib, visible=False)
        registration.add_contributor(visible_contrib2, visible=True)
        registration.save()

        metadata_xml = datacite_client.build_metadata(registration)
        # includes visible contrib name
        assert u'<givenName>{}</givenName>'.format(
            visible_contrib.given_name) in metadata_xml
        assert u'<familyName>{}</familyName>'.format(
            visible_contrib.family_name) in metadata_xml

        # doesn't include invisible contrib name
        assert u'<givenName>{}</givenName>'.format(
            invisible_contrib.given_name) not in metadata_xml
        assert u'<familyName>{}</familyName>'.format(
            invisible_contrib.family_name) not in metadata_xml
Example #2
0
    def test_metadata_for_node_only_includes_visible_contribs(self, datacite_client):
        visible_contrib = AuthUserFactory()
        visible_contrib2 = AuthUserFactory()
        visible_contrib2.given_name = u'ヽ༼ ಠ益ಠ ༽ノ'
        visible_contrib2.family_name = u'ლ(´◉❥◉`ლ)'
        visible_contrib2.save()
        invisible_contrib = AuthUserFactory()
        invisible_contrib.given_name = 'Shady'
        invisible_contrib.family_name = 'McCoy'
        invisible_contrib.save()
        registration = RegistrationFactory(is_public=True)

        registration.add_contributor(visible_contrib, visible=True)
        registration.add_contributor(invisible_contrib, visible=False)
        registration.add_contributor(visible_contrib2, visible=True)
        registration.save()

        metadata_xml = datacite_client.build_metadata(registration)
        # includes visible contrib name
        assert u'<givenName>{}</givenName>'.format(visible_contrib.given_name) in metadata_xml
        assert u'<familyName>{}</familyName>'.format(visible_contrib.family_name) in metadata_xml

        # doesn't include invisible contrib name
        assert u'<givenName>{}</givenName>'.format(invisible_contrib.given_name) not in metadata_xml
        assert u'<familyName>{}</familyName>'.format(invisible_contrib.family_name) not in metadata_xml
    def test_process_crossref_name(self, crossref_client):
        contributor = AuthUserFactory()

        # Given name and no family name
        contributor.given_name = 'Hey'
        contributor.family_name = ''
        contributor.save()
        meta = crossref_client._process_crossref_name(contributor)
        imputed_names = impute_names(contributor.fullname)
        assert meta == {'surname': imputed_names['family'], 'given_name': imputed_names['given']}

        # Just one name
        contributor.fullname = 'Ke$ha'
        contributor.given_name = ''
        contributor.family_name = ''
        contributor.save()
        meta = crossref_client._process_crossref_name(contributor)
        assert meta == {'surname': contributor.fullname}

        # Number and ? in given name
        contributor.fullname = 'Scotty2Hotty? Ronald Garland II'
        contributor.given_name = ''
        contributor.family_name = ''
        contributor.save()
        meta = crossref_client._process_crossref_name(contributor)
        assert meta == {'given_name': 'ScottyHotty Ronald', 'surname': 'Garland', 'suffix': 'II'}

        # Long suffix is truncated to 10 characters
        long_suffix = 'PhD MD Esq MPH IV'
        contributor.given_name = 'Mark'
        contributor.family_name = 'Henry'
        contributor.suffix = long_suffix
        contributor.save()
        meta = crossref_client._process_crossref_name(contributor)
        assert meta['suffix'] == long_suffix[:crossref.CROSSREF_SUFFIX_LIMIT]

        # Long given_names and surnames are truncated to limit
        long_given = 'Maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaark'
        long_surname = 'Henryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
        contributor.given_name = long_given
        contributor.family_name = long_surname
        contributor.save()

        meta = crossref_client._process_crossref_name(contributor)
        assert meta['given_name'] == long_given[:crossref.CROSSREF_GIVEN_NAME_LIMIT]
        assert meta['surname'] == long_surname[:crossref.CROSSREF_SURNAME_LIMIT]

        # Unparsable given or surname just returns fullname as surname
        unparsable_fullname = 'Author (name withheld until double-blind peer review completes and this name is also really long)'
        contributor.given_name = ''
        contributor.family_name = ''
        contributor.fullname = unparsable_fullname
        contributor.save()

        meta = crossref_client._process_crossref_name(contributor)
        assert meta == {'surname': unparsable_fullname[:crossref.CROSSREF_SURNAME_LIMIT]}
    def test_process_crossref_name(self, crossref_client):
        contributor = AuthUserFactory()

        # Given name and no family name
        contributor.given_name = 'Hey'
        contributor.family_name = ''
        contributor.save()
        meta = crossref_client._process_crossref_name(contributor)
        imputed_names = impute_names(contributor.fullname)
        assert meta == {'surname': imputed_names['family'], 'given_name': imputed_names['given']}

        # Just one name
        contributor.fullname = 'Ke$ha'
        contributor.given_name = ''
        contributor.family_name = ''
        contributor.save()
        meta = crossref_client._process_crossref_name(contributor)
        assert meta == {'surname': contributor.fullname}

        # Number and ? in given name
        contributor.fullname = 'Scotty2Hotty? Ronald Garland II'
        contributor.given_name = ''
        contributor.family_name = ''
        contributor.save()
        meta = crossref_client._process_crossref_name(contributor)
        assert meta == {'given_name': 'ScottyHotty Ronald', 'surname': 'Garland', 'suffix': 'II'}

        # Long suffix is truncated to 10 characters
        long_suffix = 'PhD MD Esq MPH IV'
        contributor.given_name = 'Mark'
        contributor.family_name = 'Henry'
        contributor.suffix = long_suffix
        contributor.save()
        meta = crossref_client._process_crossref_name(contributor)
        assert meta['suffix'] == long_suffix[:crossref.CROSSREF_SUFFIX_LIMIT]

        # Long given_names and surnames are truncated to limit
        long_given = 'Maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaark'
        long_surname = 'Henryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
        contributor.given_name = long_given
        contributor.family_name = long_surname
        contributor.save()

        meta = crossref_client._process_crossref_name(contributor)
        assert meta['given_name'] == long_given[:crossref.CROSSREF_GIVEN_NAME_LIMIT]
        assert meta['surname'] == long_surname[:crossref.CROSSREF_SURNAME_LIMIT]

        # Unparsable given or surname just returns fullname as surname
        unparsable_fullname = 'Author (name withheld until double-blind peer review completes and this name is also really long)'
        contributor.given_name = ''
        contributor.family_name = ''
        contributor.fullname = unparsable_fullname
        contributor.save()

        meta = crossref_client._process_crossref_name(contributor)
        assert meta == {'surname': unparsable_fullname[:crossref.CROSSREF_SURNAME_LIMIT]}
Example #5
0
    def test_eight_authors(self):
        self.node.add_contributor(self.second_contrib)
        self.node.add_contributor(self.third_contrib)
        for i in range(1, 6):
            new_user = AuthUserFactory()
            new_user.given_name = 'James'
            new_user.family_name = 'Taylor{}'.format(i)
            new_user.save()
            self.node.add_contributor(new_user)
        self.node.save()

        res = self.app.get(self.published_preprint_url)
        assert_equal(res.status_code, 200)
        citation = res.json['data']['attributes']['citation']
        date = timezone.now().date().strftime('%Y, %B %-d')
        assert_equal(
            citation,
            u'McGee, G. C. B., Jenkins, D. T. T., Junior, Schematics, L. R., Taylor1, J., Taylor2, J., Taylor3, J., … Taylor5, J. ({}). {}. {}'
            .format(date, self.node.title,
                    'https://doi.org/' + self.published_preprint.article_doi))
Example #6
0
 def test_eleven_contributors(self):
     self.node.add_contributor(self.second_contrib)
     self.node.add_contributor(self.third_contrib)
     for i in range(1, 9):
         new_user = AuthUserFactory()
         new_user.given_name = 'James'
         new_user.family_name = 'Taylor{}'.format(i)
         new_user.save()
         self.node.add_contributor(new_user)
     self.node.save()
     res = self.app.get(self.published_preprint_url)
     assert_equal(res.status_code, 200)
     citation = res.json['data']['attributes']['citation']
     date = timezone.now().date()
     assert_equal(
         citation,
         u'McGee, Grapes C. B., Darla T. T. Jenkins, Junior, Lilith R. Schematics, James Taylor1, James Taylor2, James Taylor3, James Taylor4, et al. {}. “{}.” {}. {}. {}.'
         .format(date.strftime('%Y'), self.node.title,
                 self.published_preprint.provider.name,
                 date.strftime('%B %-d'),
                 'doi:' + self.published_preprint.article_doi))
    def test_eight_authors(self):
        self.node.add_contributor(self.second_contrib)
        self.node.add_contributor(self.third_contrib)
        for i in range(1,6):
            new_user = AuthUserFactory()
            new_user.given_name = 'James'
            new_user.family_name = 'Taylor{}'.format(i)
            new_user.save()
            self.node.add_contributor(new_user)
        self.node.save()

        res = self.app.get(self.published_preprint_url)
        assert_equal(res.status_code, 200)
        citation = res.json['data']['attributes']['citation']
        date = timezone.now().date().strftime('%Y, %B %-d')
        assert_equal(citation, u'McGee, G. C. B., Jenkins, D. T. T., Junior, Schematics, L. R., Taylor1, J., Taylor2, J., Taylor3, J., … Taylor5, J. ({}). {}. {}'.format(
            date,
            self.node.title,
            'https://doi.org/' + self.published_preprint.article_doi
            )
        )
 def test_eleven_contributors(self):
     self.node.add_contributor(self.second_contrib)
     self.node.add_contributor(self.third_contrib)
     for i in range(1,9):
         new_user = AuthUserFactory()
         new_user.given_name = 'James'
         new_user.family_name = 'Taylor{}'.format(i)
         new_user.save()
         self.node.add_contributor(new_user)
     self.node.save()
     res = self.app.get(self.published_preprint_url)
     assert_equal(res.status_code, 200)
     citation = res.json['data']['attributes']['citation']
     date = timezone.now().date()
     assert_equal(citation, u'McGee, Grapes C. B., Darla T. T. Jenkins, Junior, Lilith R. Schematics, James Taylor1, James Taylor2, James Taylor3, James Taylor4, et al. {}. “{}.” {}. {}. {}.'.format(
             date.strftime('%Y'),
             self.node.title,
             self.published_preprint.provider.name,
             date.strftime('%B %-d'),
             'doi:' + self.published_preprint.article_doi
             )
     )