Beispiel #1
0
 def test_load_project_config_no_config(self, mock_class):
     mock_class.return_value = self.tempdir_home
     os.mkdir(os.path.join(self.tempdir_project, ".git"))
     os.chdir(self.tempdir_project)
     global_config = YamlGlobalConfig()
     with self.assertRaises(ProjectConfigNotFound):
         config = YamlProjectConfig(global_config)
Beispiel #2
0
 def test_load_global_config_no_local(self, mock_class):
     mock_class.return_value = self.tempdir_home
     config = YamlGlobalConfig()
     with open(__location__ + "/../../cumulusci.yml",
               "r") as f_expected_config:
         expected_config = yaml.load(f_expected_config)
     self.assertEquals(config.config, expected_config)
Beispiel #3
0
    def test_load_global_config_empty_local(self, mock_class):
        self._create_global_config_local('')
        mock_class.return_value = self.tempdir_home

        config = YamlGlobalConfig()
        with open(__location__ + '/../../cumulusci.yml', 'r') as f_expected_config:
            expected_config = yaml.load(f_expected_config)
        self.assertEquals(config.config, expected_config)
Beispiel #4
0
    def test_repo_commit(self, mock_class):
        mock_class.return_value = self.tempdir_home
        os.mkdir(os.path.join(self.tempdir_project, ".git"))
        self._create_git_config()

        # create valid project config file
        self._create_project_config()

        os.chdir(self.tempdir_project)
        global_config = YamlGlobalConfig()
        config = YamlProjectConfig(global_config)
        self.assertEquals(config.repo_commit, self.current_commit)
Beispiel #5
0
    def test_repo_owner(self, mock_class):
        mock_class.return_value = self.tempdir_home
        os.mkdir(os.path.join(self.tempdir_project, '.git'))
        self._create_git_config()

        # create valid project config file
        self._create_project_config()

        os.chdir(self.tempdir_project)
        global_config = YamlGlobalConfig()
        config = YamlProjectConfig(global_config)
        self.assertEquals(config.repo_owner, 'TestOwner')
Beispiel #6
0
    def test_load_global_config_with_local(self, mock_class):
        local_yaml = 'tasks:\n    newtesttask:\n        description: test description'
        self._create_global_config_local(local_yaml)
        mock_class.return_value = self.tempdir_home

        config = YamlGlobalConfig()
        with open(__location__ + '/../../cumulusci.yml', 'r') as f_expected_config:
            expected_config = yaml.load(f_expected_config)
        expected_config['tasks']['newtesttask'] = {}
        expected_config['tasks']['newtesttask'][
            'description'] = 'test description'
        self.assertEquals(config.config, expected_config)        
Beispiel #7
0
    def test_load_global_config_with_local(self, mock_class):
        local_yaml = "tasks:\n    newtesttask:\n        description: test description"
        self._create_global_config_local(local_yaml)
        mock_class.return_value = self.tempdir_home

        config = YamlGlobalConfig()
        with open(__location__ + "/../../cumulusci.yml",
                  "r") as f_expected_config:
            expected_config = yaml.load(f_expected_config)
        expected_config["tasks"]["newtesttask"] = {}
        expected_config["tasks"]["newtesttask"][
            "description"] = "test description"
        self.assertEquals(config.config, expected_config)
Beispiel #8
0
    def test_load_project_config_valid_config(self, mock_class):
        mock_class.return_value = self.tempdir_home
        os.mkdir(os.path.join(self.tempdir_project, '.git'))
        self._create_git_config()

        # create valid project config file
        self._create_project_config()

        os.chdir(self.tempdir_project)
        global_config = YamlGlobalConfig()
        config = YamlProjectConfig(global_config)
        self.assertEquals(config.project__package__name, 'TestProject')
        self.assertEquals(config.project__package__namespace, 'testproject')
Beispiel #9
0
    def test_load_project_config_empty_config(self, mock_class):
        mock_class.return_value = self.tempdir_home
        os.mkdir(os.path.join(self.tempdir_project, ".git"))
        self._create_git_config()
        # create empty project config file
        filename = os.path.join(self.tempdir_project,
                                YamlProjectConfig.config_filename)
        content = ""
        self._write_file(filename, content)

        os.chdir(self.tempdir_project)
        global_config = YamlGlobalConfig()
        config = YamlProjectConfig(global_config)
        self.assertEquals(config.config_project, {})
Beispiel #10
0
    def test_load_project_config_valid_config(self, mock_class):
        mock_class.return_value = self.tempdir_home
        os.mkdir(os.path.join(self.tempdir_project, ".git"))
        self._create_git_config()
        local_yaml = "tasks:\n    newtesttask:\n        description: test description"
        self._create_global_config_local(local_yaml)

        # create valid project config file
        self._create_project_config()

        os.chdir(self.tempdir_project)
        global_config = YamlGlobalConfig()
        config = YamlProjectConfig(global_config)
        self.assertEquals(config.project__package__name, "TestProject")
        self.assertEquals(config.project__package__namespace, "testproject")
Beispiel #11
0
    def test_load_additional_yaml(self, mock_class):
        mock_class.return_value = self.tempdir_home
        os.mkdir(os.path.join(self.tempdir_project, ".git"))
        self._create_git_config()

        # create valid project config file
        self._create_project_config()

        # create local project config file
        content = "project:\n" + "    package:\n" + "        api_version: 10\n"

        os.chdir(self.tempdir_project)
        global_config = YamlGlobalConfig()
        config = YamlProjectConfig(global_config, additional_yaml=content)
        self.assertNotEqual(config.config_additional_yaml, {})
        self.assertEqual(config.project__package__api_version, 10)
Beispiel #12
0
    def test_load_project_config_local(self, mock_class):
        mock_class.return_value = self.tempdir_home
        os.mkdir(os.path.join(self.tempdir_project, '.git'))
        self._create_git_config()

        # create valid project config file
        self._create_project_config()

        # create local project config file
        content = ('project:\n' + '    package:\n' +
                   '        api_version: 10\n')
        self._create_project_config_local(content)

        os.chdir(self.tempdir_project)
        global_config = YamlGlobalConfig()
        config = YamlProjectConfig(global_config)
        self.assertNotEqual(config.config_project_local, {})
        self.assertEqual(config.project__package__api_version, 10)
Beispiel #13
0
 def test_load_project_config_not_repo(self, mock_class):
     mock_class.return_value = self.tempdir_home
     os.chdir(self.tempdir_project)
     global_config = YamlGlobalConfig()
     config = YamlProjectConfig(global_config)
Beispiel #14
0
 def test_load_project_config_no_config(self, mock_class):
     mock_class.return_value = self.tempdir_home
     os.mkdir(os.path.join(self.tempdir_project, '.git'))
     os.chdir(self.tempdir_project)
     global_config = YamlGlobalConfig()
     config = YamlProjectConfig(global_config)
Beispiel #15
0
 def _load_global_config(self):
     self.global_config = YamlGlobalConfig()
Beispiel #16
0
 def _load_global_config(self):
     try:
         self.global_config = YamlGlobalConfig()
     except NotInProject as e:
         raise click.UsageError(e.message)