Exemplo n.º 1
0
    def get_nd2g(self, name):
        """
        Gets a NumberedDirectoriesToGit object.

        Where ``name`` is the basename of a directory in
        :file:`src/jig/tests/fixtures/numbereddirs`.
        """
        nd = join(dirname(__file__), 'fixtures', 'numbereddirs', name)

        return NumberedDirectoriesToGit(nd)
Exemplo n.º 2
0
    def repo_from_fixture(self, repo_name):
        """
        Creates a ``git.Repo`` from the given fixture.

        The fixture should be a directory containing numbered directories
        suitable for creating a ``NumberedDirectoriesToGit``.

        Returns a tuple of 3 objects: repo, working_dir, diffs.
        """
        ndgit = NumberedDirectoriesToGit(
            join(self.fixturesdir, repo_name))

        repo = ndgit.repo

        return (ndgit.repo, repo.working_dir, ndgit.diffs())
Exemplo n.º 3
0
    def test_update_existing_plugins(self):
        """
        Can update an existing plugin.
        """
        # Make our remote repository so we have something to pull from
        origin_repo = mkdtemp()
        root_commit_dir = join(origin_repo, '01')
        makedirs(root_commit_dir)

        # Create a plugin in the repo
        create_plugin(root_commit_dir, template='python', bundle='a', name='a')
        create_plugin(root_commit_dir, template='python', bundle='b', name='b')

        # This is the directory we will clone
        ngd = NumberedDirectoriesToGit(origin_repo)
        dir_to_clone = ngd.repo.working_dir

        # This is a trick, we give it the dir_to_clone when asked to install it
        def clone_local(plugin, to_dir, branch):
            # Instead of jumping on the Internet to clone this, we will use the
            # local numbered directory repository we setup above. This will
            # allow our update to occur with a git pull and avoid network
            # traffic which is always faster for tests.
            clone(dir_to_clone, to_dir)

        # First thing is to install the the plugin
        with patch('jig.commands.base.clone') as c:
            c.side_effect = clone_local

            self.run_command('add --gitrepo {0} http://repo'.format(
                self.gitrepodir))

        self.run_command('update --gitrepo {0}'.format(self.gitrepodir))

        self.assertResults(
            """
            Updating plugins

            Plugin a, b in bundle a, b
                Already up-to-date.""", self.output)
Exemplo n.º 4
0
    def __init__(self, plugin_dir):
        self.plugin_dir = plugin_dir
        self.timeline = None
        self.expectations = None

        try:
            test_directory = join(plugin_dir, PLUGIN_TESTS_DIRECTORY)
            self.timeline = NumberedDirectoriesToGit(test_directory)
        except ValueError:
            raise ExpectationNoTests(
                'Could not find any tests: {0}.'.format(test_directory))

        try:
            expect_filename = join(plugin_dir, PLUGIN_TESTS_DIRECTORY,
                                   PLUGIN_EXPECTATIONS_FILENAME)

            with open(expect_filename, 'r', CODEC) as fh:
                expectation_text = fh.read()  # pragma: no branch

            self.expectations = list(get_expectations(expectation_text))
        except (IOError, OSError):
            raise ExpectationFileNotFound(
                'Missing expectation file: {0}.'.format(expect_filename))