Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
super().setUp()
patcher = mock.patch("snapcraft.project.Project")
patcher.start()
self.addCleanup(patcher.stop)
# Special handling is required as ProjectOptions attributes are
# handled with the @property decorator.
project_options_t = type(snapcraft.project.Project.return_value)
for key in self._kwargs:
setattr(project_options_t, key, self._kwargs[key])
base: core18
version: "1.0"
summary: test
description: test
confinement: strict
grade: stable
{type}
{parts}
"""
)
self.snapcraft_yaml_file_path = self.make_snapcraft_yaml(
yaml.format(parts=parts, type=snap_type)
)
project = snapcraft.project.Project(
snapcraft_yaml_file_path=self.snapcraft_yaml_file_path
)
return project_loader.load_config(project)
def _make_snapcraft_project(self):
yaml = textwrap.dedent(
"""\
name: test
base: core18
version: "1.0"
summary: test
description: test
confinement: strict
grade: stable
"""
)
snapcraft_yaml_file_path = self.make_snapcraft_yaml(yaml)
project = snapcraft.project.Project(
snapcraft_yaml_file_path=snapcraft_yaml_file_path
)
return project
def setUp(self):
super().setUp()
class Options:
makefile = None
make_parameters = []
make_install_var = "DESTDIR"
disable_parallel = False
artifacts = []
self.options = Options()
self.project = snapcraft.project.Project(
snapcraft_yaml_file_path=self.make_snapcraft_yaml(
textwrap.dedent(
"""\
name: make-snap
def setUp(self):
super().setUp()
self.useFixture(fixtures.EnvironmentVariable(*self.env_var))
snapcraft_yaml_path = self.make_snapcraft_yaml(
dedent(
"""\
name: gradle-snap
base: core18
"""
)
)
self.project = Project(snapcraft_yaml_file_path=snapcraft_yaml_path)
class Options:
gradle_options = []
gradle_output_dir = "build/libs"
gradle_version = gradle._DEFAULT_GRADLE_VERSION
gradle_version_checksum = gradle._DEFAULT_GRADLE_CHECKSUM
gradle_openjdk_version = "11"
self.options = Options()
def setUp(self):
super().setUp()
class Options(snapcraft.ProjectOptions):
source = "."
ruby_version = "2.4.2"
gems = []
use_bundler = False
self.options = Options()
self.project = snapcraft.project.Project(
snapcraft_yaml_file_path=self.make_snapcraft_yaml(
textwrap.dedent(
"""\
name: ruby-snap
def setUp(self):
super().setUp()
snapcraft_yaml_path = self.make_snapcraft_yaml(
dedent(
"""\
name: maven-snap
base: {base}
""".format(
base=self.base
)
)
)
self.project = Project(snapcraft_yaml_file_path=snapcraft_yaml_path)
class Options:
maven_options = []
maven_targets = [""]
maven_version = maven._DEFAULT_MAVEN_VERSION
maven_version_checksum = maven._DEFAULT_MAVEN_CHECKSUM
maven_openjdk_version = self.version
self.options = Options()
def make_snapcraft_project(self, parts):
snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path)
snapcraft_yaml.update_part("part1", dict(plugin="nil"))
for part_name, part in parts:
snapcraft_yaml.update_part(part_name, part)
self.useFixture(snapcraft_yaml)
project = Project(
snapcraft_yaml_file_path=snapcraft_yaml.snapcraft_yaml_file_path
)
return project_loader.load_config(project)
def get_project(base: str = "core16") -> Project:
with open("snapcraft.yaml", "w") as snapcraft_file:
print("name: project-name", file=snapcraft_file)
print("base: {}".format(base), file=snapcraft_file)
return Project(snapcraft_yaml_file_path="snapcraft.yaml")
def test_kernel_image_target_as_map(self):
self.options.kernel_image_target = {"arm64": "Image"}
project = snapcraft.project.Project(
target_deb_arch="arm64",
snapcraft_yaml_file_path=self.make_snapcraft_yaml(
textwrap.dedent(
"""\
name: test-snap
base: core16
"""
)
),
)
plugin = kernel.KernelPlugin("test-part", self.options, project)
self.assertThat(plugin.make_targets, Equals(["Image", "modules", "dtbs"]))