def _parse_puppet_modules( lines: List[str]) -> Tuple[List[ForgeModule], List[GitModule]]: forge_modules = [] git_modules = [] for index, line in enumerate(lines): if line.startswith('mod '): if not line.endswith(','): forge_modules.append(ForgeModule.from_line(line)) else: count = 1 while lines[index + count].endswith(','): count += 1 module_lines = lines[index:(index + count + 1)] git_module = GitModule.from_lines(module_lines) git_modules.append(git_module) return forge_modules, git_modules
def test_it_returns_forge_module_from_line_with_version_latest(): forge_module = ForgeModule.from_line( "mod 'puppetlabs/apache', :latest") assert forge_module.name == 'puppetlabs/apache' assert forge_module.version == ':latest'
def test_with_a_bad_module(): with pytest.raises(ModuleParserException): ForgeModule.from_line("mod 'puppetlabs/apache', '0.1', 'bad'")
def test_it_returns_forge_module_from_line_without_version(): forge_module = ForgeModule.from_line("mod 'puppetlabs/apache'") assert forge_module.name == 'puppetlabs/apache' assert forge_module.version is None