def test_unquote():
    pytest.raises(TypeError, unquote, None)
    assert unquote('') == ''
    assert unquote('%32%35') == '25'
    assert unquote('%25%32%35') == '%25'
    assert unquote('%25%32%35', ['%']) == '%2525'
    assert unquote('foo%25%32%35bar') == 'foo%25bar'
    assert unquote('foo%23bar') == 'foo#bar'
    assert unquote('foo%23bar', ['#']) == 'foo%23bar'
    assert unquote('%2e%2E') == '..'
Example #2
0
def test_unquote():
    pytest.raises(TypeError, unquote, None)
    assert unquote('') == ''
    assert unquote('%32%35') == '25'
    assert unquote('%25%32%35') == '%25'
    assert unquote('%25%32%35', ['%']) == '%2525'
    assert unquote('foo%25%32%35bar') == 'foo%25bar'
    assert unquote('foo%23bar') == 'foo#bar'
    assert unquote('foo%23bar', ['#']) == 'foo%23bar'
    assert unquote('%2e%2E') == '..'
Example #3
0
def test_unquote():
    assert unquote("%32%35") == "25"
    assert unquote("%25%32%35") == "%25"
    assert unquote("%25%32%35", ['%']) == "%2525"
    assert unquote("foo%25%32%35bar") == "foo%25bar"
    assert unquote("foo%23bar") == "foo#bar"
    assert unquote("foo%23bar", ['#']) == "foo%23bar"
    assert unquote("%2e%2E") == ".."
Example #4
0
def test_unquote():
    assert unquote("%32%35") == "25"
    assert unquote("%25%32%35") == "%25"
    assert unquote("%25%32%35", ['%']) == "%2525"
    assert unquote("foo%25%32%35bar") == "foo%25bar"
    assert unquote("foo%23bar") == "foo#bar"
    assert unquote("foo%23bar", ['#']) == "foo%23bar"
    assert unquote("%2e%2E") == ".."
# Create dataframe for the individual readings
readings = pd.DataFrame(columns=[
    "url", "week", "part", "date", "required", "speaker", "total", "resp"
])

for week in sorted(classes.keys(), key=int):
    v = classes[week]
    speaker = v['speaker']
    name = v['name']
    part = v['part']
    date = pd.datetime.strptime(v['date'], '%d/%m/%Y')

    for url in v['required']:
        readings.loc[len(readings) + 1] = [
            urltools.unquote(url), week, part, date, True, speaker, None, None
        ]

    for url in v['optional']:
        readings.loc[len(readings) + 1] = [
            urltools.unquote(url), week, part, date, False, speaker, None, None
        ]


# Collect hypothesis data for those readings
def query_altmetric(
    url,
    start,
):
    params = {'url': url, 'limit': 200, 'offset': start}
    r = requests.get(API_URL + "/search", headers=headers, params=params)