Пример #1
0
    def test_load_raw_configs(self):
        try:
            tempdir = mkdtemp()
            condarc = join(tempdir, '.condarc')
            condarcd = join(tempdir, 'condarc.d')
            f1 = join(condarcd, 'file1.yml')
            f2 = join(condarcd, 'file2.yml')
            not_a_file = join(tempdir, 'not_a_file')

            mkdir(condarcd)

            with open(f1, 'wb') as fh:
                fh.write(test_yaml_raw['file1'].encode('utf-8'))
            with open(f2, 'wb') as fh:
                fh.write(test_yaml_raw['file2'].encode('utf-8'))
            with open(condarc, 'wb') as fh:
                fh.write(test_yaml_raw['file3'].encode('utf-8'))
            search_path = [condarc, not_a_file, condarcd]
            raw_data = load_file_configs(search_path)
            assert not_a_file not in raw_data
            assert raw_data[condarc]['channels'].value(None)[0] == "wile"
            assert raw_data[f1]['always_yes'].value(None) == "no"
            assert raw_data[f2]['proxy_servers'].value(None)['http'] == "marv"

            config = SampleConfiguration(search_path)

            from pprint import pprint
            for key, val in config.collect_all().items():
                print(key)
                pprint(val)
            assert config.channels == ('wile', 'porky', 'bugs', 'elmer',
                                       'daffy', 'tweety', 'foghorn')
        finally:
            rmtree(tempdir, ignore_errors=True)
Пример #2
0
    def test_load_raw_configs(self):
        try:
            tempdir = mkdtemp()
            condarc = join(tempdir, '.condarc')
            condarcd = join(tempdir, 'condarc.d')
            f1 = join(condarcd, 'file1.yml')
            f2 = join(condarcd, 'file2.yml')
            not_a_file = join(tempdir, 'not_a_file')

            mkdir(condarcd)

            with open(f1, 'wb') as fh:
                fh.write(test_yaml_raw['file1'].encode('utf-8'))
            with open(f2, 'wb') as fh:
                fh.write(test_yaml_raw['file2'].encode('utf-8'))
            with open(condarc, 'wb') as fh:
                fh.write(test_yaml_raw['file3'].encode('utf-8'))
            search_path = [condarc, not_a_file, condarcd]
            raw_data = load_file_configs(search_path)
            assert not_a_file not in raw_data
            assert raw_data[condarc]['channels'].value(None)[0] == "wile"
            assert raw_data[f1]['always_yes'].value(None) == "no"
            assert raw_data[f2]['proxy_servers'].value(None)['http'] == "marv"

            config = SampleConfiguration(search_path)
            assert config.channels == ('wile', 'porky', 'bugs', 'elmer', 'daffy',
                                       'tweety', 'foghorn')

        finally:
            rmtree(tempdir, ignore_errors=True)