@@ -37,28 +37,35 @@ def test_missing_cli_args(self):
37
37
error_output = mock_stderr .getvalue ()
38
38
self .assertIn ("the following arguments are required: -t/--token" , error_output )
39
39
40
- @patch ("sys.argv" , ["myscript.py" , "--token" , "myToken" ])
40
+ @patch ("sys.argv" , ["myscript.py" , "--token" , "myToken" , "--sonar-project-key" , "myProjectKey" ])
41
41
def test_minimal_cli_args (self ):
42
42
configuration = ConfigurationLoader .initialize_configuration ()
43
43
expected_internal = Internal ()
44
44
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" )
46
46
expected_configuration = Configuration (sonar = expected_sonar )
47
47
self .assertEqual (configuration , expected_configuration )
48
48
49
- @patch ("sys.argv" , ["myscript.py" , "-t" , "myToken" , "-v" ])
50
49
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
+ ]
52
54
for alternative in alternatives :
53
55
with patch ("sys.argv" , ["myscript.py" , * alternative ]), patch ("sys.stderr" , new = StringIO ()):
54
56
configuration = ConfigurationLoader .initialize_configuration ()
55
57
expected_internal = Internal ()
56
58
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
+ )
58
62
expected_configuration = Configuration (sonar = expected_sonar )
59
63
self .assertEqual (configuration , expected_configuration )
60
64
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
+ )
62
69
def test_impossible_os_choice (self ):
63
70
with patch ("sys.stderr" , new = StringIO ()) as mock_stderr :
64
71
with self .assertRaises (SystemExit ):
@@ -73,6 +80,8 @@ def test_impossible_os_choice(self):
73
80
"myscript.py" ,
74
81
"-t" ,
75
82
"myToken" ,
83
+ "--sonar-project-key" ,
84
+ "myProjectKey" ,
76
85
"-v" ,
77
86
"--sonar-host-url" ,
78
87
"mySonarHostUrl" ,
@@ -154,6 +163,7 @@ def test_all_cli_args(self):
154
163
expected_sonar = Sonar (
155
164
scanner = expected_scanner ,
156
165
token = "myToken" ,
166
+ project_key = "myProjectKey" ,
157
167
verbose = True ,
158
168
host_url = "mySonarHostUrl" ,
159
169
region = "us" ,
@@ -165,7 +175,7 @@ def test_all_cli_args(self):
165
175
self .assertEqual (configuration , expected_configuration )
166
176
167
177
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 ()
169
179
170
180
minimal_dict = json .loads (minimal_json )
171
181
self .assertIn ("scannerProperties" , minimal_dict )
@@ -184,7 +194,8 @@ def test_minimal_json(self):
184
194
"scannerProperties" : [
185
195
{"key" : "sonar.scanner.app" , "value" : "python" },
186
196
{"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" },
188
199
{"key" : "sonar.verbose" , "value" : False },
189
200
{"key" : "sonar.scanner.bootstrapStartTime" , "value" : bootstrap_start_time },
190
201
]
@@ -224,7 +235,8 @@ def test_full_json(self):
224
235
225
236
sonar = Sonar (
226
237
scanner = scanner ,
227
- token = "MyToken" ,
238
+ token = "myToken" ,
239
+ project_key = "myProjectKey" ,
228
240
verbose = True ,
229
241
host_url = "mySonarHostUrl" ,
230
242
region = "us" ,
@@ -252,7 +264,8 @@ def test_full_json(self):
252
264
"scannerProperties" : [
253
265
{"key" : "sonar.scanner.app" , "value" : "python" },
254
266
{"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" },
256
269
{"key" : "sonar.region" , "value" : "us" },
257
270
{"key" : "sonar.host.url" , "value" : "mySonarHostUrl" },
258
271
{"key" : "sonar.projectBaseDir" , "value" : "mySonarProjectBaseDir" },
0 commit comments