Skip to content

Commit ae9b848

Browse files
committed
SCANPY-54: Running a scan displays a message to point the user to different Sonar product
1 parent 68b7420 commit ae9b848

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/pysonar_scanner/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def scan():
5050

5151
def do_scan():
5252
app_logging.setup()
53+
logging.info("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.")
5354
logging.info("Starting Pysonar, the Sonar scanner CLI for Python")
5455
config = ConfigurationLoader.load()
5556
set_logging_options(config)

tests/unit/test_main.py

Lines changed: 9 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,8 @@
4545

4646
class TestMain(pyfakefs.TestCase):
4747

48+
@patch("pysonar_scanner.__main__.logging")
49+
4850
@patch.object(pathlib.Path, "home", return_value=pathlib.Path("home/user"))
4951
@patch.object(
5052
ConfigurationLoader,
@@ -61,7 +63,7 @@ class TestMain(pyfakefs.TestCase):
6163
)
6264
@patch("pysonar_scanner.__main__.create_jre", return_value=JREResolvedPath(pathlib.Path("jre_path")))
6365
@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):
66+
def test_minimal_success_run(self, run_mock, create_jre_mock, provision_mock, load_mock, path_home_mock, mock_logging):
6567
exitcode = scan()
6668
self.assertEqual(exitcode, 0)
6769

@@ -83,6 +85,11 @@ def test_minimal_success_run(self, run_mock, create_jre_mock, provision_mock, lo
8385
}
8486

8587
self.assertEqual(expected_config, config)
88+
89+
info_logs = [call("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."),
90+
call("Starting Pysonar, the Sonar scanner CLI for Python"),
91+
call("Starting the analysis...")]
92+
mock_logging.info.assert_has_calls(info_logs)
8693

8794
@patch.object(ConfigurationLoader, "load")
8895
def test_scan_with_exception(self, load_mock):

0 commit comments

Comments
 (0)