Exemple #1
0
def test_copy_construct():
    a = DocumentProto()
    b = Document(a, copy=True)
    a.id = '1' * 16
    assert b.id != '1' * 16

    b.id = '2' * 16
    assert a.id == '1' * 16
Exemple #2
0
def test_data_type_builder_doc_bad():
    a = DocumentProto()
    a.id = 'a236cbb0eda62d58'
    with pytest.raises(BadDocType):
        _new_doc_from_data(b'BREAKIT!' + a.SerializeToString(), DataInputType.DOCUMENT)

    with pytest.raises(BadDocType):
        _new_doc_from_data(MessageToJson(a) + '�', DataInputType.DOCUMENT)
Exemple #3
0
def test_data_type_builder_doc(builder):
    a = DocumentProto()
    a.id = 'a236cbb0eda62d58'
    d, t = _build_doc(builder(a),
                      DataInputType.DOCUMENT,
                      override_doc_id=False)
    assert d.id == a.id
    assert t == DataInputType.DOCUMENT
Exemple #4
0
def eval_request():
    req = Request()
    req.request_type = 'search'
    # doc: 1
    # doc: 2
    # doc: 3
    # doc: 4
    # doc: 5 - will be missing from KV indexer
    for idx in range(5):
        dp = DocumentProto()
        dp.id = f'0{str(idx + 1)}'
        req.docs.append(Document(dp))
    return req
Exemple #5
0
def test_data_type_builder_doc_bad():
    a = DocumentProto()
    a.id = 'a236cbb0eda62d58'
    with pytest.raises(BadDocType):
        _build_doc(b'BREAKIT!' + a.SerializeToString(),
                   DataInputType.DOCUMENT,
                   override_doc_id=False)

    with pytest.raises(BadDocType):
        _build_doc(MessageToJson(a) + '🍔',
                   DataInputType.DOCUMENT,
                   override_doc_id=False)

    with pytest.raises(BadDocType):
        _build_doc({'🍔': '🍔'}, DataInputType.DOCUMENT, override_doc_id=False)
Exemple #6
0
def test_data_type_builder_doc(builder):
    a = DocumentProto()
    a.id = 'a236cbb0eda62d58'
    d, t = _new_doc_from_data(builder(a), DataInputType.DOCUMENT)
    assert d.id == a.id
    assert t == DataInputType.DOCUMENT