Exemplo n.º 1
0
def test_output_dir_file_cant_use_both():
    '''
    Cannot supply both --output-file and --output-dir
    '''
    with pytest.raises(ValueError):
        c = InsightsConfig(output_dir='test', output_file='test')
        c.load_all()
Exemplo n.º 2
0
def test_implied_non_legacy_upload(config):
    '''
    Some arguments should always imply legacy_upload=False.
    '''
    c = InsightsConfig(**config)
    c.load_all()
    assert c.legacy_upload is False
Exemplo n.º 3
0
def test_diagnosis_implies_legacy():
    '''
    --diagnosis should always imply legacy_upload=False
    '''
    c = InsightsConfig(diagnosis=True)
    c.load_all()
    assert c.legacy_upload is False
Exemplo n.º 4
0
def test_to_json_quiet_implies_diagnosis():
    '''
    --diagnosis should always imply legacy_upload=False
    '''
    c = InsightsConfig(to_json=True, quiet=True)
    c.load_all()
    assert c.diagnosis is True
    assert c.legacy_upload is False
Exemplo n.º 5
0
def test_output_dir_file_validate():
    '''
    Must supply non-empty strings for --output-dir or --output-file
    '''
    with pytest.raises(ValueError):
        c = InsightsConfig(output_dir='')
        c.load_all()
    with pytest.raises(ValueError):
        c = InsightsConfig(output_file='')
        c.load_all()
Exemplo n.º 6
0
def test_inventory_url_from_phase(try_satellite6_configuration,
                                  try_satellite5_configuration, get_proxies,
                                  init_session, config_kwargs):
    """
    Inventory URL is composed correctly from the default configuration.
    """
    config = InsightsConfig(**config_kwargs)
    config.load_all()  # Disables legacy upload.
    try_auto_configuration(
        config)  # Updates base_url if legacy upload is disabled.
    connection = InsightsConnection(config)
    assert connection.inventory_url == "https://cert-api.access.redhat.com/r/insights/platform/inventory/v1"
Exemplo n.º 7
0
def test_compressor_option_validate():
    '''
    Compressor options are validated in config.py
    (used to be in archive.py)
    If an unsupported option is given, select 'gz'
    '''
    for comp in ('gz', 'bz2', 'xz', 'none'):
        c = InsightsConfig(compressor=comp)
        c.load_all()
        assert c.compressor == comp

    c = InsightsConfig(compressor='hullabaloo')
    c.load_all()
    assert c.compressor == 'gz'
Exemplo n.º 8
0
def test_output_dir_file_implies_no_upload_true_keep_archive_false():
    '''
    Using --output-dir or --tar-file should imply:
        no-upload    == True,  because we don't want to upload
        keep-archive == False, because we don't want to keep the files in temp
    '''
    c = InsightsConfig(output_dir='test')
    c.load_all()
    assert c.no_upload
    assert not c.keep_archive
    c = InsightsConfig(output_file='test')
    c.load_all()
    assert c.no_upload
    assert not c.keep_archive
Exemplo n.º 9
0
def test_output_file_guess_file_ext():
    '''
    If --output-file is selected, automatically guess
    the compressor option based on the file extension.

    If the compressor cannot be guessed from the filename,
    the filename will be given an extension based on the
    compressor option (default .tar.gz).

    If the proper extension is already part of the
    output file, the output file is unchanged.
    '''
    c = InsightsConfig(output_file='test-abc')
    c.load_all()
    assert c.output_file == os.path.abspath('test-abc.tar.gz')
    assert c.compressor == 'gz'

    c = InsightsConfig(output_file='test-def.tar.gz')
    c.load_all()
    assert c.output_file == os.path.abspath('test-def.tar.gz')
    assert c.compressor == 'gz'

    c = InsightsConfig(output_file='test-ghi.tar.bz2', compressor='bz2')
    c.load_all()
    assert c.output_file == os.path.abspath('test-ghi.tar.bz2')
    assert c.compressor == 'bz2'

    c = InsightsConfig(output_file='test-jkl', compressor='valkyrie')
    c.load_all()
    assert c.output_file == os.path.abspath('test-jkl.tar.gz')
    assert c.compressor == 'gz'

    c = InsightsConfig(output_file='test-mno.tar')
    c.load_all()
    assert c.output_file == os.path.abspath('test-mno.tar')
    assert c.compressor == 'none'