Skip to content

Commit

Permalink
Merge pull request #81 from ayasyrev:app_output_refactor
Browse files Browse the repository at this point in the history
App_output_refactor
  • Loading branch information
ayasyrev authored Sep 17, 2024
2 parents f549b93 + 69b965a commit 86ba1d9
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions tests/test_app_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import subprocess

from pytest import CaptureFixture

from nbmetaclean.helpers import read_nb, write_nb


Expand All @@ -31,33 +29,33 @@ def run_app(

example_nbs_path = Path("tests/test_nbs")

# this test conflict with coverage - need to be fixed
# def test_app_clean_no_args(tmp_path: Path) -> None:
# """test app_clean with no args"""
# res_out, res_err = run_app(cwd=tmp_path)
# assert res_out == "No notebooks found at current directory.\n"
# assert not res_err

def test_app_clean_no_args(tmp_path: Path) -> None:
"""test app_clean with no args"""
res_out, res_err = run_app(cwd=tmp_path)
assert res_out == "No notebooks found at current directory.\n"
assert not res_err
# # prepare test clean notebook
# nb_name_clean = "test_nb_2_clean.ipynb"
# test_nb = read_nb(example_nbs_path / nb_name_clean)
# test_nb_path = tmp_path / nb_name_clean
# write_nb(test_nb, test_nb_path)

# prepare test clean notebook
nb_name_clean = "test_nb_2_clean.ipynb"
test_nb = read_nb(example_nbs_path / nb_name_clean)
test_nb_path = tmp_path / nb_name_clean
write_nb(test_nb, test_nb_path)
# res_out, res_err = run_app(cwd=tmp_path)
# assert res_out == "Checked: 1 notebooks. All notebooks are clean.\n"
# assert not res_err

res_out, res_err = run_app(cwd=tmp_path)
assert res_out == "Checked: 1 notebooks. All notebooks are clean.\n"
assert not res_err
# # add metadata
# test_nb["metadata"]["some key"] = "some value"
# write_nb(test_nb, test_nb_path)

# add metadata
test_nb["metadata"]["some key"] = "some value"
write_nb(test_nb, test_nb_path)

res_out, res_err = run_app(cwd=tmp_path)
assert res_out == "cleaned: test_nb_2_clean.ipynb\n"
assert not res_err
# res_out, res_err = run_app(cwd=tmp_path)
# assert res_out == "cleaned: test_nb_2_clean.ipynb\n"
# assert not res_err


def test_clean_nb_metadata(tmp_path: Path, capsys: CaptureFixture) -> None:
def test_clean_nb_metadata(tmp_path: Path) -> None:
"""test clean_nb_metadata"""
nb_name_clean = "test_nb_2_clean.ipynb"
test_nb = read_nb(example_nbs_path / nb_name_clean)
Expand Down

0 comments on commit 86ba1d9

Please sign in to comment.