Example #1
0
def test_get_submissions():
    openreview_client = mock_client()
    openreview_client_v2 = mock_v2(version=2)
    config = {
        'dataset': {
            'directory': 'tests/data/'
        },
        'csv_submissions': 'csv_submissions.csv'
    }
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       config)
    submissions = or_expertise.get_submissions()
    print(submissions)
    assert json.dumps(submissions) == json.dumps({
        'GhJKSuij': {
            "id": "GhJKSuij",
            "content": {
                "title":
                "Manual & mechan traction",
                "abstract":
                "Etiam vel augue. Vestibulum rutrum rutrum neque. Aenean auctor gravida sem."
            }
        },
        'KAeiq76y': {
            "id": "KAeiq76y",
            "content": {
                "title":
                "Aorta resection & anast",
                "abstract":
                "Morbi non lectus. Aliquam sit amet diam in magna bibendum imperdiet. Nullam orci pede, venenatis non, sodales sed, tincidunt eu, felis.Fusce posuere felis sed lacus. Morbi sem mauris, laoreet ut, rhoncus aliquet, pulvinar sed, nisl. Nunc rhoncus dui vel sem."
            }
        }
    })
Example #2
0
def test_get_submissions_from_invitation():
    openreview_client = mock_client()
    openreview_client_v2 = mock_v2(version=2)
    config = {
        'use_email_ids': False,
        'match_group': 'ABC.cc',
        'paper_invitation': 'ABC.cc/-/Submission'
    }
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       config)
    submissions = or_expertise.get_submissions()
    print(submissions)
    assert json.dumps(submissions) == json.dumps({
        'KHnr1r7H': {
            "id": "KHnr1r7H",
            "content": {
                "title":
                "Repair Right Metatarsal, Percutaneous Endoscopic Approach",
                "abstract":
                "Nam ultrices, libero non mattis pulvinar, nulla pede ullamcorper augue, a suscipit nulla elit ac nulla. Sed vel enim sit amet nunc viverra dapibus. Nulla suscipit ligula in lacus.\n\nCurabitur at ipsum ac tellus semper interdum. Mauris ullamcorper purus sit amet nulla. Quisque arcu libero, rutrum ac, lobortis vel, dapibus at, diam."
            }
        },
        'YQtWeE8P': {
            "id": "YQtWeE8P",
            "content": {
                "title":
                "Bypass L Com Iliac Art to B Com Ilia, Perc Endo Approach",
                "abstract":
                "Nullam sit amet turpis elementum ligula vehicula consequat. Morbi a ipsum. Integer a nibh.\n\nIn quis justo. Maecenas rhoncus aliquam lacus. Morbi quis tortor id nulla ultrices aliquet.\n\nMaecenas leo odio, condimentum id, luctus nec, molestie sed, justo. Pellentesque viverra pede ac diam. Cras pellentesque volutpat dui."
            }
        }
    })
Example #3
0
def test_get_papers_from_group():
    openreview_client = mock_client()
    openreview_client_v2 = mock_v2(version=2)
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       {})
    all_papers = or_expertise.get_papers_from_group('ABC.cc')
    assert len(all_papers) == 148
    if os.path.isfile('publications_by_profile_id.json'):
        os.remove('publications_by_profile_id.json')
Example #4
0
def test_convert_to_list():
    openreview_client = mock_client()
    openreview_client_v2 = mock_v2(version=2)
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       {})
    groupList = or_expertise.convert_to_list('group.cc')
    assert groupList == ['group.cc']

    groupList = or_expertise.convert_to_list(['group.cc', 'group.aa'])
    assert groupList == ['group.cc', 'group.aa']
Example #5
0
def test_retrieve_expertise(get_paperhash):
    openreview_client = mock_client()
    openreview_client_v2 = mock_v2(version=2)
    config = {'use_email_ids': False, 'match_group': 'ABC.cc'}
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       config)
    expertise = or_expertise.retrieve_expertise()

    with open('tests/data/fakeData.json') as json_file:
        data = json.load(json_file)
    profiles = data['profiles']
    for profile in profiles:
        if len(profile['publications']) > 0:
            assert len(expertise[profile['id']]) == len(
                profile['publications'])
Example #6
0
def test_get_profile_ids():
    openreview_client = mock_client()
    openreview_client_v2 = mock_v2(version=2)
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       {})
    ids, _ = or_expertise.get_profile_ids(group_ids=['ABC.cc'])
    assert len(ids) == 100
    for tilde_id, email_id in ids:
        # ~Arianna_Daugherty3 does not have emails, so both fields should have her tilde ID
        if tilde_id == '~Arianna_Daugherty3':
            assert '~' in tilde_id
            assert '~' in email_id
        else:
            assert '~' in tilde_id
            assert '@' in email_id

    ids, _ = or_expertise.get_profile_ids(reviewer_ids=[
        '*****@*****.**', '*****@*****.**', '*****@*****.**'
    ])
    assert len(ids) == 3
    assert sorted(ids) == sorted([('~Romeo_Mraz2', '*****@*****.**'),
                                  ('~Stacee_Powlowski9', '*****@*****.**'),
                                  ('~Stanley_Bogisich4',
                                   '*****@*****.**')])

    ids, _ = or_expertise.get_profile_ids(group_ids=['ABC.cc'],
                                          reviewer_ids=[
                                              '*****@*****.**',
                                              '*****@*****.**',
                                              '*****@*****.**'
                                          ])
    assert len(ids) == 100

    ids, inv_ids = or_expertise.get_profile_ids(reviewer_ids=[
        '*****@*****.**', '*****@*****.**', '*****@*****.**',
        '*****@*****.**'
    ])
    assert len(ids) == 3
    assert sorted(ids) == sorted([('~Romeo_Mraz2', '*****@*****.**'),
                                  ('~Stacee_Powlowski9', '*****@*****.**'),
                                  ('~Stanley_Bogisich4',
                                   '*****@*****.**')])
    assert len(inv_ids) == 1
    assert inv_ids[0] == '*****@*****.**'
Example #7
0
def test_get_by_submissions_from_paper_id():
    openreview_client = mock_client()
    openreview_client_v2 = mock_v2(version=2)
    config = {'paper_id': 'KHnr1r7H'}
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       config)
    submissions = or_expertise.get_submissions()
    print(submissions)
    assert json.dumps(submissions) == json.dumps({
        'KHnr1r7H': {
            "id": "KHnr1r7H",
            "content": {
                "title":
                "Repair Right Metatarsal, Percutaneous Endoscopic Approach",
                "abstract":
                "Nam ultrices, libero non mattis pulvinar, nulla pede ullamcorper augue, a suscipit nulla elit ac nulla. Sed vel enim sit amet nunc viverra dapibus. Nulla suscipit ligula in lacus.\n\nCurabitur at ipsum ac tellus semper interdum. Mauris ullamcorper purus sit amet nulla. Quisque arcu libero, rutrum ac, lobortis vel, dapibus at, diam."
            }
        }
    })
Example #8
0
def test_get_publications():
    openreview_client = mock_client()
    openreview_client_v2 = mock_v2(version=2)
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       {})
    publications = or_expertise.get_publications('~Carlos_Mondragon1')
    assert publications == []

    publications = or_expertise.get_publications('~Perry_Volkman3')
    assert len(publications) == 3

    minimum_pub_date = 1554819115
    config = {'dataset': {'minimum_pub_date': minimum_pub_date}}
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       config)
    publications = or_expertise.get_publications('~Perry_Volkman3')
    assert len(publications) == 2
    for publication in publications:
        assert publication['cdate'] > minimum_pub_date

    top_recent_pubs = 2
    config = {'dataset': {'top_recent_pubs': top_recent_pubs}}
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       config)
    publications = or_expertise.get_publications('~Perry_Volkman3')
    assert len(publications) == 2
    for publication in publications:
        assert publication['cdate'] > minimum_pub_date

    top_recent_pubs = 1
    config = {
        'dataset': {
            'top_recent_pubs': top_recent_pubs,
            'minimum_pub_date': minimum_pub_date
        }
    }
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       config)
    publications = or_expertise.get_publications('~Perry_Volkman3')
    assert len(publications) == 1
    assert publications[0]['cdate'] > minimum_pub_date

    top_recent_pubs = 1
    config = {
        'dataset': {
            'or': {
                'top_recent_pubs': top_recent_pubs,
                'minimum_pub_date': minimum_pub_date
            }
        }
    }
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       config)
    publications = or_expertise.get_publications('~Perry_Volkman3')
    assert len(publications) == 2
    for publication in publications:
        assert publication['cdate'] > minimum_pub_date

    top_recent_pubs = '10%'
    config = {
        'dataset': {
            'or': {
                'top_recent_pubs': top_recent_pubs,
                'minimum_pub_date': minimum_pub_date
            }
        }
    }
    or_expertise = OpenReviewExpertise(openreview_client, openreview_client_v2,
                                       config)
    publications = or_expertise.get_publications('~Perry_Volkman3')
    assert len(publications) == 2
    for publication in publications:
        assert publication['cdate'] > minimum_pub_date