Skip to content

Commit

Permalink
Rename test file
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Apr 23, 2024
1 parent 5622fc5 commit 68405dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
File renamed without changes.
12 changes: 6 additions & 6 deletions tests/unit/utils/test_file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

class TestFileUtils:
def test_load_file(self):
file = utils.load_file("tests/resources/foobar.txt")
file = utils.load_file("tests/resources/foobar-many.txt")

assert file.decode("utf-8").startswith("foobar foobar foobar")
assert len(file.decode("utf-8")) == 4563

def test_load_files(self):
sources = ["tests/resources/foobar.txt", "tests/resources/foobar.txt", "tests/resources/small.png"]
sources = ["tests/resources/foobar-many.txt", "tests/resources/foobar-many.txt", "tests/resources/small.png"]
files = utils.load_files(sources, futures_executor=futures.ThreadPoolExecutor(max_workers=1))
assert len(files) == 2

test_file = files[utils.str_to_hash("tests/resources/foobar.txt")]
test_file = files[utils.str_to_hash("tests/resources/foobar-many.txt")]
assert len(test_file) == 4563
assert test_file.decode("utf-8").startswith("foobar foobar foobar")

Expand All @@ -27,20 +27,20 @@ def test_load_files(self):
assert small_file[:8] == b"\x89PNG\r\n\x1a\n"

def test_load_file_with_loader(self):
file = utils.load_file("tests/resources/foobar.txt")
file = utils.load_file("tests/resources/foobar-many.txt")
artifacts = TextLoader(max_tokens=MAX_TOKENS, embedding_driver=MockEmbeddingDriver()).load(file)

assert len(artifacts) == 39
assert isinstance(artifacts, list)
assert artifacts[0].value.startswith("foobar foobar foobar")

def test_load_files_with_loader(self):
sources = ["tests/resources/foobar.txt"]
sources = ["tests/resources/foobar-many.txt"]
files = utils.load_files(sources)
loader = TextLoader(max_tokens=MAX_TOKENS, embedding_driver=MockEmbeddingDriver())
collection = loader.load_collection(list(files.values()))

test_file_artifacts = collection[loader.to_key(files[utils.str_to_hash("tests/resources/foobar.txt")])]
test_file_artifacts = collection[loader.to_key(files[utils.str_to_hash("tests/resources/foobar-many.txt")])]
assert len(test_file_artifacts) == 39
assert isinstance(test_file_artifacts, list)
assert test_file_artifacts[0].value.startswith("foobar foobar foobar")

0 comments on commit 68405dd

Please sign in to comment.