1717# along with this program; if not, write to the Free Software Foundation,
1818# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919#
20-
20+ import os
2121from unittest .mock import patch
2222
2323import pyfakefs .fake_filesystem_unittest as pyfakefs
2626from pysonar_scanner .configuration .properties import (
2727 SONAR_PROJECT_KEY ,
2828 SONAR_PROJECT_NAME ,
29+ SONAR_PROJECT_BASE_DIR ,
2930 SONAR_SCANNER_APP ,
3031 SONAR_SCANNER_APP_VERSION ,
3132 SONAR_SCANNER_BOOTSTRAP_START_TIME ,
4950 SONAR_SCANNER_ARCH ,
5051 SONAR_SCANNER_OS ,
5152)
52- from pysonar_scanner .configuration .configuration_loader import ConfigurationLoader , SONAR_PROJECT_BASE_DIR
53+ from pysonar_scanner .configuration .configuration_loader import ConfigurationLoader
5354from pysonar_scanner .exceptions import MissingKeyException
5455from pysonar_scanner .utils import Arch , Os
5556
@@ -66,6 +67,9 @@ def setUp(self):
6667
6768 @patch ("sys.argv" , ["myscript.py" , "--token" , "myToken" , "--sonar-project-key" , "myProjectKey" ])
6869 def test_defaults (self , mock_get_os , mock_get_arch ):
70+ custom_dir = "/my_analysis_directory"
71+ self .fs .create_dir (custom_dir )
72+ os .chdir (custom_dir )
6973 configuration = ConfigurationLoader .load ()
7074 expected_configuration = {
7175 SONAR_TOKEN : "myToken" ,
@@ -75,7 +79,7 @@ def test_defaults(self, mock_get_os, mock_get_arch):
7579 SONAR_SCANNER_BOOTSTRAP_START_TIME : configuration [SONAR_SCANNER_BOOTSTRAP_START_TIME ],
7680 SONAR_VERBOSE : False ,
7781 SONAR_SCANNER_SKIP_JRE_PROVISIONING : False ,
78- SONAR_PROJECT_BASE_DIR : "/" ,
82+ SONAR_PROJECT_BASE_DIR : "/my_analysis_directory " ,
7983 SONAR_SCANNER_CONNECT_TIMEOUT : 5 ,
8084 SONAR_SCANNER_SOCKET_TIMEOUT : 60 ,
8185 SONAR_SCANNER_RESPONSE_TIMEOUT : 0 ,
@@ -102,7 +106,7 @@ def test_dynamic_defaults_are_loaded(self, get_static_default_properties_mock, m
102106 self .assertDictEqual (
103107 config ,
104108 {
105- SONAR_PROJECT_BASE_DIR : "/" ,
109+ SONAR_PROJECT_BASE_DIR : os . getcwd () ,
106110 SONAR_SCANNER_OS : Os .LINUX .value ,
107111 SONAR_SCANNER_ARCH : Arch .X64 .value ,
108112 },
@@ -141,7 +145,7 @@ def test_load_sonar_project_properties(self, mock_get_os, mock_get_arch):
141145 SONAR_SCANNER_BOOTSTRAP_START_TIME : configuration [SONAR_SCANNER_BOOTSTRAP_START_TIME ],
142146 SONAR_VERBOSE : False ,
143147 SONAR_SCANNER_SKIP_JRE_PROVISIONING : False ,
144- SONAR_PROJECT_BASE_DIR : "/" ,
148+ SONAR_PROJECT_BASE_DIR : os . getcwd () ,
145149 SONAR_SCANNER_CONNECT_TIMEOUT : 5 ,
146150 SONAR_SCANNER_SOCKET_TIMEOUT : 60 ,
147151 SONAR_SCANNER_RESPONSE_TIMEOUT : 0 ,
@@ -287,7 +291,7 @@ def test_load_pyproject_toml_from_toml_path(self, mock_get_os, mock_get_arch):
287291 SONAR_SCANNER_BOOTSTRAP_START_TIME : configuration [SONAR_SCANNER_BOOTSTRAP_START_TIME ],
288292 SONAR_VERBOSE : False ,
289293 SONAR_SCANNER_SKIP_JRE_PROVISIONING : False ,
290- SONAR_PROJECT_BASE_DIR : "/" ,
294+ SONAR_PROJECT_BASE_DIR : os . getcwd () ,
291295 SONAR_SCANNER_CONNECT_TIMEOUT : 5 ,
292296 SONAR_SCANNER_SOCKET_TIMEOUT : 60 ,
293297 SONAR_SCANNER_RESPONSE_TIMEOUT : 0 ,
0 commit comments