示例#1
0
    def test_pull_with_existing_source_tree_creates_hardlinks(self):
        os.makedirs(os.path.join('src', 'dir'))
        open(os.path.join('src', 'dir', 'file'), 'w').close()

        os.mkdir('destination')
        open(os.path.join('destination', 'existing-file'), 'w').close()

        local = sources.Local('src', 'destination')
        local.pull()

        # Verify that the directories are not symlinks, but the file is a
        # hardlink. Also verify that existing-file still exists.
        self.assertFalse(os.path.islink('destination'))
        self.assertFalse(os.path.islink(os.path.join('destination', 'dir')))
        self.assertThat(os.path.join('destination', 'existing-file'),
                        FileExists())
        self.assertGreater(
            os.stat(os.path.join('destination', 'dir', 'file')).st_nlink, 1)
    def assert_expected_build_state(self, project_dir):
        self.run_snapcraft('build', project_dir)

        state_file = os.path.join(self.parts_dir, 'x-local-plugin', 'state',
                                  'build')
        self.assertThat(state_file, FileExists())
        with open(state_file) as f:
            state = yaml.load(f)

        # Verify that the correct schema dependencies made it into the state.
        self.assertTrue('foo' in state.schema_properties)
        self.assertTrue('stage-packages' in state.schema_properties)

        # Verify that the contents of the dependencies made it in as well.
        self.assertTrue('foo' in state.properties)
        self.assertTrue('stage-packages' in state.properties)
        self.assertThat(state.properties['foo'], Equals('bar'))
        self.assertThat(state.properties['stage-packages'], Equals(['curl']))
    def test_to_other_arch_else(self):
        """Test that 'else' for the other arch fetches hello."""

        self.construct_yaml(
            parts=dedent(
                """\
            simple:
              plugin: nil
              stage-packages:
              - to other-arch:
                - foo
              - else:
                - hello
            """
            )
        )
        self.run_snapcraft(["prime", "simple"])
        self.assertThat(os.path.join("prime", "usr", "bin", "hello"), FileExists())
示例#4
0
    def test_pull_keeps_symlinks(self):
        # Create a source containing a directory, a file and symlinks to both.
        os.makedirs(os.path.join('src', 'dir'))
        open(os.path.join('src', 'dir', 'file'), 'w').close()
        os.symlink('dir', os.path.join('src', 'dir_symlink'))
        os.symlink('file', os.path.join('src', 'dir', 'file_symlink'))

        local = sources.Local('src', 'destination')
        local.pull()

        # Verify that both the file and the directory symlinks were kept.
        self.expectThat(os.path.join('destination', 'dir'), DirExists())
        self.expectThat(os.path.join('destination', 'dir_symlink'),
                        unit.LinkExists('dir'))
        self.expectThat(os.path.join('destination', 'dir', 'file'),
                        FileExists())
        self.expectThat(os.path.join('destination', 'dir', 'file_symlink'),
                        unit.LinkExists('file'))
示例#5
0
    def test_pull_global_build_packages_are_excluded(self):
        """
        Ensure global build-packages are not included in each part's
        build-packages data.
        """
        self.copy_project_to_cwd('build-package-global')
        self.set_build_package_version(
            os.path.join('snap', 'snapcraft.yaml'),
            part=None, package='haskell-doc')
        self.run_snapcraft('pull')

        state_file = os.path.join(
            self.parts_dir, 'empty-part', 'state', 'pull')
        self.assertThat(state_file, FileExists())
        with open(state_file) as f:
            state = yaml.load(f)

        self.assertTrue(len(state.assets['build-packages']) == 0)
    def assert_expected_build_state(self, project_dir):
        self.run_snapcraft("build", project_dir)

        state_file = os.path.join(self.parts_dir, "x-local-plugin", "state",
                                  "build")
        self.assertThat(state_file, FileExists())
        with open(state_file) as f:
            state = yaml_utils.load(f)

        # Verify that the correct schema dependencies made it into the state.
        self.assertTrue("foo" in state.schema_properties)
        self.assertTrue("stage-packages" in state.schema_properties)

        # Verify that the contents of the dependencies made it in as well.
        self.assertTrue("foo" in state.properties)
        self.assertTrue("stage-packages" in state.properties)
        self.assertThat(state.properties["foo"], Equals("bar"))
        self.assertThat(state.properties["stage-packages"], Equals(["curl"]))
示例#7
0
    def test_push_revision_cached_with_experimental_deltas(self):
        # Upload
        with mock.patch("snapcraft.storeapi._status_tracker.StatusTracker"):
            result = self.run_command(["push", self.snap_file])
        self.assertThat(result.exit_code, Equals(0))

        snap_cache = os.path.join(
            BaseDirectory.xdg_cache_home,
            "snapcraft",
            "projects",
            "basic",
            "snap_hashes",
            "amd64",
        )
        cached_snap = os.path.join(
            snap_cache, file_utils.calculate_sha3_384(self.snap_file))

        self.assertThat(cached_snap, FileExists())
示例#8
0
    def test_pull_global_build_packages_are_excluded(self):
        """
        Ensure global build-packages are not included in each part's
        build-packages data.
        """
        self.copy_project_to_cwd("build-package-global")
        self.set_build_package_version(os.path.join("snap", "snapcraft.yaml"),
                                       part=None,
                                       package="haskell-doc")
        self.run_snapcraft("pull")

        state_file = os.path.join(self.parts_dir, "empty-part", "state",
                                  "pull")
        self.assertThat(state_file, FileExists())
        with open(state_file) as f:
            state = yaml.load(f)

        self.assertTrue(len(state.assets["build-packages"]) == 0)
示例#9
0
    def test_primed_libc6(self):
        snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path, base=None)
        snapcraft_yaml.update_part("test-part", {
            "plugin": "nil",
            "stage-packages": ["libc6", "hello"]
        })
        self.useFixture(snapcraft_yaml)

        self.run_snapcraft("prime")

        bin_path = os.path.join(self.prime_dir, "usr", "bin", "hello")
        self.assertThat(bin_path, FileExists())

        # Verify that the correct interpreter that has been staged is used.
        interpreter = subprocess.check_output(
            [self.patchelf_command, "--print-interpreter", bin_path]).decode()
        expected_interpreter = r"^/snap/test-snap/current/lib/.*"
        self.assertThat(interpreter, MatchesRegex(expected_interpreter))
示例#10
0
    def test_close_channel(self):
        self.addCleanup(self.logout)
        self.login()

        # Build a random snap, register, push and release it.
        name = self.get_unique_name()
        version = self.get_unique_version()
        self.copy_project_to_cwd("basic")
        self.update_name_and_version(name, version)
        self.run_snapcraft("snap")
        snap_path = "{}_{}_{}.snap".format(name, version, "all")
        self.assertThat(snap_path, FileExists())
        self.register(name)
        self.assertThat(self.push(snap_path, release="edge,beta"), Equals(0))

        expected = "The beta channel is now closed."
        status = self.close(name, "beta", expected=expected)
        self.assertThat(status, Equals(0))
示例#11
0
    def test_pull_with_existing_source_tree_creates_hardlinks(self):
        os.makedirs(os.path.join("src", "dir"))
        open(os.path.join("src", "dir", "file"), "w").close()

        os.mkdir("destination")
        open(os.path.join("destination", "existing-file"), "w").close()

        local = sources.Local("src", "destination")
        local.pull()

        # Verify that the directories are not symlinks, but the file is a
        # hardlink. Also verify that existing-file still exists.
        self.assertFalse(os.path.islink("destination"))
        self.assertFalse(os.path.islink(os.path.join("destination", "dir")))
        self.assertThat(os.path.join("destination", "existing-file"),
                        FileExists())
        self.assertGreater(
            os.stat(os.path.join("destination", "dir", "file")).st_nlink, 1)
示例#12
0
    def test_pull_keeps_symlinks(self):
        # Create a source containing a directory, a file and symlinks to both.
        os.makedirs(os.path.join("src", "dir"))
        open(os.path.join("src", "dir", "file"), "w").close()
        os.symlink("dir", os.path.join("src", "dir_symlink"))
        os.symlink("file", os.path.join("src", "dir", "file_symlink"))

        local = sources.Local("src", "destination")
        local.pull()

        # Verify that both the file and the directory symlinks were kept.
        self.expectThat(os.path.join("destination", "dir"), DirExists())
        self.expectThat(os.path.join("destination", "dir_symlink"),
                        unit.LinkExists("dir"))
        self.expectThat(os.path.join("destination", "dir", "file"),
                        FileExists())
        self.expectThat(os.path.join("destination", "dir", "file_symlink"),
                        unit.LinkExists("file"))
示例#13
0
    def test_close_channel(self):
        self.addCleanup(self.logout)
        self.login()

        # Build a random snap, register, push and release it.
        name = self.get_unique_name()
        version = self.get_unique_version()
        self.copy_project_to_cwd('basic')
        self.update_name_and_version(name, version)
        self.run_snapcraft('snap')
        snap_path = '{}_{}_{}.snap'.format(name, version, 'all')
        self.assertThat(snap_path, FileExists())
        self.register(name)
        self.assertThat(self.push(snap_path, release='edge,beta'), Equals(0))

        expected = 'The beta channel is now closed.'
        status = self.close(name, 'beta', expected=expected)
        self.assertThat(status, Equals(0))
示例#14
0
    def test_sign_build_missing_grade(
        self,
        mock_get_snap_data,
        mock_get_account_info,
    ):
        mock_get_account_info.return_value = {
            "account_id": "abcd",
            "account_keys": [{
                "public-key-sha3-384": "a_hash"
            }],
            "snaps": {
                "16": {
                    "test-snap": {
                        "snap-id": "snap-id"
                    }
                }
            },
        }
        mock_get_snap_data.return_value = {"name": "test-snap"}
        fake_check_output = fixtures.MockPatch("subprocess.check_output",
                                               side_effect=mock_check_output)
        self.useFixture(fake_check_output)

        result = self.run_command(
            ["sign-build", self.snap_test.snap_path, "--local"], input="1\n")

        self.assertThat(result.exit_code, Equals(0))
        snap_build_path = self.snap_test.snap_path + "-build"
        self.assertThat(
            result.output,
            Contains(
                "Build assertion {} saved to disk.".format(snap_build_path)),
        )
        self.assertThat(snap_build_path, FileExists())
        fake_check_output.mock.assert_called_with([
            mock.ANY,
            "sign-build",
            "--developer-id=abcd",
            "--snap-id=snap-id",
            "--grade=stable",
            "-k",
            "default",
            self.snap_test.snap_path,
        ])
示例#15
0
    def test_snap_defaults_with_parts_in_prime(self):
        fake_logger = fixtures.FakeLogger(level=logging.INFO)
        self.useFixture(fake_logger)
        self.make_snapcraft_yaml()

        # Pretend this part has already been primed
        os.makedirs(self.state_dir)
        open(os.path.join(self.state_dir, "prime"), "w").close()

        result = self.run_command(["snap"])

        self.assertThat(result.exit_code, Equals(0))
        self.assertThat(result.output,
                        Contains("Snapped snap-test_1.0_amd64.snap\n"))

        self.assertThat(
            fake_logger.output,
            Contains(
                "Skipping pull part1 (already ran)\n"
                "Skipping build part1 (already ran)\n"
                "Skipping stage part1 (already ran)\n"
                "Skipping prime part1 (already ran)\n"
                "The requested action has already been taken. Consider\n"
                "specifying parts, or clean the steps you want to run again.\n"
            ),
        )

        self.popen_spy.assert_called_once_with(
            [
                "mksquashfs",
                self.prime_dir,
                "snap-test_1.0_amd64.snap",
                "-noappend",
                "-comp",
                "xz",
                "-no-xattrs",
                "-no-fragments",
                "-all-root",
            ],
            stderr=subprocess.STDOUT,
            stdout=subprocess.PIPE,
        )

        self.assertThat("snap-test_1.0_amd64.snap", FileExists())
示例#16
0
    def test_get_package_trusted_parts_already_imported(self, mock_apt_pkg):
        self.mock_cache().is_virtual_package.return_value = False

        def _fake_find_file(key: str):
            if key == "Dir::Etc::TrustedParts":
                return os.path.join(ubuntu._cache.base_dir, "trusted")
            else:
                return DEFAULT

        mock_apt_pkg.config.find_file.side_effect = _fake_find_file

        ubuntu = repo.Ubuntu(self.tempdir)
        ubuntu.get(["fake-package"])

        mock_apt_pkg.assert_has_calls(
            [
                call.config.set("Apt::Install-Recommends", "False"),
                call.config.set("Acquire::AllowInsecureRepositories", "False"),
                call.config.find_file("Dir::Etc::Trusted"),
                call.config.set("Dir::Etc::Trusted", ANY),
                call.config.find_file("Dir::Etc::TrustedParts"),
                call.config.clear("APT::Update::Post-Invoke-Success"),
            ]
        )

        self.mock_cache.assert_has_calls(
            [
                call(memonly=True, rootdir=ANY),
                call().update(fetch_progress=ANY, sources_list=ANY),
                call().open(),
            ]
        )

        # __getitem__ is tricky
        self.assertThat(
            self.mock_cache.return_value.__getitem__.call_args_list,
            Contains(call("fake-package")),
        )

        # Verify that the package was actually fetched and copied into the
        # requested location.
        self.assertThat(
            os.path.join(self.tempdir, "download", "fake-package.deb"), FileExists()
        )
示例#17
0
    def test_sign_build_snapd_failure(
        self,
        mock_get_snap_data,
        mock_get_account_info,
    ):
        mock_get_account_info.return_value = {
            "account_id": "abcd",
            "account_keys": [{
                "public-key-sha3-384": "a_hash"
            }],
            "snaps": {
                "16": {
                    "test-snap": {
                        "snap-id": "snap-id"
                    }
                }
            },
        }
        mock_get_snap_data.return_value = {
            "name": "test-snap",
            "grade": "stable"
        }
        self.useFixture(
            fixtures.MockPatch(
                "subprocess.check_output",
                side_effect=[
                    '[{"name": "default", "sha3-384": "a_hash"}]'.encode(),
                    subprocess.CalledProcessError(1, ["a", "b"]),
                ],
            ))

        raised = self.assertRaises(
            storeapi.errors.SignBuildAssertionError,
            self.run_command,
            ["sign-build", self.snap_test.snap_path],
        )

        self.assertThat(
            str(raised),
            Contains("Failed to sign build assertion for {!r}".format(
                self.snap_test.snap_path)),
        )
        snap_build_path = self.snap_test.snap_path + "-build"
        self.assertThat(snap_build_path, Not(FileExists()))
示例#18
0
    def test_pull_sdk(self):
        with tarfile.open('test-sdk.tar', 'w') as test_sdk_tar:
            open('test-sdk', 'w').close()
            test_sdk_tar.add('test-sdk')
        with mock.patch.dict(
                    dotnet._SDKS_AMD64['2.0.0'],
                    {'checksum': 'sha256/{}'.format(
                        file_utils.calculate_hash(
                            'test-sdk.tar', algorithm='sha256'))}):
            plugin = dotnet.DotNetPlugin(
                'test-part', self.options, self.project)

        with mock.patch.object(
                sources.Tar, 'download', return_value='test-sdk.tar'):
            plugin.pull()

        self.assertThat(
            os.path.join('parts', 'test-part', 'dotnet', 'sdk', 'test-sdk'),
            FileExists())
示例#19
0
    def test_download_from_host_dangerous(self):
        fake_get_assertion = fixtures.MockPatch(
            "snapcraft.internal.repo.snaps.get_assertion",
            return_value=b"foo-assert")
        self.useFixture(fake_get_assertion)
        self.fake_snapd.snaps_result = [{
            "id": "fake-snap-id",
            "name": "fake-snap",
            "channel": "stable",
            "revision": "x1",
        }]

        snap_pkg = snaps.SnapPackage("fake-snap/strict/stable")
        snap_pkg.local_download(snap_path="fake-snap.snap",
                                assertion_path="fake-snap.assert")

        self.assertThat("fake-snap.snap", FileExists())
        self.assertThat("fake-snap.assert", FileContains(""))
        fake_get_assertion.mock.assert_not_called()
示例#20
0
    def test_opencv(self):
        snap_path = self.build_snap(self.snap_content_dir)

        bin_path = os.path.join(os.path.dirname(snap_path), 'prime', 'bin',
                                'example')
        self.assertThat(bin_path, FileExists())

        interpreter = subprocess.check_output(
            ['patchelf', '--print-interpreter', bin_path]).decode()
        expected_interpreter = r'^/snap/core/current/.*'
        self.assertThat(interpreter, MatchesRegex(expected_interpreter))

        arch_triplet = snapcraft.ProjectOptions().arch_triplet

        # test $ORIGIN in action
        rpath = subprocess.check_output(
            ['patchelf', '--print-rpath', bin_path]).decode()
        expected_rpath = '$ORIGIN/../usr/lib/{}:'.format(arch_triplet)
        self.assertThat(rpath, Contains(expected_rpath))

        # test $ORIGIN applied
        ldd = subprocess.check_output(['ldd', bin_path]).decode()
        expected_opencv_path = (
            '/prime/bin/../usr/lib/{}/libopencv_core'.format(arch_triplet))
        self.assertThat(ldd, Contains(expected_opencv_path))

        self.install_snap(snap_path, 'opencv-example', '1.0', classic=True)
        if not snaps_tests.config.get('skip-install', False):
            output = self.run_command_in_snappy_testbed(
                '/snap/bin/opencv-example.example').splitlines()

            # Depending on opencv the result is now displayed differently
            # so let's do a lazy match.
            # On artful you see:
            # [  1,   3;
            #    2,   4]
            # And on others:
            # [1, 3;
            #  2, 4]
            expected_in_first_line = ['[', '1', ',', '3', ';']
            self.assertThat(output[0], ContainsAll(expected_in_first_line))
            expected_in_second_line = ['2', ',', '4', ']']
            self.assertThat(output[1], ContainsAll(expected_in_second_line))
    def test_pull(self):
        project_dir = 'local-plugin-build-properties'
        self.run_snapcraft('build', project_dir)

        state_file = os.path.join(
            project_dir, 'parts', 'x-local-plugin', 'state', 'build')
        self.assertThat(state_file, FileExists())
        with open(state_file) as f:
            state = yaml.load(f)

        # Verify that the correct schema dependencies made it into the state.
        self.assertTrue('foo' in state.schema_properties)
        self.assertTrue('stage-packages' in state.schema_properties)

        # Verify that the contents of the dependencies made it in as well.
        self.assertTrue('foo' in state.properties)
        self.assertTrue('stage-packages' in state.properties)
        self.assertEqual('bar', state.properties['foo'])
        self.assertEqual(['curl'], state.properties['stage-packages'])
示例#22
0
    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")
        self.assertThat(state_file, FileExists())
        self.assertThat(
            state_file,
            FileContains(matcher=Contains(
                dedent("""\
                  - {}={}
                """.format(
                    virtual_package,
                    integration.get_package_version(
                        virtual_package, self.distro_series, self.deb_arch),
                )))),
        )
    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())
示例#24
0
    def test_snap_defaults_on_a_tty(self, progress_mock):
        fake_logger = fixtures.FakeLogger(level=logging.INFO)
        self.useFixture(fake_logger)
        self.useFixture(fixture_setup.FakeTerminal())

        self.make_snapcraft_yaml()

        result = self.run_command(['snap'])

        self.assertThat(result.exit_code, Equals(0))
        self.assertThat(result.output,
                        Contains('\nSnapped snap-test_1.0_amd64.snap\n'))

        self.popen_spy.assert_called_once_with([
            'mksquashfs', self.prime_dir, 'snap-test_1.0_amd64.snap',
            '-noappend', '-comp', 'xz', '-no-xattrs', '-all-root'],
            stderr=subprocess.STDOUT, stdout=subprocess.PIPE)

        self.assertThat('snap-test_1.0_amd64.snap', FileExists())
示例#25
0
    def test_close_channel(self):
        self.addCleanup(self.logout)
        self.login()

        # Build a random snap, register, push and release it.
        unique_id = uuid.uuid4().int
        name = 'u1test-{}'.format(unique_id)
        version = str(unique_id)[:32]
        self.copy_project_to_cwd('basic')
        self.update_name_and_version(name, version)
        self.run_snapcraft('snap')
        snap_path = '{}_{}_{}.snap'.format(name, version, 'all')
        self.assertThat(snap_path, FileExists())
        self.register(name)
        self.assertEqual(0, self.push(snap_path, release='edge,beta'))

        expected = 'The beta channel is now closed.'
        status = self.close(name, 'beta', expected=expected)
        self.assertEqual(0, status)
示例#26
0
    def testBlacklistingPPAs(self):
        """Test that the htaccess for blacklisted PPAs are not touched."""
        subs, tokens = self.setupDummyTokens()
        htaccess, htpasswd = self.ensureNoFiles()

        # Setup the first subscription so that it is due to be expired.
        now = datetime.now(pytz.UTC)
        subs[0].date_expires = now - timedelta(minutes=3)
        self.assertEqual(subs[0].status, ArchiveSubscriberStatus.CURRENT)

        script = self.getScript()
        script.blacklist = {'joe': ['my_other_ppa', 'myppa', 'and_another']}
        script.main()

        # The tokens will still be deactivated, and subscriptions expired.
        self.assertDeactivated(tokens[0])
        self.assertEqual(subs[0].status, ArchiveSubscriberStatus.EXPIRED)
        # But the htaccess is not touched.
        self.assertThat([htaccess, htpasswd], AllMatch(Not(FileExists())))
示例#27
0
    def testSkippingOfDisabledPPAs(self):
        """Test that the htaccess for disabled PPAs are not touched."""
        subs, tokens = self.setupDummyTokens()
        htaccess, htpasswd = self.ensureNoFiles()

        # Setup subscription so that htaccess/htpasswd is pending generation.
        now = datetime.now(pytz.UTC)
        subs[0].date_expires = now + timedelta(minutes=3)
        self.assertEqual(subs[0].status, ArchiveSubscriberStatus.CURRENT)

        # Set the PPA as disabled.
        self.ppa.disable()
        self.assertFalse(self.ppa.enabled)

        script = self.getScript()
        script.main()

        # The htaccess and htpasswd files should not be generated.
        self.assertThat([htaccess, htpasswd], AllMatch(Not(FileExists())))
示例#28
0
    def test_glibc_mangling(self):
        elf_files = [
            self.fake_elf['fake_elf-2.26'],
            self.fake_elf['fake_elf-2.23'],
            self.fake_elf['fake_elf-1.1'],
        ]

        mangling.handle_glibc_mismatch(
            elf_files=elf_files,
            root_path=self.path,
            core_base_path='/snap/core/current',
            snap_base_path='/snap/snap-name/current')

        self.get_packages_mock.assert_called_once_with('libc6')
        self.assertThat(os.path.join(self.path, 'snap', 'libc6', 'ld-2.26.so'),
                        FileExists())
        # Only fake_elf1 requires a newer libc6
        self.patch_mock.assert_called_once_with(
            elf_file=self.fake_elf['fake_elf-2.26'])
示例#29
0
    def test_sign_build_locally_successfully(self, mock_installed,
                                             mock_get_snap_data,
                                             mock_check_output,
                                             mock_get_account_info):
        mock_installed.return_value = True
        mock_get_account_info.return_value = {
            'account_id': 'abcd',
            'snaps': {
                '16': {
                    'test-snap': {
                        'snap-id': 'snap-id'
                    },
                }
            }
        }
        mock_get_snap_data.return_value = {
            'name': 'test-snap',
            'grade': 'stable',
        }
        mock_check_output.side_effect = [
            '[{"name": "default"}]', b'Mocked assertion'
        ]

        result = self.run_command(
            ['sign-build', self.snap_test.snap_path, '--local'])

        self.assertThat(result.exit_code, Equals(0))
        snap_build_path = self.snap_test.snap_path + '-build'
        self.assertThat(
            result.output,
            Contains(
                'Build assertion {} saved to disk.'.format(snap_build_path)))
        self.assertThat(snap_build_path, FileExists())
        mock_check_output.assert_called_with([
            'snap',
            'sign-build',
            '--developer-id=abcd',
            '--snap-id=snap-id',
            '--grade=stable',
            '-k',
            'default',
            self.snap_test.snap_path,
        ])
示例#30
0
    def test_pull_svn_checkout(self):
        self.copy_project_to_cwd('svn-pull')

        self.init_source_control()
        self.checkout(
             'file:///{}'.format(os.path.join(self.path, 'repo')),
             'local')
        open(os.path.join('local', 'file'), 'w').close()
        self.add('file', cwd='local/')
        self.commit('test', cwd='local/')
        self.update(cwd='local/')
        subprocess.check_call(
            ['rm', '-rf', 'local/'], stdout=subprocess.DEVNULL)

        self.run_snapcraft('pull')
        part_src_path = os.path.join(self.parts_dir, 'svn', 'src')
        revno = subprocess.check_output(['svnversion', part_src_path]).strip()
        self.assertThat(revno, Equals(b'1'))
        self.assertThat(os.path.join(part_src_path, 'file'), FileExists())
示例#31
0
 def test_not_exists(self):
     doesntexist = os.path.join(self.mkdtemp(), 'doesntexist')
     mismatch = FileExists().match(doesntexist)
     self.assertThat(
         PathExists().match(doesntexist).describe(),
         Equals(mismatch.describe()))
示例#32
0
 def test_not_a_file(self):
     tempdir = self.mkdtemp()
     mismatch = FileExists().match(tempdir)
     self.assertThat(
         "%s is not a file." % tempdir, Equals(mismatch.describe()))