-
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.
Merge pull request #3 from sumeshi/feature/v0.3.1
feat: add test
- Loading branch information
Showing
3 changed files
with
101 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import io | ||
from qsv import main | ||
from qsv.controllers.DataFrameController import DataFrameController | ||
import polars | ||
|
||
scriptpath = '__init__.py' | ||
logpath = 'Security.csv' | ||
|
||
def test_load_unit(): | ||
d = DataFrameController() | ||
d.load(logpath) | ||
assert type(d.df) == polars.lazyframe.frame.LazyFrame | ||
|
||
def test_load_cli(monkeypatch): | ||
argv = [scriptpath, "load", logpath] | ||
stdin = io.StringIO() | ||
stdout = io.StringIO() | ||
|
||
with monkeypatch.context() as m: | ||
m.setattr("sys.argv", argv) | ||
m.setattr("sys.stdin", stdin) | ||
m.setattr("sys.stdout", stdout) | ||
main() | ||
assert stdout.getvalue().startswith('shape: ') | ||
|
||
def test_load_quilt(tmpdir, monkeypatch): | ||
config = """title: test | ||
rules: | ||
load: | ||
""" | ||
temp_file = tmpdir.join('tmprule.yaml') | ||
temp_file.write(config) | ||
|
||
argv = [scriptpath, "quilt", str(temp_file), logpath] | ||
stdin = io.StringIO() | ||
stdout = io.StringIO() | ||
|
||
with monkeypatch.context() as m: | ||
m.setattr("sys.argv", argv) | ||
m.setattr("sys.stdin", stdin) | ||
m.setattr("sys.stdout", stdout) | ||
main() | ||
assert stdout.getvalue().startswith('Loaded Rules') |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.