Esempio n. 1
0
    def test_add_and_use_if_only(self):
        # TODO: create a new repo and use it
        name1 = "origin"
        url1 = "https://www.verta.ai/"
        name2 = "upstream"
        url2 = "https://www.verta.ai/"

        runner = CliRunner()
        with runner.isolated_filesystem():
            runner.invoke(cli, ['init'])

            runner.invoke(cli, ['remote', 'add', name1, url1])
            with _config_utils.read_merged_config() as config:
                assert config['current-remote'] == name1

            runner.invoke(cli, ['remote', 'add', name2, url2])
            with _config_utils.read_merged_config() as config:
                # unchanged; still name1
                assert config['current-remote'] == name1
Esempio n. 2
0
    def test_add(self):
        # TODO: create a new repo and use it
        name = "origin"
        url = "https://www.verta.ai/"

        runner = CliRunner()
        with runner.isolated_filesystem():
            runner.invoke(cli, ['init'])

            result = runner.invoke(cli, ['remote', 'add', name, url])
            assert not result.exception
            with _config_utils.read_merged_config() as config:
                remotes = config['remotes']
                remote = remotes[name]
                assert remote['url'] == url
                assert remote['branch'] == "master"
Esempio n. 3
0
    def test_use(self):
        # TODO: create a new repo and use it
        name1 = "origin"
        url1 = "https://www.verta.ai/"
        name2 = "upstream"
        url2 = "https://www.verta.ai/"

        runner = CliRunner()
        with runner.isolated_filesystem():
            runner.invoke(cli, ['init'])
            runner.invoke(cli, ['remote', 'add', name1, url1])
            runner.invoke(cli, ['remote', 'add', name2, url2])

            result = runner.invoke(cli, ['remote', 'use', name2])
            assert not result.exception
            with _config_utils.read_merged_config() as config:
                assert config['current-remote'] == name2
Esempio n. 4
0
    def test_merge_and_overwrite(self, expected_config):
        cwd_config_filepath = os.path.abspath(_config_utils.CONFIG_YAML_FILENAME)

        # pick a key from config
        config_keys = set(expected_config.keys())
        #     don't pick the key that's already in cwd config
        with open(cwd_config_filepath, 'r') as f:
            nearest_config = yaml.safe_load(f)
            config_keys -= set(nearest_config.keys())
        key = config_keys.pop()

        # arbitrary new value
        value = "NEW_VALUE"

        # add item to cwd config
        nearest_config[key] = value
        with open(cwd_config_filepath, 'w') as f:
            yaml.safe_dump(nearest_config, f)

        # merged config has new value, not old value
        expected_config[key] = value
        with _config_utils.read_merged_config() as config:
            assert config == expected_config
Esempio n. 5
0
 def test_merge(self, expected_config):
     with _config_utils.read_merged_config() as config:
         assert config == expected_config