Exemplo n.º 1
0
def test_input_lines_with_jsonlines_docs():
    result = list(
        DocumentArray.from_lines(
            filepath='tests/unit/clients/python/docs.jsonlines'))
    assert len(result) == 2
    assert result[0].text == "a"
    assert result[1].text == "b"
Exemplo n.º 2
0
def test_input_csv_from_lines_field_resolver():
    with open(os.path.join(cur_dir, 'docs.csv')) as fp:
        result = list(
            DocumentArray.from_lines(fp,
                                     line_format='csv',
                                     field_resolver={'question': 'text'}))
    assert len(result) == 2
    assert isinstance(result[0], Document)
    assert result[0].tags['source'] == 'testsrc'
    assert not result[0].uri
    assert result[0].text
Exemplo n.º 3
0
def test_input_lines_with_empty_filepath_and_lines():
    with pytest.raises(ValueError):
        lines = DocumentArray.from_lines(lines=None, filepath=None)
        for _ in lines:
            pass
Exemplo n.º 4
0
def test_input_csv_from_lines():
    with open(os.path.join(cur_dir, 'docs.csv')) as fp:
        result = list(DocumentArray.from_lines(fp, line_format='csv'))
    assert len(result) == 2
    assert isinstance(result[0], Document)
    assert result[0].tags['source'] == 'testsrc'
Exemplo n.º 5
0
def test_input_lines_with_filepath(filepath):
    result = list(DocumentArray.from_lines(filepath=filepath, size=2))
    assert len(result) == 2
    assert isinstance(result[0], Document)