Esempio n. 1
0
    def test_new(self):
        config_write = pygit2.Config(config_filename)

        self.assertNotEqual(config_write, None)

        config_write['core.bare'] = False
        config_write['core.editor'] = 'ed'

        config_read = pygit2.Config(config_filename)
        self.assertTrue('core.bare' in config_read)
        self.assertFalse(config_read['core.bare'])
        self.assertTrue('core.editor' in config_read)
        self.assertEqual(config_read['core.editor'], 'ed')
Esempio n. 2
0
    def test_add(self):
        config = pygit2.Config()

        new_file = open(config_filename, "w")
        new_file.write("[this]\n\tthat = true\n")
        new_file.write("[something \"other\"]\n\there = false")
        new_file.close()

        config.add_file(config_filename, 0)
        self.assertTrue('this.that' in config)
        self.assertTrue(config['this.that'])
        self.assertTrue('something.other.here' in config)
        self.assertFalse(config['something.other.here'])
Esempio n. 3
0
    def test_config_commit(self):
        # ensure ocp-build-data is cloned
        _, out, _ = run_doozer(["--group=openshift-3.11", "config:get"])
        # configure user.name and user.email for ocp-build-data commit
        ocp_build_data_dir = os.path.join(get_working_dir(), "ocp-build-data")
        repo = pygit2.Repository(ocp_build_data_dir)
        pygit2.Config()
        repo_conf = repo.config  # type: pygit2.Config
        repo_conf["user.name"] = "Doozer Test User"
        repo_conf["user.email"] = "*****@*****.**"

        _, out, _ = run_doozer([
            "--group=openshift-3.11",
            "config:commit",
            "--message=Doozer test commit message",
            "--no-push",
        ])

        # Assert commit message
        commit = repo.head.peel(pygit2.Commit)  # type: pygit2.Commit
        self.assertEqual(commit.message.rstrip(), "Doozer test commit message")