|
48 | 48 | SONAR_SCANNER_JAVA_OPTS, |
49 | 49 | ) |
50 | 50 | from pysonar_scanner.configuration.configuration_loader import ConfigurationLoader, SONAR_PROJECT_BASE_DIR |
51 | | -from pysonar_scanner.exceptions import MissingKeyException |
| 51 | +from pysonar_scanner.exceptions import MissingPropertyException |
52 | 52 |
|
53 | 53 |
|
54 | 54 | class TestConfigurationLoader(pyfakefs.TestCase): |
@@ -88,7 +88,7 @@ def test_get_token(self): |
88 | 88 | with self.subTest("Token is present"): |
89 | 89 | self.assertEqual(configuration_loader.get_token({SONAR_TOKEN: "myToken"}), "myToken") |
90 | 90 |
|
91 | | - with self.subTest("Token is absent"), self.assertRaises(MissingKeyException): |
| 91 | + with self.subTest("Token is absent"), self.assertRaises(MissingPropertyException): |
92 | 92 | configuration_loader.get_token({}) |
93 | 93 |
|
94 | 94 | @patch("sys.argv", ["myscript.py", "--token", "myToken", "--sonar-project-key", "myProjectKey"]) |
@@ -394,3 +394,21 @@ def test_unknown_args_with_D_prefix(self): |
394 | 394 | self.assertEqual(configuration["another.unknown.property"], "anotherValue") |
395 | 395 | self.assertEqual(configuration[SONAR_TOKEN], "myToken") |
396 | 396 | self.assertEqual(configuration[SONAR_PROJECT_KEY], "myProjectKey") |
| 397 | + |
| 398 | + def test_check_configuration(self): |
| 399 | + with self.subTest("Both values present"): |
| 400 | + ConfigurationLoader.check_configuration({SONAR_TOKEN: "", SONAR_PROJECT_KEY: ""}) |
| 401 | + |
| 402 | + with self.subTest("missing keys"): |
| 403 | + with self.assertRaises(MissingPropertyException) as cm: |
| 404 | + ConfigurationLoader.check_configuration({SONAR_PROJECT_KEY: "myKey"}) |
| 405 | + self.assertIn(SONAR_TOKEN, str(cm.exception)) |
| 406 | + |
| 407 | + with self.assertRaises(MissingPropertyException) as cm: |
| 408 | + ConfigurationLoader.check_configuration({SONAR_TOKEN: "myToken"}) |
| 409 | + self.assertIn(SONAR_PROJECT_KEY, str(cm.exception)) |
| 410 | + |
| 411 | + with self.assertRaises(MissingPropertyException) as cm: |
| 412 | + ConfigurationLoader.check_configuration({}) |
| 413 | + self.assertIn(SONAR_PROJECT_KEY, str(cm.exception)) |
| 414 | + self.assertIn(SONAR_TOKEN, str(cm.exception)) |
0 commit comments