def test_prime_with_build_package_with_any_architecture(self, _): self.useFixture( fixtures.EnvironmentVariable('SNAPCRAFT_BUILD_INFO', '1')) self.fake_apt_cache.add_package( fixture_setup.FakeAptCachePackage('test-package', 'test-version')) self.make_snapcraft_yaml("""parts: test-part: plugin: nil build-packages: ['test-package:any'] """) lifecycle.execute('prime', self.project_options) expected = ("""name: test version: 0 summary: test description: test confinement: strict grade: stable parts: test-part: build-packages: ['test-package:any'] installed-packages: [] plugin: nil prime: [] stage: [] stage-packages: [] uname: Linux test uname 4.10 x86_64 architectures: [{}] build-packages: [test-package=test-version] build-snaps: [] """.format(self.project_options.deb_arch)) self.assertThat(os.path.join('prime', 'snap', 'manifest.yaml'), FileContains(expected))
def test_get_installed_packages(self): for name, version, installed in ( ('test-installed-package', 'test-installed-package-version', True), ('test-not-installed-package', 'dummy', False)): self.fake_apt_cache.add_package( fixture_setup.FakeAptCachePackage( name, version, installed=installed)) self.assertThat( repo.Repo.get_installed_packages(), Equals(['test-installed-package=test-installed-package-version']))
def test_prime_with_source_details(self, _): self.useFixture(fixtures.EnvironmentVariable( 'SNAPCRAFT_BUILD_INFO', '1')) self.fake_apt_cache.add_package( fixture_setup.FakeAptCachePackage('git', 'testversion')) self.make_snapcraft_yaml( textwrap.dedent("""\ parts: test-part: plugin: nil source: test-source source-type: git source-commit: test-commit """)) lifecycle.execute('prime', self.project_options) expected = textwrap.dedent("""\ name: test version: 0 summary: test description: test confinement: strict grade: stable parts: test-part: build-packages: [] installed-packages: [] installed-snaps: [] plugin: nil prime: [] source: test-source source-branch: '' source-checksum: '' source-commit: test-commit source-tag: '' source-type: git stage: [] stage-packages: [] uname: Linux test uname 4.10 x86_64 architectures: [{}] build-packages: [git=testversion] build-snaps: [] """.format(self.project_options.deb_arch)) self.assertThat( os.path.join('prime', 'snap', 'manifest.yaml'), FileContains(expected))
def test_prime_with_installed_packages(self): self.useFixture( fixtures.EnvironmentVariable('SNAPCRAFT_BUILD_INFO', '1')) for name, version in [('test-package1', 'test-version1'), ('test-package2', 'test-version2')]: self.fake_apt_cache.add_package( fixture_setup.FakeAptCachePackage(name, version, installed=True)) self.make_snapcraft_yaml( textwrap.dedent("""\ parts: test-part: plugin: nil """)) lifecycle.execute('prime', self.project_options) expected = textwrap.dedent("""\ name: test version: 0 summary: test description: test confinement: strict grade: stable parts: test-part: build-packages: [] installed-packages: {} installed-snaps: [] plugin: nil prime: [] stage: [] stage-packages: [] uname: Linux test uname 4.10 x86_64 architectures: [{}] build-packages: [] build-snaps: [] """.format( '[test-package1=test-version1, ' 'test-package2=test-version2]', self.project_options.deb_arch)) self.assertThat(os.path.join('prime', 'snap', 'manifest.yaml'), FileContains(expected))
def test_prime_with_virtual_build_package(self, _): self.useFixture( fixtures.EnvironmentVariable('SNAPCRAFT_BUILD_INFO', '1')) fake_apt_cache = fixture_setup.FakeAptCache() self.useFixture(fake_apt_cache) fake_apt_cache.cache['test-provider-package'] = ( fixture_setup.FakeAptCachePackage( fake_apt_cache.path, 'test-provider-package', 'test-version', provides=['test-virtual-package'])) self.make_snapcraft_yaml("""parts: test-part: plugin: nil build-packages: ['test-virtual-package'] """) lifecycle.execute('prime', self.project_options) expected = ("""name: test version: 0 summary: test description: test confinement: strict grade: stable parts: test-part: build-packages: [test-virtual-package] plugin: nil prime: [] stage: [] stage-packages: [] architectures: [{}] build-packages: [test-provider-package=test-version] """.format(self.project_options.deb_arch)) self.assertThat(os.path.join('prime', 'snap', 'manifest.yaml'), FileContains(expected))