-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add SAFETY_DB_DIR env var to the scan command (#523)
- Loading branch information
1 parent
4ef66e0
commit a1692d5
Showing
8 changed files
with
85 additions
and
15 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
import pytest | ||
from unittest.mock import Mock, patch | ||
from safety.scan.finder.handlers import PythonFileHandler | ||
|
||
@patch('safety.safety.fetch_database') | ||
def test_download_required_assets(mock_fetch_database): | ||
handler = PythonFileHandler() | ||
session = Mock() | ||
|
||
os.environ["SAFETY_DB_DIR"] = "/path/to/db" | ||
handler.download_required_assets(session) | ||
|
||
_, kwargs = mock_fetch_database.call_args | ||
|
||
assert kwargs['db'] == "/path/to/db" | ||
|
||
@patch('safety.safety.fetch_database') | ||
def test_download_required_assets_no_db_dir(mock_fetch_database): | ||
handler = PythonFileHandler() | ||
session = Mock() | ||
|
||
if "SAFETY_DB_DIR" in os.environ: | ||
del os.environ["SAFETY_DB_DIR"] | ||
handler.download_required_assets(session) | ||
|
||
_, kwargs = mock_fetch_database.call_args | ||
|
||
assert kwargs['db'] == False |