示例#1
0
    def setUpClass(self):
        self.maxDiff = None

        repo_dir = tempfile.mkdtemp(prefix="lorax.test.repo.")
        server.config["REPO_DIR"] = repo_dir
        repo = open_or_create_repo(server.config["REPO_DIR"])
        server.config["GITLOCK"] = GitLock(repo=repo, lock=Lock(), dir=repo_dir)

        server.config["COMPOSER_CFG"] = configure(root_dir=repo_dir, test_config=True)
        os.makedirs(joinpaths(server.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))
        errors = make_queue_dirs(server.config["COMPOSER_CFG"], 0)
        if errors:
            raise RuntimeError("\n".join(errors))

        make_dnf_dirs(server.config["COMPOSER_CFG"])
        dbo = get_base_object(server.config["COMPOSER_CFG"])
        server.config["DNFLOCK"] = DNFLock(dbo=dbo, lock=Lock())

        server.config['TESTING'] = True
        self.server = server.test_client()
        self.repo_dir = repo_dir

        self.examples_path = "./tests/pylorax/blueprints/"

        # Copy the shared files over to the directory tree we are using
        share_path = "./share/composer/"
        for f in glob(joinpaths(share_path, "*")):
            shutil.copy(f, joinpaths(server.config["COMPOSER_CFG"].get("composer", "share_dir"), "composer"))

        # Import the example blueprints
        commit_recipe_directory(server.config["GITLOCK"].repo, "master", self.examples_path)

        start_queue_monitor(server.config["COMPOSER_CFG"], 0, 0)
示例#2
0
    def test_05_commit_recipe_directory_handling_internal_exceptions(self):
        """Test committing a directory of TOML files while handling internal exceptions"""
        # first verify that the newly created file isn't present
        old_commits = recipes.list_commits(self.repo, "master",
                                           "python-testing.toml")
        self.assertEqual(len(old_commits), 0,
                         "Wrong number of commits: %s" % old_commits)

        # then create it and commit the entire directory
        self._create_another_recipe()

        # try to commit while raising RecipeFileError
        with mock.patch('pylorax.api.recipes.commit_recipe_file',
                        side_effect=recipes.RecipeFileError('TESTING')):
            recipes.commit_recipe_directory(self.repo, "master",
                                            self.examples_path)

        # try to commit while raising TomlError
        with mock.patch('pylorax.api.recipes.commit_recipe_file',
                        side_effect=TomlError('TESTING', 0, 0, '__test__')):
            recipes.commit_recipe_directory(self.repo, "master",
                                            self.examples_path)

        # verify again that the newly created file isn't present b/c we raised an exception
        new_commits = recipes.list_commits(self.repo, "master",
                                           "python-testing.toml")
        self.assertEqual(len(new_commits), 0,
                         "Wrong number of commits: %s" % new_commits)
示例#3
0
    def test_05_commit_toml_dir(self):
        """Test committing a directory of TOML files"""
        # first verify that the newly created file isn't present
        old_commits = recipes.list_commits(self.repo, "master", "python-testing.toml")
        self.assertEqual(len(old_commits), 0, "Wrong number of commits: %s" % old_commits)

        # then create it and commit the entire directory
        self._create_another_recipe()
        recipes.commit_recipe_directory(self.repo, "master", self.examples_path)

        # verify that the newly created file is already in the repository
        new_commits = recipes.list_commits(self.repo, "master", "python-testing.toml")
        self.assertEqual(len(new_commits), 1, "Wrong number of commits: %s" % new_commits)
        # again make sure new_commits != old_commits
        self.assertGreater(len(new_commits), len(old_commits),
                           "New commits shoud differ from old commits")
示例#4
0
    def setUpClass(self):
        self.rawhide = False
        self.maxDiff = None

        repo_dir = tempfile.mkdtemp(prefix="lorax.test.repo.")
        server.config["REPO_DIR"] = repo_dir
        repo = open_or_create_repo(server.config["REPO_DIR"])
        server.config["GITLOCK"] = GitLock(repo=repo,
                                           lock=Lock(),
                                           dir=repo_dir)

        server.config["COMPOSER_CFG"] = configure(root_dir=repo_dir,
                                                  test_config=True)
        os.makedirs(
            joinpaths(
                server.config["COMPOSER_CFG"].get("composer", "share_dir"),
                "composer"))
        errors = make_queue_dirs(server.config["COMPOSER_CFG"], 0)
        if errors:
            raise RuntimeError("\n".join(errors))

        make_dnf_dirs(server.config["COMPOSER_CFG"])

        # copy over the test dnf repositories
        dnf_repo_dir = server.config["COMPOSER_CFG"].get(
            "composer", "repo_dir")
        for f in glob("./tests/pylorax/repos/*.repo"):
            shutil.copy2(f, dnf_repo_dir)

        # Modify fedora vs. rawhide tests when running on rawhide
        if os.path.exists("/etc/yum.repos.d/fedora-rawhide.repo"):
            self.rawhide = True

        # dnf repo baseurl has to point to an absolute directory, so we use /tmp/lorax-empty-repo/ in the files
        # and create an empty repository
        os.makedirs("/tmp/lorax-empty-repo/")
        os.system("createrepo_c /tmp/lorax-empty-repo/")

        dbo = get_base_object(server.config["COMPOSER_CFG"])
        server.config["DNFLOCK"] = DNFLock(dbo=dbo, lock=Lock())

        server.config['TESTING'] = True
        self.server = server.test_client()
        self.repo_dir = repo_dir

        self.examples_path = "./tests/pylorax/blueprints/"

        # Copy the shared files over to the directory tree we are using
        share_path = "./share/composer/"
        for f in glob(joinpaths(share_path, "*")):
            shutil.copy(
                f,
                joinpaths(
                    server.config["COMPOSER_CFG"].get("composer", "share_dir"),
                    "composer"))

        # Import the example blueprints
        commit_recipe_directory(server.config["GITLOCK"].repo, "master",
                                self.examples_path)

        start_queue_monitor(server.config["COMPOSER_CFG"], 0, 0)