Ejemplo n.º 1
0
    def test_url_with_branch(self):
        """
        URL with a branch specifier.
        """
        add_plugin(self.pm, 'http://a.b/c@branch', self.gitrepodir)

        # Since this was a URL clone was called with the full URL
        self.clone.assert_called_with(
            'http://a.b/c',
            '{0}/.jig/plugins/{1}'.format(self.gitrepodir, MockUUID.hex),
            'branch')
Ejemplo n.º 2
0
    def test_url_with_branch(self):
        """
        URL with a branch specifier.
        """
        add_plugin(self.pm, 'http://a.b/c@branch', self.gitrepodir)

        # Since this was a URL clone was called with the full URL
        self.clone.assert_called_with(
            'http://a.b/c',
            '{0}/.jig/plugins/{1}'.format(self.gitrepodir,
                                          MockUUID.hex), 'branch')
Ejemplo n.º 3
0
    def test_add_file_system(self):
        """
        Adds a file system plugin.
        """
        add_plugin(self.pm, '/a/b/c', self.gitrepodir)

        # Since this was from the file system clone was not called
        self.assertFalse(self.clone.called)

        # The plugin manager add() method was called with the location verbatim
        self.pm.add.assert_called_with('/a/b/c')
Ejemplo n.º 4
0
    def test_add_file_system(self):
        """
        Adds a file system plugin.
        """
        add_plugin(self.pm, '/a/b/c', self.gitrepodir)

        # Since this was from the file system clone was not called
        self.assertFalse(self.clone.called)

        # The plugin manager add() method was called with the location verbatim
        self.pm.add.assert_called_with('/a/b/c')
Ejemplo n.º 5
0
    def test_cleanup_on_error_with_url(self):
        """
        Cleanup occurs on a plugin error.
        """
        self.pm.add.side_effect = PluginError

        # Make sure that the error does bubble out
        with self.assertRaises(PluginError):
            add_plugin(self.pm, 'http://a.b/c', self.gitrepodir)

        self.rmtree.assert_called_with(
            '{0}/.jig/plugins/{1}'.format(self.gitrepodir, MockUUID.hex))
Ejemplo n.º 6
0
    def test_add_file_system_error_skips_cleanup(self):
        """
        Cleanup only occurs if the plugin is URL-based
        """
        self.pm.add.side_effect = PluginError

        # Make sure that the error does bubble out
        with self.assertRaises(PluginError):
            add_plugin(self.pm, '/a/b/c', self.gitrepodir)

        # Since we didn't clone a repository, we should not clean anything up
        self.assertFalse(self.rmtree.called)
Ejemplo n.º 7
0
    def test_cleanup_on_error_with_url(self):
        """
        Cleanup occurs on a plugin error.
        """
        self.pm.add.side_effect = PluginError

        # Make sure that the error does bubble out
        with self.assertRaises(PluginError):
            add_plugin(self.pm, 'http://a.b/c', self.gitrepodir)

        self.rmtree.assert_called_with('{0}/.jig/plugins/{1}'.format(
            self.gitrepodir, MockUUID.hex))
Ejemplo n.º 8
0
    def test_add_file_system_error_skips_cleanup(self):
        """
        Cleanup only occurs if the plugin is URL-based
        """
        self.pm.add.side_effect = PluginError

        # Make sure that the error does bubble out
        with self.assertRaises(PluginError):
            add_plugin(self.pm, '/a/b/c', self.gitrepodir)

        # Since we didn't clone a repository, we should not clean anything up
        self.assertFalse(self.rmtree.called)
Ejemplo n.º 9
0
    def process(self, argv):
        path = argv.path
        plugins_file = argv.pluginsfile

        with self.out() as out:
            try:
                plugin_list = read_plugin_list(plugins_file)
            except IOError as e:
                # Grab the human-readable part of the IOError and raise that
                raise PluginError(e[1])

            for plugin in plugin_list:
                config = get_jigconfig(path)
                pm = PluginManager(config)

                try:
                    added = add_plugin(pm, plugin, path)
                except Exception as e:
                    out.append('From {0}:\n - {1}'.format(plugin, e))
                    continue

                set_jigconfig(path, pm.config)

                out.append('From {0}:'.format(plugin))
                for p in added:
                    out.append(' - Added plugin {0} in bundle {1}'.format(
                        p.name, p.bundle))

            out.extend(USE_RUNNOW)
Ejemplo n.º 10
0
    def test_url_without_branch(self):
        """
        URL without a branch specifier.
        """
        add_plugin(self.pm, 'http://a.b/c', self.gitrepodir)

        # Since this was a URL clone was called with the full URL
        self.clone.assert_called_with(
            'http://a.b/c',
            '{0}/.jig/plugins/{1}'.format(self.gitrepodir, MockUUID.hex), None)

        # The plugin manager was given the newly cloned location
        self.pm.add.assert_called_with('{0}/.jig/plugins/{1}'.format(
            self.gitrepodir, MockUUID.hex))

        # Since things went well, the cleanup function was not ran
        self.assertFalse(self.rmtree.called)
Ejemplo n.º 11
0
    def test_url_without_branch(self):
        """
        URL without a branch specifier.
        """
        add_plugin(self.pm, 'http://a.b/c', self.gitrepodir)

        # Since this was a URL clone was called with the full URL
        self.clone.assert_called_with(
            'http://a.b/c',
            '{0}/.jig/plugins/{1}'.format(self.gitrepodir, MockUUID.hex),
            None)

        # The plugin manager was given the newly cloned location
        self.pm.add.assert_called_with(
            '{0}/.jig/plugins/{1}'.format(self.gitrepodir, MockUUID.hex))

        # Since things went well, the cleanup function was not ran
        self.assertFalse(self.rmtree.called)
Ejemplo n.º 12
0
    def add(self, argv):
        """
        Add a plugin.
        """
        path = argv.path
        plugin = argv.plugin

        with self.out() as out:
            config = get_jigconfig(path)

            pm = PluginManager(config)

            added = add_plugin(pm, plugin, path)

            set_jigconfig(path, pm.config)

            for p in added:
                out.append(
                    'Added plugin {0} in bundle {1} to the '
                    'repository.'.format(p.name, p.bundle))

            out.extend(USE_RUNNOW)