-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f1aebd
commit 343f64a
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import pytest | ||
|
||
from griptape.loaders.text_loader import TextLoader | ||
|
||
|
||
class TestBaseFileLoader: | ||
@pytest.fixture(params=["ascii", "utf-8", None]) | ||
def loader(self, request): | ||
encoding = request.param | ||
if encoding is None: | ||
return TextLoader() | ||
else: | ||
return TextLoader(encoding=encoding) | ||
|
||
@pytest.fixture(params=["path_from_resource_path"]) | ||
def create_source(self, request): | ||
return request.getfixturevalue(request.param) | ||
|
||
def test_fetch(self, loader, create_source): | ||
source = create_source("test.txt") | ||
|
||
data = loader.fetch(source) | ||
|
||
assert data.startswith(b"foobar foobar foobar") | ||
|
||
def test_save(self, loader, create_source): | ||
source = create_source("test.txt") | ||
|
||
data = loader.load(source) | ||
|
||
destination = create_source("test_copy.txt") | ||
|
||
loader.save(destination, data) | ||
|
||
data_copy = loader.load(destination) | ||
|
||
assert data.value == data_copy.value |