Exemplo n.º 1
0
def test_default_or_local_repo_not_set():
    ubi.DEFAULT_UBI_REPO = ''
    expected_error = ValueError('Please either set use_local or define \
DEFAULT_UBI_URL in your environment')
    try:
        ubi.get_loader()
        raise AssertionError('should not get a loader!')
    except ValueError as e:
        assert isinstance(e, type(expected_error))
        assert e.args == expected_error.args
    ubi.DEFAULT_UBI_REPO = 'https://contentdelivery.com/ubi/data'
Exemplo n.º 2
0
def test_syntax_from_config_file():
    loader = ubi.get_loader(local=True, local_repo=TEST_DATA_DIR)
    try:
        loader.load('bad_configs/syntax_error.yaml')
        raise AssertionError('load should fail!')
    except yaml.YAMLError as e:
        assert e.problem == "expected <block end>, but found '?'"
Exemplo n.º 3
0
def test_load_all_from_local_without_repo_set():
    loader = ubi.get_loader(local=True)
    try:
        loader.load_all()
        raise AssertionError('should fail!')
    except RuntimeError as e:
        assert e.args == ('You need to set local repo to load all files',)
Exemplo n.º 4
0
def test_load_all_from_default_repo(mocked_pre_load, mocked_session, files_branch_map,
                                    dnf7_config_file, ubi7_config_file, response):
    mocked_pre_load.return_value = files_branch_map
    mocked_session.return_value.get.side_effect = ['200 OK',
                                                   response(dnf7_config_file),
                                                   response(ubi7_config_file)]
    loader = ubi.get_loader()
    configs = loader.load_all()
    configs = sorted(configs, key=repr)
    assert len(configs) == 2
    assert isinstance(configs[0], ubi.UbiConfig)
    assert str(configs[1]) == 'rhel-atomic-host.yaml'
Exemplo n.º 5
0
def test_load_all_from_local_recursive():
    repo = os.path.join(TEST_DATA_DIR, 'configs')
    loader = ubi.get_loader(local=True, local_repo=repo)
    configs = loader.load_all(recursive=True)
    assert len(configs) == 2
    assert isinstance(configs[0], ubi.UbiConfig)
Exemplo n.º 6
0
def test_load_from_local():
    loader = ubi.get_loader(local=True)
    # pass the complete path to load
    config = loader.load(os.path.join(TEST_DATA_DIR, 'configs/dnf7/rhel-atomic-host.yaml'))
    assert isinstance(config, ubi.UbiConfig)