def test_validate_server_unicode(self): self.virt_config = EsxConfigSection('test_esx', None) for key, value in self.UNICODE_SERVER_CONFIG.items(): self.virt_config[key] = value result = self.virt_config._validate_server('server') expected_result = ('error', "Option server needs to be ASCII characters only: 'test_esx'") six.assertCountEqual(self, result, expected_result)
def setUp(self): config_values = { 'type': 'esx', 'server': 'localhost', 'username': '******', 'password': '******', 'owner': 'owner', } config = EsxConfigSection('test', None) config.update(**config_values) config.validate() self.esx = Esx(self.logger, config, None, interval=DefaultInterval) # No dest given here
class TestEsxConfigSection(ConfigSectionValidationTests, TestBase): """ A group of tests to ensure proper validation of EsxConfigSections """ CONFIG_CLASS = EsxConfigSection VALID_CONFIG = { "type": "esx", "server": "1.2.3.4", "username": "******", "password": "******", "owner": "admin", "filter_host_parents": "'PARENT_A', 'PARENT_B'", "exclude_host_parents": "'PARENT_C_EXCLUDED'", } UNICODE_SERVER_CONFIG = { "type": "esx", "server": "红帽€467aa", "username": "******", "password": "******", "owner": "admin", "filter_host_parents": "'PARENT_A', 'PARENT_B'", "exclude_host_parents": "'PARENT_C_EXCLUDED'", } SAM_REQUIRED_KEYS = { 'type', 'server', 'username', 'password', 'owner', } SAT5_REQUIRED_KEYS = SAM_REQUIRED_KEYS - {'owner'} DEFAULTS = { 'filter_host_parents': None, 'exclude_host_parents': None, 'hypervisor_id': 'uuid', 'simplified_vim': True, 'sm_type': SAT6, } def test_validate_server_unicode(self): self.virt_config = EsxConfigSection('test_esx', None) for key, value in self.UNICODE_SERVER_CONFIG.items(): self.virt_config[key] = value result = self.virt_config._validate_server('server') expected_result = ('error', "Option server needs to be ASCII characters only: 'test_esx'") six.assertCountEqual(self, result, expected_result)