Ejemplo n.º 1
0
def test_fetch_journal_nonetwork(capsys, mock_init_sample, reqs):
    bibcode = '1918ApJ....48..154S'
    filename = None
    pm.fetch(bibcode, filename=filename)
    captured = capsys.readouterr()
    assert captured.out == ("Fetching PDF file from Journal website:\n"
                            "Failed to establish a web connection.\n")
Ejemplo n.º 2
0
def test_fetch_journal(capsys, mock_init_sample, reqs):
    bibcode = '1957RvMP...29..547B'
    filename = None
    pm.fetch(bibcode, filename=filename)
    captured = capsys.readouterr()
    assert captured.out == ("Fetching PDF file from Journal website:\n"
                            "Saved PDF to: "
                            f"'{u.BM_PDF()}Burbidge1957_RvMP_29_547.pdf'.\n")
Ejemplo n.º 3
0
def test_fetch_ads_nonetwork(capsys, mock_init_sample, reqs):
    bibcode = '2009ApJ...699..564S'
    filename = None
    pm.fetch(bibcode, filename=filename)
    captured = capsys.readouterr()
    assert captured.out == ("Fetching PDF file from Journal website:\n"
                            "Request failed with status code 403: Forbidden\n"
                            "Fetching PDF file from ADS website:\n"
                            "Failed to establish a web connection.\n")
Ejemplo n.º 4
0
def test_fetch_non_database(tmp_path, capsys, mock_init, reqs):
    os.chdir(tmp_path)
    bibcode = '1957RvMP...29..547B'
    filename = None
    pm.fetch(bibcode, filename=filename)
    captured = capsys.readouterr()
    assert captured.out == (
        "Fetching PDF file from Journal website:\n"
        "Saved PDF to: '1957RvMP...29..547B.pdf'.\n"
        "(Note that BibTex entry is not in the Bibmanager database)\n")
Ejemplo n.º 5
0
def test_fetch_ads(capsys, mock_init_sample, reqs):
    bibcode = '1913LowOB...2...56S'
    filename = None
    pm.fetch(bibcode, filename=filename)
    captured = capsys.readouterr()
    assert captured.out == (
        "Fetching PDF file from Journal website:\n"
        "Request failed with status code 403: Forbidden\n"
        "Fetching PDF file from ADS website:\n"
        f"Saved PDF to: '{u.BM_PDF()}Slipher1913_LowOB_2_56.pdf'.\n")
Ejemplo n.º 6
0
def test_fetch_arxiv_fail(capsys, mock_init_sample, reqs):
    bibcode = '2010arXiv1007.0324B'
    filename = None
    pm.fetch(bibcode, filename=filename)
    captured = capsys.readouterr()
    assert captured.out == ("Fetching PDF file from Journal website:\n"
                            "Request failed with status code 403: Forbidden\n"
                            "Fetching PDF file from ADS website:\n"
                            "Request failed with status code 404: NOT FOUND\n"
                            "Fetching PDF file from ArXiv website:\n"
                            "Request failed with status code 404: NOT FOUND\n"
                            "Could not fetch PDF from any source.\n")
Ejemplo n.º 7
0
def test_fetch_arxiv(capsys, mock_init_sample, reqs):
    bibcode = '1917PASP...29..206C'
    filename = None
    pm.fetch(bibcode, filename=filename)
    captured = capsys.readouterr()
    assert captured.out == (
        "Fetching PDF file from Journal website:\n"
        "Request failed with status code 403: Forbidden\n"
        "Fetching PDF file from ADS website:\n"
        "Request failed with status code 404: NOT FOUND\n"
        "Fetching PDF file from ArXiv website:\n"
        "Saved PDF to: "
        f"'{u.BM_PDF()}Curtis1917_arxiv_PASP_29_206.pdf'.\n")
Ejemplo n.º 8
0
def test_fetch_invalid_filename(mock_init_sample, reqs):
    bibcode = '1917PASP...29..206C'
    filename = 'pdf_file'
    with pytest.raises(ValueError,
            match='Invalid filename, must have a .pdf extension'):
        pm.fetch(bibcode, filename=filename)
Ejemplo n.º 9
0
def test_fetch_pathed_filename(mock_init_sample, reqs):
    bibcode = '1917PASP...29..206C'
    filename = 'path/file.pdf'
    with pytest.raises(ValueError, match='filename must not have a path'):
        pm.fetch(bibcode, filename=filename)