def test_add_linkedin():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    author = AuthorBuilder()
    author.add_linkedin('https://www.linkedin.com/in/example-12345/')

    expected = [{
        "value": "https://www.linkedin.com/in/example-12345/",
        "schema": "LINKEDIN"
    }]
    result = author.obj['ids']

    assert validate(result, subschema) is None
    assert expected == result
Exemple #2
0
    def build_author(self, data):
        author = AuthorBuilder()

        for advisor in data.get('advisors', []):
            author.add_advisor(**advisor)

        for arxiv_category in data.get('arxiv_categories', []):
            author.add_arxiv_category(arxiv_category)

        blog = data.get('blog')
        author.add_blog(blog)

        comments = data.get('comments')
        author.add_private_note(comments)

        display_name = data.get('display_name')
        author.set_display_name(display_name)

        given_name = data.get('given_name')
        family_name = data.get('family_name')
        full_name = self.get_full_name(family_name, given_name)
        author.set_name(full_name)

        linkedin = data.get('linkedin')
        author.add_linkedin(linkedin)

        orcid = data.get('orcid')
        author.add_orcid(orcid)

        bai = data.get('bai')
        author.add_bai(bai)

        native_name = data.get('native_name')
        author.add_native_name(native_name)

        for position in data.get('positions', []):
            institution = position.get('institution')
            start_date = position.get('start_date')
            end_date = position.get('end_date')
            rank = position.get('rank')
            record = position.get('record')
            curated_relation = position.get('curated_relation', False)
            current = position.get('current', False)

            author.add_institution(
                institution,
                start_date=start_date,
                end_date=end_date,
                rank=rank,
                record=record,
                curated=curated_relation,
                current=current
            )

        for project in data.get('project_membership', []):
            name = project.get('name')
            record = project.get('record')
            start_date = project.get('start_date')
            end_date = project.get('end_date')
            curated_relation = project.get('curated_relation', False)
            current = project.get('current', False)

            author.add_project(
                name,
                record=record,
                start_date=start_date,
                end_date=end_date,
                curated=curated_relation,
                current=current
            )

        for email in data.get('public_emails', []):
            author.add_email_address(email)

        status = data.get('status')
        author.set_status(status)

        twitter = data.get('twitter')
        author.add_twitter(twitter)

        for website in data.get('websites', []):
            author.add_url(website)

        acquisition_source = data.get('acquisition_source')

        if acquisition_source:
            method = acquisition_source.get('method')
            submission_number = acquisition_source.get('submission_number')
            internal_uid = acquisition_source.get('internal_uid')
            email = acquisition_source.get('email')
            orcid = acquisition_source.get('orcid')
            source = acquisition_source.get('source')
            datetime = acquisition_source.get('datetime')
            author.add_acquisition_source(
                method,
                submission_number=submission_number,
                internal_uid=internal_uid,
                email=email,
                orcid=orcid,
                source=source,
                datetime=datetime,
            )

        return author.obj
Exemple #3
0
    def build_author(self, data):
        author = AuthorBuilder()

        for advisor in data.get("advisors", []):
            curated = advisor.pop("curated_relation", False)
            author.add_advisor(**advisor, curated=curated)

        for arxiv_category in data.get("arxiv_categories", []):
            author.add_arxiv_category(arxiv_category)

        blog = data.get("blog")
        author.add_blog(blog)

        comments = data.get("comments")
        author.add_private_note(comments)

        display_name = data.get("display_name")
        author.set_display_name(display_name)

        given_name = data.get("given_name")
        family_name = data.get("family_name")
        full_name = self.get_full_name(family_name, given_name)
        author.set_name(full_name)
        alternate_name = data.get("alternate_name")
        author.add_name_variant(alternate_name)

        linkedin = data.get("linkedin")
        author.add_linkedin(linkedin)

        orcid = data.get("orcid")
        author.add_orcid(orcid)

        bai = data.get("bai")
        author.add_bai(bai)

        native_name = data.get("native_name")
        author.add_native_name(native_name)

        for position in data.get("positions", []):
            curated = position.pop("curated_relation", False)

            author.add_institution(**position, curated=curated)

        for project in data.get("project_membership", []):
            curated = project.pop("curated_relation", False)
            author.add_project(**project, curated=curated)

        for email in data.get("emails", []):
            author.add_email_address(
                email.get("value"),
                current=email.get("current"),
                hidden=email.get("hidden"),
            )

        status = data.get("status")
        author.set_status(status)

        twitter = data.get("twitter")
        author.add_twitter(twitter)

        for website in data.get("websites", []):
            author.add_url(website)

        acquisition_source = data.get("acquisition_source")

        if acquisition_source:
            method = acquisition_source.get("method")
            submission_number = acquisition_source.get("submission_number")
            internal_uid = acquisition_source.get("internal_uid")
            email = acquisition_source.get("email")
            orcid = acquisition_source.get("orcid")
            source = acquisition_source.get("source")
            datetime = acquisition_source.get("datetime")
            author.add_acquisition_source(
                method,
                submission_number=submission_number,
                internal_uid=internal_uid,
                email=email,
                orcid=orcid,
                source=source,
                datetime=datetime,
            )

        return author.obj