Skip to content

Commit

Permalink
created mock to override file open
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Bowden committed Jun 27, 2024
1 parent c1b55b3 commit 5e6a020
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/application/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,19 @@ def test_that_scan_implements_multiple_file_args(mock_container: MagicMock):
)


def test_that_update_with_new_pattern_succeeds():
@pytest.fixture()
def mock_secureli_yaml_open_fn(mocker: MockerFixture) -> MagicMock:
mock_open = mocker.mock_open(
read_data="""
{}
"""
)
return mocker.patch("builtins.open", mock_open)


def test_that_update_with_new_pattern_succeeds(
mock_secureli_yaml_open_fn: MagicMock, # so we don't open and write to the actual secureli.yaml file
):
result = CliRunner().invoke(secureli.main.app, ["update", "--new-pattern", "foo"])
assert result.exit_code == 0
assert result.stdout == ""

0 comments on commit 5e6a020

Please sign in to comment.