def test_get_config_dict_with_no_global_config(self): env = { 'home_path': get_fixture_path('unexistent_home'), 'xdg_config_home': get_fixture_path('unexistent_xdg_config_home'), } expected_config_dict = {'source_name': 'ConfigGlobalSource'} config_source = self.initialize_config_source_with_env(ConfigGlobalSource, env) self.assertConfigDict(config_source, expected_config_dict)
def test_get_config_dict_with_no_global_config(self): env = { 'home_path': get_fixture_path('unexistent_home'), 'xdg_config_home': get_fixture_path('unexistent_xdg_config_home'), } expected_config_dict = {} config_source = self.initialize_config_source_with_env(ConfigGlobalSource, env) self.assertConfigDict(config_source, expected_config_dict)
def test_get_config_dict(self): env = { 'home_path': get_fixture_path('dummy_home'), 'xdg_config_home': get_fixture_path('unexistent_xdg_config_home'), } expected_config_dict = { 'cmdargs': { 'verbose': bool, 'error-limit': int, 'severity': Enum, } } config_source = self.initialize_config_source_with_env(ConfigGlobalSource, env) self.assertConfigValueType(config_source, expected_config_dict)
def test_get_config_dict(self): env = { 'home_path': get_fixture_path('dummy_home'), 'xdg_config_home': get_fixture_path('unexistent_xdg_config_home'), } expected_config_dict = { 'cmdargs': { 'verbose': bool, 'error-limit': int, 'severity': Level, }, 'source_name': str, } config_source = self.initialize_config_source_with_env(ConfigGlobalSource, env) self.assertConfigValueType(config_source, expected_config_dict)
def test_get_config_dict_with_no_global_config(self): env = {'cwd': get_fixture_path('unexistent_project')} expected_config_dict = {} config_source = self.initialize_config_source_with_env( ConfigProjectSource, env) self.assertConfigDict(config_source, expected_config_dict)
def test_get_config_dict_with_no_global_config(self): env = { 'cwd': get_fixture_path('unexistent_project') } expected_config_dict = {} config_source = self.initialize_config_source_with_env(ConfigProjectSource, env) self.assertConfigDict(config_source, expected_config_dict)
def test_get_config_dict(self): env = {'cwd': get_fixture_path('project_with_long_extname')} expected_type = { 'cmdargs': { 'verbose': bool, 'error-limit': int, 'severity': Enum, } } config_source = self.initialize_config_source_with_env( ConfigProjectSource, env) self.assertConfigValueType(config_source, expected_type)
def test_get_config_dict(self): env = { 'cwd': get_fixture_path('project') } expected_type = { 'cmdargs': { 'verbose': bool, 'error-limit': int, 'severity': Enum, } } config_source = self.initialize_config_source_with_env(ConfigProjectSource, env) self.assertConfigValueType(config_source, expected_type)
def test_get_config_dict_for_no_extname(self): env = { 'cwd': get_fixture_path('project_with_no_extname') } expected_type = { 'cmdargs': { 'verbose': bool, 'error-limit': int, 'severity': Level, }, 'source_name': str, } config_source = self.initialize_config_source_with_env(ConfigProjectSource, env) self.assertConfigValueType(config_source, expected_type)
def test_get_config_dict_on_sub_directory(self): env = { 'cwd': get_fixture_path( Path('project_with_long_extname') / 'sub' / 'subsub') } expected_type = { 'cmdargs': { 'verbose': bool, 'error-limit': int, 'severity': Level, }, 'source_name': str, } config_source = self.initialize_config_source_with_env( ConfigProjectSource, env) self.assertConfigValueType(config_source, expected_type)
import unittest from test.asserting.config_source import ConfigSourceAssertion from test.asserting.config_source import get_fixture_path from vint.linting.config.config_file_source import ConfigFileSource from vint.linting.level import Level FIXTURE_CONFIG_FILE = get_fixture_path('fixture_config_file') class TestConfigFileSource(ConfigSourceAssertion, unittest.TestCase): class ConcreteConfigFileSource(ConfigFileSource): def get_file_path(self, env): return FIXTURE_CONFIG_FILE def test_get_config_dict(self): expected_config_dict = { 'cmdargs': { 'verbose': True, 'severity': Level.WARNING, 'error-limit': 10, }, 'policies': { 'ProhibitSomethingEvil': { 'enabled': False, }, 'ProhibitSomethingDengerous': { 'enabled': True, }, }
class Fixtures(enum.Enum): SIMPLE = get_fixture_path("fixture_for_line_comment_simple.vim") LAMBDA_STRING_EXPR = get_fixture_path("fixture_for_line_comment_lambda_string_expr.vim")