Skip to content

Commit

Permalink
Merge pull request #3 from sumeshi/feature/v0.3.1
Browse files Browse the repository at this point in the history
feat: add test
  • Loading branch information
sumeshi authored Nov 4, 2024
2 parents f54dee2 + 8f94594 commit 34da9f5
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ build-backend = "hatchling.build"
[dependency-groups]
dev = [
"pdoc>=15.0.0",
"pytest>=8.3.3",
]

[project.scripts]
Expand Down
43 changes: 43 additions & 0 deletions tests/units/test_load.py
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')
59 changes: 57 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 34da9f5

Please sign in to comment.