def test_plugin_schema_step_hint_build(self): class Plugin(snapcraft.BasePlugin): @classmethod def schema(cls): schema = super().schema() schema["properties"]["foo"] = {"type": "string"} schema["build-properties"] = ["foo"] return schema self.useFixture(fixture_setup.FakePlugin("plugin", Plugin)) self.load_part("fake-part", "plugin")
def test_plugin_schema_step_hint_build(self): class Plugin(snapcraft.BasePlugin): @classmethod def schema(cls): schema = super().schema() schema['properties']['foo'] = { 'type': 'string', } schema['build-properties'] = ['foo'] return schema self.useFixture(fixture_setup.FakePlugin('plugin', Plugin)) self.load_part('fake-part', 'plugin')
def test_plugin_without_project(self): class OldPlugin(snapcraft.BasePlugin): @classmethod def schema(cls): schema = super().schema() schema["properties"]["fake-property"] = {"type": "string"} return schema def __init__(self, name, options): super().__init__(name, options) self.useFixture(fixture_setup.FakePlugin("oldplugin", OldPlugin)) handler = self.load_part("fake-part", "oldplugin", {"fake-property": "."}) self.assertTrue(handler.plugin.project is not None)
def test_plugin_schema_invalid_build_hint(self): class Plugin(snapcraft.BasePlugin): @classmethod def schema(cls): schema = super().schema() schema["properties"]["foo"] = {"type": "string"} schema["build-properties"] = ["bar"] return schema self.useFixture(fixture_setup.FakePlugin("plugin", Plugin)) raised = self.assertRaises(errors.InvalidBuildPropertiesError, self.load_part, "fake-part", "plugin") self.assertThat(raised.plugin_name, Equals("plugin")) self.assertThat(raised.properties, Equals(["bar"]))
def test_plugin_without_project(self): class OldPlugin(snapcraft.BasePlugin): @classmethod def schema(cls): schema = super().schema() schema['properties']['fake-property'] = { 'type': 'string', } return schema def __init__(self, name, options): super().__init__(name, options) self.useFixture(fixture_setup.FakePlugin('oldplugin', OldPlugin)) handler = self.load_part('fake-part', 'oldplugin', {'fake-property': '.'}) self.assertTrue(handler.plugin.project is not None)
def test_plugin_schema_invalid_build_hint(self): class Plugin(snapcraft.BasePlugin): @classmethod def schema(cls): schema = super().schema() schema['properties']['foo'] = { 'type': 'string', } schema['build-properties'] = ['bar'] return schema self.useFixture(fixture_setup.FakePlugin('plugin', Plugin)) raised = self.assertRaises(errors.InvalidBuildPropertiesError, self.load_part, 'fake-part', 'plugin') self.assertThat(raised.plugin_name, Equals('plugin')) self.assertThat(raised.properties, Equals(['bar']))