Skip to content

Commit

Permalink
Add expected content and metadata in test_load_json_files() and refac…
Browse files Browse the repository at this point in the history
…tor assertion
  • Loading branch information
guybartal committed Mar 17, 2024
1 parent a6124aa commit 2d19261
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@

def test_load_json_files():
keys_to_load = ["content", "title"]
expected_content = [
{"content": "This is the content for item 1.", "title": "Title TEST 1"},
{"content": "This is the content for item 2.", "title": "Title 2"},
{"content": "This is the content for item 3.", "title": "Title 3"},
{"content": "This is the content for item 4.", "title": "Title 4"},
{"content": "This is the content for item 5.", "title": "Title 5"},
{"content": "This is the content for item 6.", "title": "Title 6"},
]
expected_metadata = {
"source": "/workspaces/rag-experiment-accelerator/rag_experiment_accelerator/doc_loader/tests/test_data/json/data.valid.json"
}

docs = load_structured_files(
chunking_strategy="basic",
AzureDocumentIntelligenceCredentials=None,
Expand All @@ -26,14 +38,8 @@ def test_load_json_files():
},
)
doc = list(docs[0].values())[0]
assert (
str(doc["content"])
== "[{'content': 'This is the content for item 1.', 'title': 'Title TEST 1'}, {'content': 'This is the content for item 2.', 'title': 'Title 2'}, {'content': 'This is the content for item 3.', 'title': 'Title 3'}, {'content': 'This is the content for item 4.', 'title': 'Title 4'}, {'content': 'This is the content for item 5.', 'title': 'Title 5'}, {'content': 'This is the content for item 6.', 'title': 'Title 6'}]"
)
assert (
str(doc["metadata"])
== "{'source': '/workspaces/rag-experiment-accelerator/rag_experiment_accelerator/doc_loader/tests/test_data/json/data.valid.json'}"
)
assert doc["content"] == str(expected_content)
assert doc["metadata"] == expected_metadata


def test_load_json_files_raises_invalid_keys():
Expand Down

0 comments on commit 2d19261

Please sign in to comment.