Skip to content

Commit

Permalink
Merge pull request #119 from Kuniwak/fix-style-problem
Browse files Browse the repository at this point in the history
Fix style problem
  • Loading branch information
Kuniwak committed Jan 25, 2015
2 parents df0e764 + c3ba0d7 commit 95d5471
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 4 deletions.
66 changes: 63 additions & 3 deletions test/unit/vint/linting/config/test_config_cmdargs_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

class TestConfigFileSource(ConfigSourceAssertion, unittest.TestCase):
def test_get_config_dict(self):
env = {
'cmdargs': {
'verbose': True,
'style': True,
'warning': True,
'max-violations': 10,
},
}

expected_config_dict = {
'cmdargs': {
'verbose': True,
Expand All @@ -15,12 +24,63 @@ def test_get_config_dict(self):
},
}

config_source = self.initialize_config_source_with_env(ConfigCmdargsSource, env)
self.assertConfigDict(config_source, expected_config_dict)


def test_get_config_dict_with_no_severity(self):
env = {'cmdargs': {}}

expected_config_dict = {'cmdargs': {}}

config_source = self.initialize_config_source_with_env(ConfigCmdargsSource, env)
self.assertConfigDict(config_source, expected_config_dict)


def test_get_config_dict_with_severity_style_problem(self):
env = {
'cmdargs': {
'style_problem': True,
},
}

expected_config_dict = {
'cmdargs': {
'severity': Level.STYLE_PROBLEM,
},
}

config_source = self.initialize_config_source_with_env(ConfigCmdargsSource, env)
self.assertConfigDict(config_source, expected_config_dict)


def test_get_config_dict_with_severity_warning(self):
env = {
'cmdargs': {
'verbose': True,
'style': True,
'warning': True,
'max-violations': 10,
},
}

expected_config_dict = {
'cmdargs': {
'severity': Level.WARNING,
},
}

config_source = self.initialize_config_source_with_env(ConfigCmdargsSource, env)
self.assertConfigDict(config_source, expected_config_dict)


def test_get_config_dict_with_severity_error(self):
env = {
'cmdargs': {
'error': True,
},
}

expected_config_dict = {
'cmdargs': {
'severity': Level.ERROR,
},
}

Expand Down
2 changes: 1 addition & 1 deletion vint/linting/config/config_cmdargs_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _normalize_severity(self, env, config_dict):
# 1. error
# 2. warning
# 3. style problem
if env_cmdargs.get('style', False):
if env_cmdargs.get('style_problem', False):
config_dict_cmdargs['severity'] = Level.STYLE_PROBLEM

if env_cmdargs.get('warning', False):
Expand Down

0 comments on commit 95d5471

Please sign in to comment.