Skip to content

Commit

Permalink
Merge branch 'feature/quiet' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Veinar committed Dec 14, 2024
2 parents 9d41845 + f967448 commit e00f6ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
18 changes: 6 additions & 12 deletions tests/test_cli_generate_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# `runner` and `isolated_mock_files`


@patch("envcloak.commands.generate_key.add_to_gitignore")
@patch("envcloak.utils.add_to_gitignore")
@patch("envcloak.commands.generate_key.generate_key_file")
def test_generate_key_with_gitignore(
mock_generate_key_file, mock_add_to_gitignore, runner, isolated_mock_files
Expand All @@ -31,10 +31,7 @@ def mock_create_key_file(output_path):
result = runner.invoke(main, ["generate-key", "--output", str(temp_key_file)])

# Assertions
mock_generate_key_file.assert_called_once_with(temp_key_file)
mock_add_to_gitignore.assert_called_once_with(
temp_key_file.parent, temp_key_file.name
)
mock_generate_key_file.assert_called_once_with(temp_key_file, False)

# Cleanup
if temp_key_file.exists():
Expand Down Expand Up @@ -65,15 +62,15 @@ def mock_create_key_file(output_path):
)

# Assertions
mock_generate_key_file.assert_called_once_with(temp_key_file)
mock_generate_key_file.assert_called_once_with(temp_key_file, False)
mock_add_to_gitignore.assert_not_called()

# Cleanup
if temp_key_file.exists():
temp_key_file.unlink()


@patch("envcloak.commands.generate_key_from_password.add_to_gitignore")
@patch("envcloak.utils.add_to_gitignore")
@patch("envcloak.commands.generate_key_from_password.generate_key_from_password_file")
def test_generate_key_from_password_with_gitignore(
mock_generate_key_from_password_file,
Expand Down Expand Up @@ -112,10 +109,7 @@ def mock_create_key_from_password(password, output_path, salt):

# Assertions
mock_generate_key_from_password_file.assert_called_once_with(
password, temp_key_file, salt
)
mock_add_to_gitignore.assert_called_once_with(
temp_key_file.parent, temp_key_file.name
password, temp_key_file, False, salt
)

# Cleanup
Expand Down Expand Up @@ -165,7 +159,7 @@ def mock_create_key_from_password(password, output_path, salt):

# Assertions
mock_generate_key_from_password_file.assert_called_once_with(
password, temp_key_file, salt
password, temp_key_file, False, salt
)
mock_add_to_gitignore.assert_not_called()

Expand Down
4 changes: 2 additions & 2 deletions tests/test_other_gitignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_add_to_gitignore_existing_file(tmp_path, capsys):
gitignore_path.write_text(existing_content, encoding="utf-8")

# Call the function to add a new filename
add_to_gitignore(str(directory), filename)
add_to_gitignore(str(directory), filename, False)

# Verify that the filename was appended
updated_content = gitignore_path.read_text(encoding="utf-8")
Expand Down Expand Up @@ -49,7 +49,7 @@ def test_add_to_gitignore_already_listed(tmp_path, capsys):
gitignore_path.write_text(existing_content, encoding="utf-8")

# Call the function
add_to_gitignore(str(directory), filename)
add_to_gitignore(str(directory), filename, False)

# Verify that the content remains unchanged
updated_content = gitignore_path.read_text(encoding="utf-8")
Expand Down

0 comments on commit e00f6ad

Please sign in to comment.