-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/secureli-154-prompt-to-install-linters
- Loading branch information
Showing
3 changed files
with
19 additions
and
1 deletion.
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
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 |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
|
||
from secureli.utilities.git_meta import git_user_email, origin_url, current_branch_name | ||
|
||
mock_git_origin_url = r"[email protected]:my-org/repo%20with%20spaces.git" | ||
|
||
|
||
@pytest.fixture() | ||
def mock_subprocess(mocker: MockerFixture) -> MagicMock: | ||
|
@@ -36,6 +38,17 @@ def mock_open_git_head(mocker: MockerFixture) -> MagicMock: | |
return mock_open_git_head | ||
|
||
|
||
@pytest.fixture() | ||
def mock_open_git_origin(mocker: MockerFixture) -> MagicMock: | ||
mock_open_git_config = mocker.mock_open( | ||
read_data='[remote "origin"]' | ||
f"\n url = {mock_git_origin_url}" | ||
"\n fetch = +refs/heads/*:refs/remotes/origin/*" | ||
) | ||
mocker.patch("builtins.open", mock_open_git_config) | ||
return mock_open_git_config | ||
|
||
|
||
@pytest.fixture() | ||
def mock_open_io_error(mocker: MockerFixture) -> MagicMock: | ||
mock_open_io_error = mocker.patch("builtins.open") | ||
|
@@ -71,3 +84,7 @@ def test_current_branch_name_yields_unknown_due_to_io_error( | |
result = current_branch_name() | ||
|
||
assert result == "UNKNOWN" | ||
|
||
|
||
def test_configparser_can_read_origin_url_with_percent(mock_open_git_origin: MagicMock): | ||
assert origin_url() == mock_git_origin_url |