Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
split unit & integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Panos Vagenas <[email protected]>
  • Loading branch information
vagenas committed Aug 27, 2024
1 parent 5cdc80e commit fc9a4c5
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Run checks
run: poetry run pre-commit run --all-files
- name: Run integration tests
run: poetry run pytest tests/integration
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ jobs:
# - uses: ./.github/actions/setup-poetry
# - name: Build docs
# run: poetry run mkdocs build --verbose --clean

2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:
files: '\.py$'
- id: pytest
name: Pytest
entry: poetry run pytest tests
entry: poetry run pytest tests/unit
pass_filenames: false
language: system
files: '\.py$'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ def test_retrieval():
)
retr_res = retriever.retrieve(QUERY)
act_data = dict(root=[n.text for n in retr_res])
with open("tests/data/2_out_retrieval_results.json") as f:
with open("tests/integration/data/0_out_retrieval_results.json") as f:
exp_data = json.load(fp=f)
assert exp_data == act_data
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@


def test_chunk_without_metadata():
with open("tests/data/0_inp_dl_doc.json") as f:
with open("tests/unit/data/0_inp_dl_doc.json") as f:
data_json = f.read()
dl_doc = DLDocument.model_validate_json(data_json)
chunker = HierarchicalChunker(include_metadata=False)
chunks = chunker.chunk(dl_doc=dl_doc)
act_data = dict(root=[n.model_dump() for n in chunks])
with open("tests/data/0_out_chunks_wout_meta.json") as f:
with open("tests/unit/data/0_out_chunks_wout_meta.json") as f:
exp_data = json.load(fp=f)
assert exp_data == act_data


def test_chunk_with_metadata():
with open("tests/data/0_inp_dl_doc.json") as f:
with open("tests/unit/data/0_inp_dl_doc.json") as f:
data_json = f.read()
dl_doc = DLDocument.model_validate_json(data_json)
chunker = HierarchicalChunker(include_metadata=True)
chunks = chunker.chunk(dl_doc=dl_doc)
act_data = dict(root=[n.model_dump() for n in chunks])
with open("tests/data/0_out_chunks_with_meta.json") as f:
with open("tests/unit/data/0_out_chunks_with_meta.json") as f:
exp_data = json.load(fp=f)
assert exp_data == act_data
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@


def test_node_parse():
with open("tests/data/1_inp_li_doc.json") as f:
with open("tests/unit/data/1_inp_li_doc.json") as f:
data_json = f.read()
li_doc = LIDocument.from_json(data_json)
node_parser = HierarchicalNodeParser(id_gen_seed=42)
nodes = node_parser._parse_nodes(nodes=[li_doc])
act_data = dict(root=[n.dict() for n in nodes])
with open("tests/data/1_out_nodes.json") as f:
with open("tests/unit/data/1_out_nodes.json") as f:
exp_data = json.load(fp=f)
assert exp_data == act_data

0 comments on commit fc9a4c5

Please sign in to comment.