@@ -37,28 +37,35 @@ def test_missing_cli_args(self):
3737 error_output = mock_stderr .getvalue ()
3838 self .assertIn ("the following arguments are required: -t/--token" , error_output )
3939
40- @patch ("sys.argv" , ["myscript.py" , "--token" , "myToken" ])
40+ @patch ("sys.argv" , ["myscript.py" , "--token" , "myToken" , "--sonar-project-key" , "myProjectKey" ])
4141 def test_minimal_cli_args (self ):
4242 configuration = ConfigurationLoader .initialize_configuration ()
4343 expected_internal = Internal ()
4444 expected_scanner = Scanner (internal = expected_internal )
45- expected_sonar = Sonar (scanner = expected_scanner , token = "myToken" )
45+ expected_sonar = Sonar (scanner = expected_scanner , token = "myToken" , project_key = "myProjectKey" )
4646 expected_configuration = Configuration (sonar = expected_sonar )
4747 self .assertEqual (configuration , expected_configuration )
4848
49- @patch ("sys.argv" , ["myscript.py" , "-t" , "myToken" , "-v" ])
5049 def test_alternative_cli_args (self ):
51- alternatives = [["-t" , "myToken" , "-v" ], ["--sonar-token" , "myToken" , "--sonar-verbose" ]]
50+ alternatives = [
51+ ["-t" , "myToken" , "-v" , "--sonar-project-key" , "myProjectKey" ],
52+ ["--sonar-token" , "myToken" , "--sonar-verbose" , "--sonar-project-key" , "myProjectKey" ],
53+ ]
5254 for alternative in alternatives :
5355 with patch ("sys.argv" , ["myscript.py" , * alternative ]), patch ("sys.stderr" , new = StringIO ()):
5456 configuration = ConfigurationLoader .initialize_configuration ()
5557 expected_internal = Internal ()
5658 expected_scanner = Scanner (internal = expected_internal )
57- expected_sonar = Sonar (scanner = expected_scanner , token = "myToken" , verbose = True )
59+ expected_sonar = Sonar (
60+ scanner = expected_scanner , token = "myToken" , project_key = "myProjectKey" , verbose = True
61+ )
5862 expected_configuration = Configuration (sonar = expected_sonar )
5963 self .assertEqual (configuration , expected_configuration )
6064
61- @patch ("sys.argv" , ["myscript.py" , "-t" , "myToken" , "--sonar-scanner-os" , "windows2" ])
65+ @patch (
66+ "sys.argv" ,
67+ ["myscript.py" , "-t" , "myToken" , "--sonar-project-key" , "myProjectKey" , "--sonar-scanner-os" , "windows2" ],
68+ )
6269 def test_impossible_os_choice (self ):
6370 with patch ("sys.stderr" , new = StringIO ()) as mock_stderr :
6471 with self .assertRaises (SystemExit ):
@@ -73,6 +80,8 @@ def test_impossible_os_choice(self):
7380 "myscript.py" ,
7481 "-t" ,
7582 "myToken" ,
83+ "--sonar-project-key" ,
84+ "myProjectKey" ,
7685 "-v" ,
7786 "--sonar-host-url" ,
7887 "mySonarHostUrl" ,
@@ -154,6 +163,7 @@ def test_all_cli_args(self):
154163 expected_sonar = Sonar (
155164 scanner = expected_scanner ,
156165 token = "myToken" ,
166+ project_key = "myProjectKey" ,
157167 verbose = True ,
158168 host_url = "mySonarHostUrl" ,
159169 region = "us" ,
@@ -165,7 +175,7 @@ def test_all_cli_args(self):
165175 self .assertEqual (configuration , expected_configuration )
166176
167177 def test_minimal_json (self ):
168- minimal_json = Configuration (sonar = Sonar (token = "MyToken " )).to_json ()
178+ minimal_json = Configuration (sonar = Sonar (token = "myToken" , project_key = "myProjectKey " )).to_json ()
169179
170180 minimal_dict = json .loads (minimal_json )
171181 self .assertIn ("scannerProperties" , minimal_dict )
@@ -184,7 +194,8 @@ def test_minimal_json(self):
184194 "scannerProperties" : [
185195 {"key" : "sonar.scanner.app" , "value" : "python" },
186196 {"key" : "sonar.scanner.appVersion" , "value" : "1.0" },
187- {"key" : "sonar.token" , "value" : "MyToken" },
197+ {"key" : "sonar.token" , "value" : "myToken" },
198+ {"key" : "sonar.projectKey" , "value" : "myProjectKey" },
188199 {"key" : "sonar.verbose" , "value" : False },
189200 {"key" : "sonar.scanner.bootstrapStartTime" , "value" : bootstrap_start_time },
190201 ]
@@ -224,7 +235,8 @@ def test_full_json(self):
224235
225236 sonar = Sonar (
226237 scanner = scanner ,
227- token = "MyToken" ,
238+ token = "myToken" ,
239+ project_key = "myProjectKey" ,
228240 verbose = True ,
229241 host_url = "mySonarHostUrl" ,
230242 region = "us" ,
@@ -252,7 +264,8 @@ def test_full_json(self):
252264 "scannerProperties" : [
253265 {"key" : "sonar.scanner.app" , "value" : "python" },
254266 {"key" : "sonar.scanner.appVersion" , "value" : "1.0" },
255- {"key" : "sonar.token" , "value" : "MyToken" },
267+ {"key" : "sonar.token" , "value" : "myToken" },
268+ {"key" : "sonar.projectKey" , "value" : "myProjectKey" },
256269 {"key" : "sonar.region" , "value" : "us" },
257270 {"key" : "sonar.host.url" , "value" : "mySonarHostUrl" },
258271 {"key" : "sonar.projectBaseDir" , "value" : "mySonarProjectBaseDir" },
0 commit comments