Skip to content

Commit 832b6b4

Browse files
authored
SCANPY-54: Running a scan displays a message to point the user to different Sonar product (#228)
1 parent 5599ac2 commit 832b6b4

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/pysonar_scanner/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ def scan():
5454

5555
def do_scan():
5656
app_logging.setup()
57+
logging.info(
58+
"Enhance your workflow: Pair pysonar with SonarQube Server per your license or SonarQube Cloud for deeper analysis, and try SonarQube-IDE in your favourite IDE."
59+
)
5760
logging.info("Starting Pysonar, the Sonar scanner CLI for Python")
5861
config = ConfigurationLoader.load()
5962
set_logging_options(config)

tests/unit/test_main.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919
#
2020
import pathlib
21-
from unittest.mock import patch, Mock
21+
from unittest.mock import patch, Mock, call
2222

2323
from pyfakefs import fake_filesystem_unittest as pyfakefs
2424

@@ -45,6 +45,7 @@
4545

4646
class TestMain(pyfakefs.TestCase):
4747

48+
@patch("pysonar_scanner.__main__.logging")
4849
@patch.object(pathlib.Path, "home", return_value=pathlib.Path("home/user"))
4950
@patch.object(
5051
ConfigurationLoader,
@@ -61,7 +62,9 @@ class TestMain(pyfakefs.TestCase):
6162
)
6263
@patch("pysonar_scanner.__main__.create_jre", return_value=JREResolvedPath(pathlib.Path("jre_path")))
6364
@patch.object(ScannerEngine, "run", return_value=0)
64-
def test_minimal_success_run(self, run_mock, create_jre_mock, provision_mock, load_mock, path_home_mock):
65+
def test_minimal_success_run(
66+
self, run_mock, create_jre_mock, provision_mock, load_mock, path_home_mock, mock_logging
67+
):
6568
exitcode = scan()
6669
self.assertEqual(exitcode, 0)
6770

@@ -84,6 +87,15 @@ def test_minimal_success_run(self, run_mock, create_jre_mock, provision_mock, lo
8487

8588
self.assertEqual(expected_config, config)
8689

90+
info_logs = [
91+
call(
92+
"Enhance your workflow: Pair pysonar with SonarQube Server per your license or SonarQube Cloud for deeper analysis, and try SonarQube-IDE in your favourite IDE."
93+
),
94+
call("Starting Pysonar, the Sonar scanner CLI for Python"),
95+
call("Starting the analysis..."),
96+
]
97+
mock_logging.info.assert_has_calls(info_logs)
98+
8799
@patch.object(ConfigurationLoader, "load")
88100
def test_scan_with_exception(self, load_mock):
89101
load_mock.side_effect = Exception("Test exception")

0 commit comments

Comments
 (0)