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
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)
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
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
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)
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