Exemple #1
0
    def test_snap_exists_but_not_on_channel(self):
        # If the snap tested here does not exist, then BuildSnapsTestCase
        # will fail.
        if os.environ.get('ADT_TEST') and self.deb_arch == 'armhf':
            self.expectFailure('The autopkgtest armhf runners cannot '
                               'install snaps')
        snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
        snapcraft_yaml.update_part(
            'test-part-with-build-snap', {
                'plugin': 'nil',
                'build-snaps':
                ['u1test-snap-with-tracks/not-exists/candidate']
            })
        self.useFixture(snapcraft_yaml)

        exception = self.assertRaises(subprocess.CalledProcessError,
                                      self.run_snapcraft, ['build'])

        self.assertThat(exception.returncode, Equals(2))
        self.assertThat(exception.output,
                        Contains("'u1test-snap-with-tracks'"))

        self.assertFalse(
            snapcraft.repo.snaps.SnapPackage.is_snap_installed(
                'u1test-snap-with-tracks'))
    def test_desktop_extracted_from_appstream(self):
        xdg_data_dir = os.path.join('usr', 'local', 'share', 'applications')
        os.makedirs(os.path.join(xdg_data_dir, 'com.example.test'))
        shutil.copyfile(
            os.path.join(os.path.dirname(tests.__file__), 'data',
                         'test.desktop'),
            os.path.join(self.path, xdg_data_dir, 'com.example.test',
                         'app.desktop'))

        snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path,
                                                     summary=None,
                                                     description=None)
        snapcraft_yaml.data['adopt-info'] = 'test-part'
        snapcraft_yaml.update_part('test-part', {
            'plugin': 'dump',
            'parse-info': ['test.metainfo.xml']
        })
        snapcraft_yaml.update_app('test-app', {'command': 'echo'})
        self.useFixture(snapcraft_yaml)

        self.run_snapcraft('prime')

        self.assertThat(
            os.path.join('prime', 'meta', 'gui', 'test-app.desktop'),
            FileExists())
 def test_plain_source_string(self):
     snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
     snapcraft_yaml.update_part('my-part', {
         'plugin': 'nil',
         'source': self.test_source,
     })
     self.useFixture(snapcraft_yaml)
     self.run_snapcraft(['pull'])
Exemple #4
0
 def test_build_snap(self):
     self.useFixture(fixture_setup.WithoutSnapInstalled(self.snap))
     snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
     snapcraft_yaml.update_part('test-part-with-build-snap', {
         'plugin': 'nil',
         'build-snaps': [self.snap]
     })
     self.useFixture(snapcraft_yaml)
     self.run_snapcraft('build')
     self.assertTrue(
         snapcraft.repo.snaps.SnapPackage.is_snap_installed(self.snap))
 def test_source_on_other_arch(self):
     snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
     snapcraft_yaml.update_part('my-part', {
         'plugin': 'nil',
         'source': [
             {
                 'on other-arch': 'invalid'
             },
         ]
     })
     self.useFixture(snapcraft_yaml)
     self.run_snapcraft(['pull'])
Exemple #6
0
 def test_build_snap(self):
     if os.environ.get('ADT_TEST') and self.deb_arch == 'armhf':
         self.skipTest("The autopkgtest armhf runners can't install snaps")
     self.useFixture(fixture_setup.WithoutSnapInstalled(self.snap))
     snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
     snapcraft_yaml.update_part('test-part-with-build-snap', {
         'plugin': 'nil',
         'build-snaps': [self.snap]
     })
     self.useFixture(snapcraft_yaml)
     self.run_snapcraft('build')
     self.assertTrue(
         snapcraft.repo.snaps.SnapPackage.is_snap_installed(self.snap))
 def test_source_try(self):
     snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
     snapcraft_yaml.update_part(
         'my-part', {
             'plugin': 'nil',
             'source': [
                 {
                     'try': self.test_source
                 },
                 {
                     'else': 'invalid'
                 },
             ]
         })
     self.useFixture(snapcraft_yaml)
     self.run_snapcraft(['pull'])
 def test_source_on_other_arch_else_fail(self):
     snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
     snapcraft_yaml.update_part(
         'my-part', {
             'plugin': 'nil',
             'source': [
                 {
                     'on other-arch': 'invalid'
                 },
                 'else fail',
             ]
         })
     self.useFixture(snapcraft_yaml)
     self.assertThat(
         self.assertRaises(subprocess.CalledProcessError,
                           self.run_snapcraft, ['pull']).output,
         Contains("Unable to satisfy 'on other-arch', failure forced"))
 def test_source_on_current_arch(self):
     snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
     snapcraft_yaml.update_part(
         'my-part', {
             'plugin':
             'nil',
             'source': [
                 {
                     'on {}'.format(self.deb_arch): self.test_source
                 },
                 {
                     'else': 'invalid'
                 },
             ]
         })
     self.useFixture(snapcraft_yaml)
     self.run_snapcraft(['pull'])
    def test_specified_metadata_not_overwritten(self):
        snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path,
                                                     description=None)
        snapcraft_yaml.data['adopt-info'] = 'test-part'
        snapcraft_yaml.update_part('test-part', {
            'plugin': 'dump',
            'parse-info': ['test.metainfo.xml']
        })
        self.useFixture(snapcraft_yaml)

        self.run_snapcraft('prime')
        with open(os.path.join('prime', 'meta',
                               'snap.yaml')) as snap_yaml_file:
            snap_yaml = yaml.load(snap_yaml_file)
        self.assertThat(snap_yaml['description'],
                        Equals('test-appstream-description'))
        self.assertThat(snap_yaml['summary'], Equals('test-summary'))
    def test_inexistent_build_snap(self):
        if os.environ.get('ADT_TEST') and self.deb_arch == 'armhf':
            self.skipTest("The autopkgtest armhf runners can't install snaps")
        snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
        snapcraft_yaml.update_part('test-part-with-build-snap', {
            'plugin': 'nil',
            'build-snaps': ['inexistent']
        })
        self.useFixture(snapcraft_yaml)

        exception = self.assertRaises(subprocess.CalledProcessError,
                                      self.run_snapcraft, ['build'])

        self.assertThat(exception.returncode, Equals(2))
        self.assertThat(exception.output, Contains("'inexistent'"))
        self.assertFalse(
            snapcraft.repo.snaps.SnapPackage.is_snap_installed('inexistent'))
    def test_icon_extracted_from_appstream(self):
        os.mkdir('assets')
        shutil.copyfile(
            os.path.join(os.path.dirname(tests.__file__), 'data', 'icon.png'),
            os.path.join(self.path, 'assets', 'test-icon.png'))

        snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path,
                                                     summary=None,
                                                     description=None)
        snapcraft_yaml.data['adopt-info'] = 'test-part'
        snapcraft_yaml.update_part('test-part', {
            'plugin': 'dump',
            'parse-info': ['test.metainfo.xml']
        })
        self.useFixture(snapcraft_yaml)

        self.run_snapcraft('prime')

        self.assertThat(os.path.join('prime', 'meta', 'gui', 'icon.png'),
                        FileExists())
    def test_prime_records_build_snaps(self):
        self.useFixture(fixture_setup.WithoutSnapInstalled('hello'))
        snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
        snapcraft_yaml.update_part('test-part', {
            'plugin': 'nil',
            'build-snaps': ['hello']
        })
        self.useFixture(snapcraft_yaml)

        self.run_snapcraft('prime')

        expected_revision = snaps.SnapPackage(
            'hello').get_local_snap_info()['revision']
        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-snaps'],
                        Equals(['hello={}'.format(expected_revision)]))
Exemple #14
0
    def test_prime_records_build_snaps(self):
        if os.environ.get('ADT_TEST') and self.deb_arch == 'armhf':
            self.skipTest("The autopkgtest armhf runners can't install snaps")

        self.useFixture(fixture_setup.WithoutSnapInstalled('hello'))
        snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
        snapcraft_yaml.update_part('test-part', {
            'plugin': 'nil',
            'build-snaps': ['hello']
        })
        self.useFixture(snapcraft_yaml)

        self.run_snapcraft('prime')

        expected_revision = snaps.SnapPackage(
            'hello').get_local_snap_info()['revision']
        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-snaps'],
                        Equals(['hello={}'.format(expected_revision)]))