def test_pull(self, check_call_mock): """Test pulling with the default settings.""" plugin = meson.MesonPlugin("test-part", self.options, self.project) plugin.pull() check_call_mock.assert_called_once_with( ["python3", "-m", "pip", "install", "-U", "meson"])
def test_build(self, run_mock): """Test building via meson and check for known calls and destdir""" plugin = meson.MesonPlugin("test-part", self.options, self.project) plugin.build() env = os.environ.copy() env["DESTDIR"] = plugin.installdir self.assertThat(run_mock.call_count, Equals(3)) run_mock.assert_has_calls([ mock.call(["meson", plugin.snapbuildname]), mock.call(["ninja"], cwd=plugin.mesonbuilddir), mock.call(["ninja", "install"], env=env, cwd=plugin.mesonbuilddir), ])
def test_build_with_parameters(self, run_mock): """Test with parameters""" self.options.meson_parameters = ["--strip"] plugin = meson.MesonPlugin("test-part", self.options, self.project) plugin.build() env = os.environ.copy() env["DESTDIR"] = plugin.installdir self.assertThat(run_mock.call_count, Equals(3)) run_mock.assert_has_calls([ mock.call(["meson", "--strip", plugin.snapbuildname]), mock.call(["ninja"], cwd=plugin.mesonbuilddir), mock.call(["ninja", "install"], env=env, cwd=plugin.mesonbuilddir), ])
def test_pull_meson_installation_fails(self, check_call_mock): """Test pulling with the default settings.""" self.options.meson_version = "1.0" plugin = meson.MesonPlugin("test-part", self.options, self.project) self.assertRaises(errors.SnapcraftPluginCommandError, plugin.pull)