Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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')
Пример #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)        
Пример #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)
Пример #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')
Пример #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, {})
Пример #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")
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #15
0
 def _load_global_config(self):
     self.global_config = YamlGlobalConfig()
Пример #16
0
 def _load_global_config(self):
     try:
         self.global_config = YamlGlobalConfig()
     except NotInProject as e:
         raise click.UsageError(e.message)