This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
1 changed file
with
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import qsv | ||
import pytest | ||
from pathlib import Path | ||
from .test_data import test_data | ||
|
||
|
||
class TestIndexFunc: | ||
@pytest.mark.parametrize( | ||
"file_name", | ||
[("fruits.csv")], | ||
) | ||
def test_index(self, file_name, tmp_path: Path): | ||
"""Generate an index for a given file path at `filename.ext.idx` where `.ext` is the file's extension.""" | ||
|
||
# Make a temporary data file in a temporary directory | ||
tmp_file = tmp_path.joinpath(file_name).resolve() | ||
tmp_file.write_text(test_data[file_name].read_text(), encoding="utf-8") | ||
|
||
qsv.index(tmp_file, run=True) | ||
idx_file = tmp_path.joinpath(f"{file_name}.idx").resolve() | ||
|
||
assert idx_file.exists() | ||
|
||
@pytest.mark.parametrize( | ||
"file_name", | ||
[("fruits.csv")], | ||
) | ||
def test_output(self, file_name, tmp_path: Path): | ||
"""Generate an index for a given file path at a specified output path.""" | ||
|
||
# Make a temporary data file in a temporary directory | ||
tmp_file = tmp_path.joinpath(file_name).resolve() | ||
tmp_file.write_text(test_data[file_name].read_text(), encoding="utf-8") | ||
output_file = tmp_path.joinpath( | ||
f"arbitrary_path{''.join(test_data[file_name].suffixes)}.idx" | ||
).resolve() | ||
|
||
qsv.index(tmp_file, output=output_file.as_posix(), run=True) | ||
|
||
assert output_file.exists() |