Skip to content

Commit

Permalink
Fix unit tests for invalid config (#867)
Browse files Browse the repository at this point in the history
(cherry picked from commit bd34895)
  • Loading branch information
jyejare authored and web-flow committed Jan 4, 2023
1 parent 42c9bab commit d3b9312
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from unittest.mock import mock_open
from unittest.mock import patch

from packaging.version import InvalidVersion
from packaging.version import parse

from nailgun.config import _get_config_file_path
Expand All @@ -19,8 +20,8 @@
'default': {'url': 'http://example.com'},
'Ask Aak': {'url': 'bogus value', 'auth': ['username', 'password']},
'Acros-Krik': {'url': 'booger', 'version': '1.2.3.4.dev5+67'},
'King Adas': {'url': 'burger', 'version': 'silly version'},
}
INVALID_CONFIG = {'url': 'burger', 'version': 'silly version'}
CONFIGS2 = CONFIGS.copy()
CONFIGS2.update(
{
Expand Down Expand Up @@ -62,6 +63,13 @@ def test_init(self):
vars(BaseServerConfig(**config)),
)

def test_init_invalid(self):
"""Test instantiating :class: `nailgun.config.BaseServerConfig`.
Assert that configs with invalid versions do not load.
"""
with self.assertRaises(InvalidVersion):
_convert_bsc_attrs(INVALID_CONFIG)

def test_get(self):
"""Test :meth:`nailgun.config.BaseServerConfig.get`.
Expand Down

0 comments on commit d3b9312

Please sign in to comment.