def generator(self): """Test template.""" # Set fake content MockSrcFile.set_content(content) if os.path.basename(path) in ['src-PECL.tar']: src = tarball.Source(url, destination, path, 'phpize') else: src = tarball.Source(url, destination, path) self.assertEqual(src.type, src_type) self.assertEqual(src.prefix, prefix, f"fail for: {url}") self.assertEqual(src.subdir, subdir)
def test_extract_sources(self): """Test for tarball.extract_sources method.""" # Set up input values main_src = tarball.Source('https://example1.tar', '', '/tmp') arch1_src = tarball.Source('https://example2.tar', '', '/tmp') arch2_src = tarball.Source('https://example3.tar', ':', '/tmp') arch3_src = tarball.Source('https://example4.tar', '', '/tmp') archives_src = [arch1_src, arch2_src, arch3_src] tarball.extract_sources(main_src, archives_src) # Sources with destination=':' should not be extracted, so method # should be called only 3 times. self.assertEqual(tarball.Source.extract.call_count, 3)
def test_process_multiver_archives(self): """Test for tarball.process_multiver_archives method.""" # Set up input values main_src = tarball.Source('https://example/src-5.0.tar', ':', '/tmp/src.tar') multiver_archives = [] config_versions = { '5.0': 'https://example/src-5.0.tar', '4.0': 'https://example/src-4.0.tar', '3.5': 'https://example/src-3.5.tar', '3.0': 'https://example/src-3.0.tar', } expected_multiver_archives = [ 'https://example/src-4.0.tar', '', 'https://example/src-3.5.tar', '', 'https://example/src-3.0.tar', '', ] # Set up a return value for parse_config_versions method attrs = {'parse_config_versions.return_value': config_versions} conf = Mock() conf.configure_mock(**attrs) self.content.config = conf self.content.process_multiver_archives(main_src, multiver_archives) self.assertEqual(multiver_archives, expected_multiver_archives)
def generator(self): """Test template.""" # Set fake content MockSrcFile.set_content(content) src = tarball.Source(url, destination, path) self.assertEqual(src.type, src_type) self.assertEqual(src.prefix, prefix) self.assertEqual(src.subdir, subdir)