Exemple #1
0
def test_search_unauthorized(reqs, mock_init):
    cm.set("ads_token", "None")
    query = 'author:"^fortney, j" year:2000-2018 property:refereed'
    with pytest.raises(ValueError,
                       match='Unauthorized access to ADS.  '
                       'Check that the ADS token is valid.'):
        results, nmatch = am.search(query)
Exemple #2
0
def test_search_limit_cache(reqs, ads_entries, mock_init):
    query = 'author:"^fortney, j" year:2000-2018 property:refereed'
    results, nmatch = am.search(query, start=0, cache_rows=2)
    # There are 26 matches:
    assert nmatch == 26
    # But requested only two entries:
    assert len(results) == 2
    assert results == [ads_entries['fortney2018'], ads_entries['fortney2016']]
Exemple #3
0
def test_search_start(reqs, ads_entries, mock_init):
    querry = 'author:"^fortney, j" year:2000-2018 property:refereed'
    results, nmatch = am.search(querry, start=2, cache_rows=2)
    # There are 26 matches:
    assert nmatch == 26
    # But requested only two entries:
    assert len(results) == 2
    # But results start from third match:
    assert results == [ads_entries['fortney2013'], ads_entries['fortney2012']]
Exemple #4
0
def test_search(reqs, ads_entries, mock_init):
    query = 'author:"^mayor" year:1995 property:refereed'
    results, nmatch = am.search(query)
    assert nmatch == 1
    assert results == [ads_entries['mayor']]
Exemple #5
0
def test_search_unauthorized(reqs):
    cm.set("ads_token", "None")
    querry = 'author:"^fortney, j" year:2000-2018 property:refereed'
    with pytest.raises(ValueError, match="Invalid ADS request: Unauthorized," \
                                         " check you have a valid ADS token."):
        results, nmatch = am.search(querry)