def test_file_invalid__raise(self, tmp_file):
        tmp_file.write_text('''
        { 'this': is not yaml}
        ''')

        with pytest.raises(ValueError, match='Invalid Hierarchy') as e:
            loader.load_from_file(tmp_file)
    def test_file_invalid_2__raise(self, tmp_file):
        tmp_file.write_text('''
        repos:
          - path: '/this/is/a/path'
            name: hc
        ''')

        with pytest.raises(ValueError, match='Invalid Hierarchy') as e:
            loader.load_from_file(tmp_file)
    def test_no_explicit_name__extract_from_url(self, tmp_file):
        tmp_file.write_text('''
        repos:
          - url: '[email protected]:FlorianKempenich/Hierarchy.git'
            path: '/this/is/a/path'
        ''')

        repos = loader.load_from_file(tmp_file)

        assert repos[0].path == Path('/this/is/a/path/Hierarchy')
    def test_expand_home_in_path(self, expanduser, tmp_file):
        tmp_file.write_text('''
        repos:
          - url: '[email protected]:FlorianKempenich/Hierarchy.git'
            path: '~/this/is/a/path/with/home/symbol'
        ''')
        expanduser.return_value = 'EXPECTED_PATH'

        repos = loader.load_from_file(tmp_file)

        expanduser.assert_called_with('~/this/is/a/path/with/home/symbol')
        assert repos[0].path == Path('EXPECTED_PATH/Hierarchy')
    def test_valid_hierarchy(self, tmp_file: Path):
        tmp_file.write_text('''
        repos:
          - url: '[email protected]:FlorianKempenich/Hierarchy.git'
            path: '/this/is/a/path'
            name: hc

          - url: '[email protected]:FlorianKempenich/kata.git'
            path: '/some/other/path'
            name: kata
        ''')

        repos = loader.load_from_file(tmp_file)

        assert repos == [
            RepoToClone(url='[email protected]:FlorianKempenich/Hierarchy.git',
                        root_path=Path('/this/is/a/path'),
                        name='hc'),
            RepoToClone(url='[email protected]:FlorianKempenich/kata.git',
                        root_path=Path('/some/other/path'),
                        name='kata')
        ]
Beispiel #6
0
def clone_hierarchy(hierarchy_file):
    clone_all(load_from_file(hierarchy_file))
    def test_file_empty__raise(self, tmp_file):
        tmp_file.write_text('''
        ''')

        with pytest.raises(ValueError, match='Invalid Hierarchy') as e:
            loader.load_from_file(tmp_file)
    def test_file_does_not_exist__raise(self):
        doesnt_exist = Path('/does/not/exist')
        assert not doesnt_exist.exists()

        with pytest.raises(ValueError, match=r'File .* does not exist!') as e:
            loader.load_from_file(doesnt_exist)