コード例 #1
0
def test_1():
    url = "https://projecteuclid.org/journals/advances-in-differential-equations/volume-19/issue-3_2f_4/An-analysis-of-the-renormalization-group-method-for-asymptotic-expansions/ade/1391109086.short"  # noqa: E501

    downs = papis.downloaders.get_matching_downloaders(url)
    down, = (d for d in downs if d.name == "projecteuclid")

    # import os
    # with open(os.path.join(
    #         os.path.dirname(__file__),
    #         "resources", "projecteuclid_1.html"), "w") as f:
    #     f.write(down._get_body().decode())

    with patch.object(down, "_get_body",
                      lambda: get_resource("projecteuclid_1.html")):
        with patch.object(down, "download_document", lambda: None):
            down.fetch()

            # with open(os.path.join(
            #         os.path.dirname(__file__),
            #         "resources", "projecteuclid_1_out.json"), "w+") as f:
            #     import json
            #     json.dump(down.ctx.data, f)

            ref_data = get_json_resource("projecteuclid_1_out.json")
            assert down.ctx.data == ref_data
コード例 #2
0
def test_1():
    url = 'https://hal.archives-ouvertes.fr/jpa-00235190'
    down = papis.downloaders.get_downloader(url)
    assert(down.name == 'hal')
    with patch.object(down, '_get_body', lambda: get_resource('hal_1.html')):
        with patch.object(down, 'download_document', lambda: None):
            down.fetch()
            correct_data = get_json_resource('hal_1_out.json')
            assert(down.ctx.data == correct_data)
コード例 #3
0
ファイル: test_citeseerx.py プロジェクト: zzmjohn/papis
def test_1():
    url = 'https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.26.2787'
    down = papis.downloaders.get_matching_downloaders(url)[0]
    assert (down.name == 'citeseerx')
    with patch.object(down, '_get_body',
                      lambda: get_resource('citeseerx_1.html')):
        down.fetch_data()
        correct_data = get_json_resource('citeseerx_1_out.json')
        assert (down.ctx.data == correct_data)
コード例 #4
0
def test_1():
    url = 'https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.122.145901'
    down = papis.downloaders.get_downloader(url)
    assert(down.name == 'aps')
    with patch.object(down, '_get_body',
            lambda: get_resource('prl_1.html')):
        with patch.object(down, 'download_document', lambda: None):
            down.fetch()
            correct_data = get_json_resource('prl_1_out.json')
            assert(down.ctx.data == correct_data)
コード例 #5
0
ファイル: test_springer.py プロジェクト: zzmjohn/papis
def test_1():
    url = 'https://link.springer.com/article/10.1007/s10924-010-0192-1#citeas'
    down = papis.downloaders.get_downloader(url)
    assert (down.name == 'springer')
    with patch.object(down, '_get_body',
                      lambda: get_resource('springer_1.html')):
        with patch.object(down, 'download_document', lambda: None):
            down.fetch()
            correct_data = get_json_resource('springer_1_out.json')
            assert (down.ctx.data == correct_data)
コード例 #6
0
ファイル: test_springer.py プロジェクト: zzmjohn/papis
def test_2():
    url = 'https://link.springer.com/article/10.1007%2FBF02727953'
    down = papis.downloaders.get_downloader(url)
    assert (down.name == 'springer')
    with patch.object(down, '_get_body',
                      lambda: get_resource('springer_2.html')):
        with patch.object(down, 'download_document', lambda: None):
            down.fetch()
            correct_data = get_json_resource('springer_2_out.json')
            assert (down.ctx.data == correct_data)
コード例 #7
0
def test_2():
    url = 'https://www.sciencedirect.com/science/article/pii/bogus'
    down = papis.downloaders.get_downloader(url)
    assert (not down.ctx)
    with patch.object(down, '_get_body',
                      lambda: get_resource('sciencedirect_2.html')):
        with patch.object(down, 'download_document', lambda: None):
            down.fetch()
            correct_data = get_json_resource('sciencedirect_2_out.json')
            assert (down.ctx.data == correct_data)
コード例 #8
0
ファイル: test_iopscience.py プロジェクト: zzmjohn/papis
def test_1():
    # One old paper
    url = 'https://iopscience.iop.org/article/10.1088/0026-1394/12/4/002'
    down = papis.downloaders.get_downloader(url)
    assert (down.name == 'iopscience')
    with patch.object(down, '_get_body',
                      lambda: get_resource('iopscience_1.html')):
        with patch.object(down, 'download_document', lambda: None):
            down.fetch()
            correct_data = get_json_resource('iopscience_1_out.json')
            assert (down.ctx.data == correct_data)
コード例 #9
0
ファイル: test_iopscience.py プロジェクト: zzmjohn/papis
def test_2():
    # Multiple authors with affiliations
    url = 'https://iopscience.iop.org/article/10.1088/1748-605X/ab007b'
    down = papis.downloaders.get_downloader(url)
    assert (down.name == 'iopscience')
    with patch.object(down, '_get_body',
                      lambda: get_resource('iopscience_2.html')):
        with patch.object(down, 'download_document', lambda: None):
            down.fetch()
            correct_data = get_json_resource('iopscience_2_out.json')
            assert (down.ctx.data == correct_data)
コード例 #10
0
ファイル: test_acs.py プロジェクト: zzmjohn/papis
def test_acs_2():
    url = 'https://pubs.acs.org/pdf/10.1021/acscombsci.5b00087'
    down = papis.downloaders.get_downloader(url)
    assert (not down.ctx)
    with patch.object(down, '_get_body', lambda: get_resource('acs_2.html')):
        with patch.object(down, 'download_document', lambda: None):
            down.fetch()
            with open('acs_2_out.json', 'w+') as f:
                import json
                json.dump(down.ctx.data, f)
            correct_data = get_json_resource('acs_2_out.json')
            assert (down.ctx.data == correct_data)
コード例 #11
0
ファイル: test_annualreviews.py プロジェクト: zzmjohn/papis
def test_1():
    url = ('https://www.annualreviews.org/doi/10.1146/'
           'annurev-conmatphys-031214-014726')
    down = papis.downloaders.get_downloader(url)
    assert(down.name == 'annualreviews')
    with patch.object(down, '_get_body',
            lambda: get_resource('annualreviews_1.html')):
        with patch.object(down, 'download_document', lambda: None):
            down.fetch()
            # with open('annualreviews_1_out.json', 'w+') as f:
                # import json
                # json.dump(down.ctx.data, f)
            correct_data = get_json_resource('annualreviews_1_out.json')
            assert(down.ctx.data == correct_data)
コード例 #12
0
def test_2():
    url = 'https://www.tandfonline.com/doi/full/10.1080/23311932.2015.1117749'
    down = papis.downloaders.get_downloader(url)
    assert (down.name == 'tandfonline')

    # with open('tandfonline_2.html', 'w+') as f:
    #     f.write(down.session.get(url).content.decode())

    with patch.object(down, '_get_body',
                      lambda: get_resource('tandfonline_2.html')):
        down.fetch()
        with patch.object(down, 'download_document', lambda: None):
            # with open('tandfonline_2_out.json', 'w+') as f:
            #     import json
            #     json.dump(down.ctx.data, f,
            #             indent=2,
            #             sort_keys=True,
            #             ensure_ascii=False)
            correct_data = get_json_resource('tandfonline_2_out.json')
            assert (down.ctx.data == correct_data)