New configuration is successfully written and comments are preserved.
(self)
| 177 | config.validate() |
| 178 | |
| 179 | def test_save(self): |
| 180 | """New configuration is successfully written and comments are preserved.""" |
| 181 | config = BinaryAlertConfig() |
| 182 | config._config['force_destroy'] = True |
| 183 | config.aws_region = 'us-west-2' |
| 184 | config.name_prefix = 'new_name_prefix' |
| 185 | config.enable_carbon_black_downloader = False |
| 186 | config.carbon_black_url = 'https://example2.com' |
| 187 | config.encrypted_carbon_black_api_token = 'B' * 100 |
| 188 | config.save() |
| 189 | |
| 190 | # Verify that all of the original comments were preserved. |
| 191 | with open(CONFIG_FILE) as config_file: |
| 192 | raw_data = config_file.read() |
| 193 | for i in range(1, 6): |
| 194 | self.assertIn('comment{}'.format(i), raw_data) |
| 195 | |
| 196 | new_config = BinaryAlertConfig() |
| 197 | self.assertEqual(True, new_config._config['force_destroy']) |
| 198 | self.assertEqual(config.aws_region, new_config.aws_region) |
| 199 | self.assertEqual(config.name_prefix, new_config.name_prefix) |
| 200 | self.assertEqual( |
| 201 | config.enable_carbon_black_downloader, new_config.enable_carbon_black_downloader) |
| 202 | self.assertEqual( |
| 203 | config.encrypted_carbon_black_api_token, new_config.encrypted_carbon_black_api_token) |
nothing calls this directly
no test coverage detected