def test_prime_without_packages_version(self): """Test the recorded manifest for a snap with packages This snap declares all the packages that it requires, there are no additional dependencies. The packages don't specify their version. """ self.run_snapcraft( 'prime', project_dir='stage-packages-without-dependencies') with open(os.path.join('snap', 'snapcraft.yaml')) as source_yaml_file: source_yaml = yaml.load(source_yaml_file) part_name = 'part-with-stage-packages' expected_packages = [ '{}={}'.format( package, integration.get_package_version( package, self.distro_series, self.deb_arch)) for package in source_yaml['parts'][part_name]['stage-packages'] ] recorded_yaml_path = os.path.join( self.prime_dir, 'snap', 'manifest.yaml') with open(recorded_yaml_path) as recorded_yaml_file: recorded_yaml = yaml.load(recorded_yaml_file) self.assertThat( recorded_yaml['parts'][part_name]['stage-packages'], Equals(expected_packages))
def test_prime_with_packages_missing_dependency(self): """Test the recorded manifest for a snap with packages This snap declares one package that has undeclared dependencies. """ self.copy_project_to_cwd('stage-packages-missing-dependency') part_name = 'part-with-stage-packages' self.set_stage_package_version( os.path.join('snap', 'snapcraft.yaml'), part_name, package='haskell-doc') self.run_snapcraft('prime') expected_packages = [ '{}={}'.format( package, integration.get_package_version( package, self.distro_series, self.deb_arch)) for package in [ 'haskell-doc', 'haskell98-tutorial', 'haskell98-report'] ] recorded_yaml_path = os.path.join( self.prime_dir, 'snap', 'manifest.yaml') with open(recorded_yaml_path) as recorded_yaml_file: recorded_yaml = yaml.load(recorded_yaml_file) self.assertThat( recorded_yaml['parts'][part_name]['stage-packages'], Equals(expected_packages))
def test_prime_with_build_packages(self): """Test the recorded manifest for a snap with build packages This snap declares one global build package that has undeclared dependencies. """ expected_packages = [ 'haskell-doc', 'haskell98-tutorial', 'haskell98-report'] self.addCleanup( subprocess.call, ['sudo', 'apt', 'remove', '-y'] + expected_packages) self.run_snapcraft('prime', self.snap) expected_packages_with_version = [ '{}={}'.format( package, integration.get_package_version( package, self.distro_series, self.deb_arch)) for package in expected_packages ] recorded_yaml_path = os.path.join( self.prime_dir, 'snap', 'manifest.yaml') with open(recorded_yaml_path) as recorded_yaml_file: recorded_yaml = yaml.load(recorded_yaml_file) self.assertThat( recorded_yaml['build-packages'], Equals(expected_packages_with_version))
def test_pull_with_virtual_build_package(self): virtual_package = 'fortunes-off' self.addCleanup(subprocess.call, ['sudo', 'apt-get', 'remove', virtual_package]) self.run_snapcraft('pull', 'build-virtual-package') state_file = os.path.join('snap', '.snapcraft', 'state') with open(state_file) as f: state = yaml.load(f) self.assertIn( '{}={}'.format( virtual_package, integration.get_package_version(virtual_package, self.distro_series, self.deb_arch)), state.assets['build-packages'])