Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor querylang test use types #1963

Merged
merged 1 commit into from Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 8 additions & 9 deletions tests/unit/drivers/querylang/test_querylang_drivers.py
Expand Up @@ -2,41 +2,40 @@

from jina.executors.segmenters import BaseSegmenter
from jina.flow import Flow
from jina.proto import jina_pb2
from jina import Document


def random_docs(num_docs):
for j in range(num_docs):
d = jina_pb2.DocumentProto()
d = Document()
d.text = 'hello world'
d.uri = 'doc://'
d.tags['id'] = j
for m in range(10):
dm = d.matches.add()
dm = Document()
dm.text = 'match to other world'
dm.uri = 'doc://match'
dm.tags['id'] = m
d.matches.add(dm)
yield d


def random_docs_to_chunk():
d1 = jina_pb2.DocumentProto()
d1 = Document()
d1.tags['id'] = 1
d1.text = 'chunk1 chunk2'
yield d1
d2 = jina_pb2.DocumentProto()
d2 = Document()
d2.tags['id'] = 1
d2.text = 'chunk3'
yield d2


def random_docs_with_tags():
d1 = jina_pb2.DocumentProto()
d1 = Document()
d1.tags['id'] = 1
d1.text = 'a'
d1.tags.update({'id': 1})
yield d1
d2 = jina_pb2.DocumentProto()
d2 = Document()
d2.tags['id'] = 2
d2.tags.update({'id': 2})
d2.text = 'b'
Expand Down
13 changes: 6 additions & 7 deletions tests/unit/drivers/querylang/test_querylang_reader.py
Expand Up @@ -6,29 +6,28 @@
from jina.drivers.querylang.slice import SliceQL
from jina.drivers.querylang.select import ExcludeQL
from jina.flow import Flow
from jina.proto import jina_pb2
from jina import Document
from jina.types.querylang import QueryLang
from jina.types.sets import QueryLangSet


def random_docs(num_docs):
for j in range(num_docs):
d = jina_pb2.DocumentProto()
d = Document()
d.tags['id'] = j
d.text = 'hello world'
d.uri = 'doc://'
for m in range(10):
dm = d.matches.add()
dm = Document()
dm.text = 'match to hello world'
dm.uri = 'doc://match'
dm.tags['id'] = m
dm.score.ref_id = d.id
d.matches.add(dm)
for mm in range(10):
dmm = dm.matches.add()
dmm = Document()
dmm.text = 'nested match to match'
dmm.uri = 'doc://match/match'
dmm.tags['id'] = mm
dmm.score.ref_id = dm.id
dm.matches.add(dmm)
yield d


Expand Down