コード例 #1
0
def test_client_split_for_url():
    dbbuddy = Db.DbBuddy()
    client = Db.GenericClient(dbbuddy, max_url=40)
    assert client.group_terms_for_url(ACCNS) == ['NP_001287575.1,ADH10263.1', 'XP_005165403.2,A0A087WX72,A0A096MTH0',
                                                 'A0A0A9YFB0,XM_003978475', 'ENSAMEG00000011912,ENSCJAG00000008732',
                                                 'ENSMEUG00000000523']
    client = Db.GenericClient(dbbuddy, max_url=10)
    with pytest.raises(ValueError) as err:
        client.group_terms_for_url(ACCNS)
    assert "The provided accession or search term is too long (>10)." in str(err)
コード例 #2
0
def test_client_parse_error_file():
    dbbuddy = Db.DbBuddy()
    client = Db.GenericClient(dbbuddy)

    assert not client.parse_error_file()
    assert not dbbuddy.failures
    client.http_errors_file.write("Casp9\n%s\n//\n" % HTTPError(
        "101", "Fake HTTPError from Mock", "Foo", "Bar", StringIO("Baz")))
    client.http_errors_file.write("Inx1\n%s\n//\n" %
                                  URLError("Fake URLError from Mock"))

    assert client.parse_error_file() == '''Casp9
HTTP Error Fake HTTPError from Mock: Foo

Inx1
<urlopen error Fake URLError from Mock>

'''
    assert len(dbbuddy.failures) == 2

    # Repeat to make sure that the same error is not added again
    client.http_errors_file.write("Inx1\n%s\n//\n" %
                                  URLError("Fake URLError from Mock"))
    assert not client.parse_error_file()
    assert len(dbbuddy.failures) == 2
コード例 #3
0
def test_client_init():
    dbbuddy = Db.DbBuddy(", ".join(ACCNS[3:6]))
    client = Db.GenericClient(dbbuddy)
    assert hash(dbbuddy) == hash(client.dbbuddy)
    assert type(client.http_errors_file) == br.TempFile
    assert type(client.results_file) == br.TempFile
    assert client.max_url == 1000
    with client.lock:
        assert True