def test_configure_with_file_validation_success(self, mock_open): with mock.patch('os.path.isfile', return_value=True): settings = Settings() settings.configure(settings_path='robottelo.properties') assert settings.configured assert settings.server.hostname == 'example.com' assert settings.server.ssh_password == '1234'
def test_configure_validation_success(self, mock_open): with mock.patch('os.path.isfile', return_value=True): settings = Settings() settings.configure() self.assertTrue(settings.configured) self.assertEqual(settings.server.hostname, 'example.com') self.assertEqual(settings.server.ssh_password, '1234')
def test_configure_validation_error(self, mock_open): settings = Settings() with pytest.raises(ImproperlyConfigured): settings.configure()
def test_configure_validation_error(self, mock_open): settings = Settings() with self.assertRaises(ImproperlyConfigured): settings.configure()
legacy_settings = LegacySettings() dynaconf_settings = LazySettings( envvar_prefix="ROBOTTELO", core_loaders=["YAML"], settings_file="settings.yaml", preload=["conf/*.yaml"], includes=["settings.local.yaml", ".secrets.yaml", ".secrets_*.yaml"], envless_mode=True, lowercase_read=True, ) dynaconf_settings.validators.register(**dynaconf_validators) try: legacy_settings.configure() except ImproperlyConfigured: logger.warning( "Legacy Robottelo settings configure() failed, most likely required " "configuration option is not provided. Continuing for the sake of unit tests" ) try: dynaconf_settings.validators.validate() except ValidationError: logger.warning( "Dynaconf validation failed, continuing for the sake of unit tests") settings_proxy = SettingsFacade() settings_proxy.set_configs(dynaconf_settings, legacy_settings)