Merge "Throw TypeError in repository enable/disable macros"

This commit is contained in:
Zuul 2020-03-03 18:41:46 +00:00 committed by Gerrit Code Review
commit e58653c436
2 changed files with 16 additions and 0 deletions

View File

@ -88,6 +88,9 @@ def handle_repos(context, reponames, mode):
else:
raise KeyError
if not isinstance(reponames, list):
raise TypeError("First argument should be a list of repositories")
repofile = os.path.dirname(os.path.realpath(__file__)) + '/repos.yaml'
with open(repofile, 'r') as repos_file:
repo_data = {}

View File

@ -150,3 +150,16 @@ class MethodsTest(base.TestCase):
result = methods.handle_repos(template_vars, ['grafana'], 'disable')
expectCmd = ''
self.assertEqual(expectCmd, result)
def test_handle_repos_string(self):
template_vars = {
'base_arch': 'x86_64',
'base_distro': 'debian',
'base_package_type': 'deb'
}
self.assertRaisesRegex(TypeError,
r'First argument should be a list of '
r'repositories',
methods.handle_repos, template_vars, 'grafana',
'disable')