Esempio n. 1
0
    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')
Esempio n. 2
0
    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']))
Esempio n. 3
0
    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)
Esempio n. 4
0
    def test_plugin_schema_invalid_pull_hint(self):
        class Plugin(snapcraft.BasePlugin):
            @classmethod
            def schema(cls):
                schema = super().schema()
                schema['properties']['foo'] = {
                    'type': 'string',
                }
                schema['pull-properties'] = ['bar']

                return schema

        self.useFixture(fixture_setup.FakePlugin('plugin', Plugin))
        raised = self.assertRaises(errors.InvalidPullPropertiesError,
                                   self.load_part, 'fake-part', 'plugin')

        self.assertThat(
            str(raised),
            Equals("Invalid pull properties specified by 'plugin' plugin: "
                   "['bar']"))