Ejemplo n.º 1
0
def test_urls_from_blog_url():
    form = GroupableOrderedDict([("blog_url", "foo")])

    expected = [{"description": "BLOG", "value": "foo"}]
    result = updateform.do(form)

    assert expected == result["urls"]
Ejemplo n.º 2
0
def test_positions_from_public_email_unchanged():
    form = {'public_emails': [{'email': 'foo', 'original_email': 'foo'}]}

    expected = []
    result = updateform.do(form)

    assert expected == result['positions']
Ejemplo n.º 3
0
def test_ids_from_inspireid_appends():
    form = GroupableOrderedDict([("inspireid", "foo"), ("inspireid", "bar")])

    expected = [{"type": "INSPIRE", "value": "foo"}, {"type": "INSPIRE", "value": "bar"}]
    result = updateform.do(form)

    assert expected == result["ids"]
Ejemplo n.º 4
0
def test_experiments_from_experiments():
    form = {
        'experiments': [
            {
                'start_year': 2009,
                'status': 'foo',
            },
            {
                'start_year': 2010,
                'status': '',
            },
        ],
    }

    expected = [
        {
            'start_year': 2010,
            'status': ''
        },
        {
            'start_year': 2009,
            'status': 'current',
        },
    ]
    result = updateform.do(form)

    assert expected == result['experiments']
Ejemplo n.º 5
0
def test_field_categories_from_research_field():
    form = GroupableOrderedDict([("research_field", "foo")])

    expected = [{"source": "submitter", "term": "foo"}]
    result = updateform.do(form)

    assert expected == result["field_categories"]
Ejemplo n.º 6
0
def test_positions_from_public_email_appends():
    form = GroupableOrderedDict([("public_email", "foo"), ("public_email", "bar")])

    expected = [{"current": "Current", "email": "foo"}, {"current": "Current", "email": "bar"}]
    result = updateform.do(form)

    assert expected == result["positions"]
Ejemplo n.º 7
0
def test_urls_from_linkedin_url_appends():
    form = GroupableOrderedDict([("linkedin_url", "foo"), ("linkedin_url", "bar")])

    expected = [{"description": "LINKEDIN", "value": "foo"}, {"description": "LINKEDIN", "value": "bar"}]
    result = updateform.do(form)

    assert expected == result["urls"]
Ejemplo n.º 8
0
def test_ids_from_orcid():
    form = GroupableOrderedDict([("orcid", "foo")])

    expected = [{"type": "ORCID", "value": "foo"}]
    result = updateform.do(form)

    assert expected == result["ids"]
Ejemplo n.º 9
0
def test_name_status_from_status_updates():
    form = GroupableOrderedDict([("status", "foo"), ("status", "bar")])

    expected = {"status": "bar"}
    result = updateform.do(form)

    assert expected == result["name"]
Ejemplo n.º 10
0
def test_experiments_from_experiments():
    form = {"experiments": [{"start_year": 2009, "status": "foo"}, {"start_year": 2010, "status": ""}]}

    expected = [{"start_year": 2010, "status": ""}, {"start_year": 2009, "status": "current"}]
    result = updateform.do(form)

    assert expected == result["experiments"]
Ejemplo n.º 11
0
def test_name_preferred_name_from_display_name_updates():
    form = GroupableOrderedDict([("display_name", "foo"), ("display_name", "bar")])

    expected = {"preferred_name": "bar"}
    result = updateform.do(form)

    assert expected == result["name"]
Ejemplo n.º 12
0
def test_experiments_from_experiments():
    form = {
        'experiments': [
            {
                'start_year': 2009,
                'status': 'foo',
            },
            {
                'start_year': 2010,
                'status': '',
            },
        ],
    }

    expected = [
        {
            'start_year': 2010,
            'status': ''
        },
        {
            'start_year': 2009,
            'status': 'current',
        },
    ]
    result = updateform.do(form)

    assert expected == result['experiments']
Ejemplo n.º 13
0
def test_urls_from_websites_webpage():
    form = {"websites": [{"webpage": "foo"}]}

    expected = [{"description": "", "value": "foo"}]
    result = updateform.do(form)

    assert expected == result["urls"]
Ejemplo n.º 14
0
def test_experiments_from_experiments():
    form = {
        'experiments': [
            {
                'start_year': 2009,
                'current': True,
            },
            {
                'start_year': 2010,
                'current': False,
            },
        ],
    }

    expected = [
        {
            'start_year': 2010,
            'current': False
        },
        {
            'start_year': 2009,
            'current': True,
        },
    ]

    result = updateform.do(form)

    assert expected == result['experiments']
Ejemplo n.º 15
0
def test_urls_from_twitter_url_appends():
    form = GroupableOrderedDict([("twitter_url", "foo"), ("twitter_url", "bar")])

    expected = [{"description": "TWITTER", "value": "foo"}, {"description": "TWITTER", "value": "bar"}]
    result = updateform.do(form)

    assert expected == result["urls"]
Ejemplo n.º 16
0
def test_ids_from_bai_appends():
    form = GroupableOrderedDict([("bai", "foo"), ("bai", "bar")])

    expected = [{"type": "BAI", "value": "foo"}, {"type": "BAI", "value": "bar"}]
    result = updateform.do(form)

    assert expected == result["ids"]
Ejemplo n.º 17
0
def test_phd_advisors_from_advisors():
    form = {"advisors": [{"degree_type": "PhD", "full_name": ""}, {"degree_type": "PhD", "full_name": "foo"}]}

    expected = [{"degree_type": "PhD", "name": "foo"}]
    result = updateform.do(form)

    assert expected == result["phd_advisors"]
Ejemplo n.º 18
0
def test_arxiv_categories_from_research_field():
    form = GroupableOrderedDict([
        ('research_field', 'foo'),
    ])

    expected = 'foo'
    result = updateform.do(form)

    assert expected == result['arxiv_categories']
Ejemplo n.º 19
0
def test_positions_from_public_email_unchanged():
    form = {
        'public_emails': [{'email': 'foo', 'original_email': 'foo'}]
    }

    expected = []
    result = updateform.do(form)

    assert expected == result['positions']
Ejemplo n.º 20
0
def test_positions_from_public_email_removed():
    form = {'public_emails': [{'email': '', 'original_email': 'foo'}]}

    expected = [{
        'emails': [''],
        'old_emails': ['foo'],
    }]
    result = updateform.do(form)

    assert expected == result['positions']
Ejemplo n.º 21
0
def test_name_status_from_status():
    form = GroupableOrderedDict([
        ('status', 'foo'),
    ])

    expected = {
        'status': 'foo',
    }
    result = updateform.do(form)

    assert expected == result['name']
Ejemplo n.º 22
0
def test_name_status_from_status():
    form = GroupableOrderedDict([
        ('status', 'foo'),
    ])

    expected = {
        'status': 'foo',
    }
    result = updateform.do(form)

    assert expected == result['name']
Ejemplo n.º 23
0
def test_status_from_status():
    form = GroupableOrderedDict([
        ('status', 'deceased'),
    ])

    expected = {
        'status': 'deceased',
    }
    result = updateform.do(form)

    assert expected == result
Ejemplo n.º 24
0
def test_name_preferred_name_from_display_name():
    form = GroupableOrderedDict([
        ('display_name', 'foo'),
    ])

    expected = {
        'preferred_name': 'foo',
    }
    result = updateform.do(form)

    assert expected == result['name']
Ejemplo n.º 25
0
def test_positions_from_institutions_history():
    form = {
        'institution_history': [
            {
                'start_year': 2009,
                'end_year': 2010,
                'name': 'foo',
                'email': 'bar',
                'old_email': 'baz',
                'current': 'qux',
                'rank': 'quux',
            },
            {
                'start_year': 2010,
                'end_year': 2012,
                'name': 'oof',
                'email': 'rab',
                'old_email': 'zab',
                'current': '',
                'rank': 'rank',
            },
        ],
    }

    expected = [
        {
            'institution': {
                'name': 'oof'
            },
            'status': '',
            'start_date': 2010,
            'end_date': 2012,
            'email': 'rab',
            'old_email': 'zab',
            'rank': '',
        },
        {
            'institution': {
                'name': 'foo'
            },
            'status': 'current',
            'start_date': 2009,
            'end_date': 2010,
            'email': 'bar',
            'old_email': 'baz',
            'rank': 'quux',
        },
    ]
    result = updateform.do(form)

    assert expected == result['positions']
Ejemplo n.º 26
0
def test_urls_from_blog_url():
    form = GroupableOrderedDict([
        ('blog_url', 'foo'),
    ])

    expected = [
        {
            'description': 'BLOG',
            'value': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['urls']
Ejemplo n.º 27
0
def test_field_categories_from_research_field():
    form = GroupableOrderedDict([
        ('research_field', 'foo'),
    ])

    expected = [
        {
            'source': 'submitter',
            'term': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['field_categories']
Ejemplo n.º 28
0
def test_ids_from_inspireid():
    form = GroupableOrderedDict([
        ('inspireid', 'foo'),
    ])

    expected = [
        {
            'schema': 'INSPIRE ID',
            'value': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['ids']
Ejemplo n.º 29
0
def test_ids_from_bai():
    form = GroupableOrderedDict([
        ('bai', 'foo'),
    ])

    expected = [
        {
            'type': 'BAI',
            'value': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['ids']
Ejemplo n.º 30
0
def test_ids_from_orcid():
    form = GroupableOrderedDict([
        ('orcid', 'foo'),
    ])

    expected = [
        {
            'type': 'ORCID',
            'value': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['ids']
Ejemplo n.º 31
0
def test_field_categories_from_research_field():
    form = GroupableOrderedDict([
        ('research_field', 'foo'),
    ])

    expected = [
        {
            'source': 'submitter',
            'term': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['field_categories']
Ejemplo n.º 32
0
def test_positions_from_public_email():
    form = GroupableOrderedDict([
        ('public_email', 'foo'),
    ])

    expected = [
        {
            'current': 'Current',
            'email': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['positions']
Ejemplo n.º 33
0
def test_ids_from_orcid():
    form = GroupableOrderedDict([
        ('orcid', 'foo'),
    ])

    expected = [
        {
            'type': 'ORCID',
            'value': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['ids']
Ejemplo n.º 34
0
def test_urls_from_linkedin_url():
    form = GroupableOrderedDict([
        ('linkedin_url', 'foo'),
    ])

    expected = [
        {
            'description': 'LINKEDIN',
            'value': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['urls']
Ejemplo n.º 35
0
def test_positions_from_public_email():
    form = GroupableOrderedDict([
        ('public_email', 'foo'),
    ])

    expected = [
        {
            'current': 'Current',
            'email': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['positions']
Ejemplo n.º 36
0
def test_ids_from_bai():
    form = GroupableOrderedDict([
        ('bai', 'foo'),
    ])

    expected = [
        {
            'type': 'BAI',
            'value': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['ids']
Ejemplo n.º 37
0
def test_positions_from_public_email_removed():
    form = {
        'public_emails': [{'email': '', 'original_email': 'foo'}]
    }

    expected = [
        {
            'emails': [''],
            'old_emails': ['foo'],

        }
    ]
    result = updateform.do(form)

    assert expected == result['positions']
Ejemplo n.º 38
0
def test_positions_from_institutions_history():
    form = {
        "institution_history": [
            {
                "start_year": 2009,
                "end_year": 2010,
                "name": "foo",
                "email": "bar",
                "old_email": "baz",
                "current": "qux",
                "rank": "quux",
            },
            {
                "start_year": 2010,
                "end_year": 2012,
                "name": "oof",
                "email": "rab",
                "old_email": "zab",
                "current": "",
                "rank": "rank",
            },
        ]
    }

    expected = [
        {
            "institution": {"name": "oof"},
            "status": "",
            "start_date": 2010,
            "end_date": 2012,
            "email": "rab",
            "old_email": "zab",
            "rank": "",
        },
        {
            "institution": {"name": "foo"},
            "status": "current",
            "start_date": 2009,
            "end_date": 2010,
            "email": "bar",
            "old_email": "baz",
            "rank": "quux",
        },
    ]
    result = updateform.do(form)

    assert expected == result["positions"]
Ejemplo n.º 39
0
def test_positions_from_institutions_history():
    form = {
        'institution_history': [
            {
                'start_year': 2009,
                'end_year': 2010,
                'name': 'foo',
                'emails': ['bar'],
                'old_emails': ['baz'],
                'current': 'qux',
                'rank': 'quux',
            },
            {
                'start_year': 2010,
                'end_year': 2012,
                'name': 'oof',
                'emails': ['rab'],
                'old_emails': ['zab'],
                'current': '',
                'rank': 'rank',
            },
        ],
    }

    expected = [
        {
            'institution': {'name': 'oof'},
            'current': False,
            'start_date': 2010,
            'end_date': 2012,
            'emails': ['rab'],
            'old_emails': ['zab'],
            '_rank': '',
        },
        {
            'institution': {'name': 'foo'},
            'current': True,
            'start_date': 2009,
            'end_date': 2010,
            'emails': ['bar'],
            'old_emails': ['baz'],
            '_rank': 'quux',
        },
    ]
    result = updateform.do(form)

    assert expected == result['positions']
Ejemplo n.º 40
0
def test_urls_from_websites_webpage():
    form = {
        'websites': [
            {
                'webpage': 'foo',
            },
        ],
    }

    expected = [
        {
            'description': '',
            'value': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['urls']
Ejemplo n.º 41
0
def test_ids_from_inspireid_appends():
    form = GroupableOrderedDict([
        ('inspireid', 'foo'),
        ('inspireid', 'bar'),
    ])

    expected = [
        {
            'type': 'INSPIRE',
            'value': 'foo',
        },
        {
            'type': 'INSPIRE',
            'value': 'bar',
        },
    ]
    result = updateform.do(form)

    assert expected == result['ids']
Ejemplo n.º 42
0
def test_ids_from_bai_appends():
    form = GroupableOrderedDict([
        ('bai', 'foo'),
        ('bai', 'bar'),
    ])

    expected = [
        {
            'schema': 'INSPIRE BAI',
            'value': 'foo',
        },
        {
            'schema': 'INSPIRE BAI',
            'value': 'bar',
        },
    ]
    result = updateform.do(form)

    assert expected == result['ids']
Ejemplo n.º 43
0
def test_ids_from_orcid_appends():
    form = GroupableOrderedDict([
        ('orcid', 'foo'),
        ('orcid', 'bar'),
    ])

    expected = [
        {
            'schema': 'ORCID',
            'value': 'foo',
        },
        {
            'schema': 'ORCID',
            'value': 'bar',
        },
    ]
    result = updateform.do(form)

    assert expected == result['ids']
Ejemplo n.º 44
0
def test_urls_from_twitter_url_appends():
    form = GroupableOrderedDict([
        ('twitter_url', 'foo'),
        ('twitter_url', 'bar'),
    ])

    expected = [
        {
            'description': 'TWITTER',
            'value': 'foo',
        },
        {
            'description': 'TWITTER',
            'value': 'bar',
        },
    ]
    result = updateform.do(form)

    assert expected == result['urls']
Ejemplo n.º 45
0
def test_positions_from_public_email_appends():
    form = {
        'public_emails': [{
            'email': 'foo1',
            'original_email': 'foo'
        }, {
            'email': 'bar1',
            'original_email': 'bar'
        }]
    }

    expected = [{
        'emails': ['foo1'],
        'old_emails': ['foo'],
    }, {
        'emails': ['bar1'],
        'old_emails': ['bar'],
    }]
    result = updateform.do(form)

    assert expected == result['positions']
Ejemplo n.º 46
0
def test_advisors_from_advisors():
    form = {
        'advisors': [
            {
                'degree_type': 'PhD',
                'full_name': '',
            },
            {
                'degree_type': 'PhD',
                'full_name': 'foo',
            },
        ],
    }

    expected = [
        {
            'degree_type': 'phd',
            'name': 'foo',
        },
    ]
    result = updateform.do(form)

    assert expected == result['advisors']