Skip to content

Commit

Permalink
fixing even more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nboyse committed Feb 17, 2025
1 parent d3d1fd4 commit cf8e48c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion redbox-core/tests/graph/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,6 @@ def test_get_available_keywords(tokeniser: Encoding, env: Settings):
env=env,
debug=LANGGRAPH_DEBUG,
)
keywords = {ChatRoute.search, ChatRoute.gadget}
keywords = {ChatRoute.search, ChatRoute.newroute, ChatRoute.gadget}

assert keywords == set(app.get_available_keywords().keys())
24 changes: 13 additions & 11 deletions redbox-core/tests/test_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
S3Client = object

import numpy as np

fake_embedding = np.random.rand(1024).tolist()


def file_to_s3(filename: str, s3_client: S3Client, env: Settings) -> str:
file_path = Path(__file__).parents[2] / "tests" / "data" / filename
file_name = file_path.name
Expand All @@ -54,6 +56,7 @@ def make_file_query(file_name: str, resolution: ChunkResolution | None = None) -
print("Constructed Query:", query) # Debugging: Print the query
return query


def fake_llm_response():
return {
"name": "foo",
Expand Down Expand Up @@ -120,9 +123,9 @@ def test_extract_metadata_extra_key(
metadata = metadata_loader.extract_metadata()

assert metadata is not None
assert metadata.name == "something"
assert metadata.description == ""
assert metadata.keywords == []
assert metadata.name == "foo"
assert metadata.description == "test"
assert metadata.keywords == ["abc"]


@patch("redbox.loader.loaders.get_chat_llm")
Expand Down Expand Up @@ -225,11 +228,11 @@ def test_ingest_from_loader(
"metadata": {
"languages": ["eng"],
"orig_elements": "eJwVjsFOwzAQRH9l5SMiCEVtSXrjxI0D4lZVaGNPgtV4HdlrVKj679iXXe3szOidbgYrAkS/vDNHMnY89NPezd2Be9ft+mHfjfM4dOwwvDg4O++ezSOZAGXHyjVzMyvLUnhBrtfJQBZzvleP4qqtM8WiXhaC8LQiU8mkkWwCK2hC3uIFlNqWXN9sbUyuBaqrZCTyopXwiXDlsLUGL3YtDkd6oI/XtzpzCYET+z9WH6UK28peyH6zNlr93dBI3jml6vjBZ0O7n/8BhxNVfA==",
"filename": "example.html",
"filetype": "text/html",
},
}
]
"filename": "example.html",
"filetype": "text/html",
},
}
]

mock_llm_response = mock_llm.return_value
mock_llm_response.status_code = 200
Expand Down Expand Up @@ -296,7 +299,6 @@ def get_metadata(chunk: dict) -> dict:
es_client.delete_by_query(index=es_index, body=file_query)



@patch("redbox.loader.loaders.get_chat_llm")
@patch("redbox.loader.loaders.requests.post")
@pytest.mark.parametrize(
Expand Down Expand Up @@ -376,7 +378,7 @@ def test_ingest_file(
except Exception as e:
print(f"Exception during scanning: {e}")
raise

assert len(chunks) > 0

def get_metadata(chunk: dict) -> dict:
Expand All @@ -400,4 +402,4 @@ def get_chunk_resolution(chunk: dict) -> str:
assert len(largest_resolution) > 0

# Teardown
es_client.delete_by_query(index=es_index, body=file_query)
es_client.delete_by_query(index=es_index, body=file_query)

0 comments on commit cf8e48c

Please sign in to comment.