def test_get_config_values_missing_values_config_file():
    with pytest.raises(Error):
        unparsable_config_file = os.path.join(TEST_DIR, 'fixtures', 'settings',
                                              'unparsable_settings.cfg')

        trailers.get_config_values(unparsable_config_file,
                                   SOME_CONFIG_DEFAULTS)
def test_get_config_values_missing_header_config_file():
    with pytest.raises(MissingSectionHeaderError):
        missing_header_config_file = os.path.join(TEST_DIR, 'fixtures',
                                                  'settings',
                                                  'no_header_settings.cfg')

        trailers.get_config_values(missing_header_config_file,
                                   SOME_CONFIG_DEFAULTS)
def test_get_config_values_no_config_file():
    missing_file_path = '/not/a/path/on/any/real/system/settings.cfg'
    settings = copy.deepcopy(SOME_CONFIG_DEFAULTS)
    settings['download_all_urls'] = []

    assert trailers.get_config_values(missing_file_path,
                                      SOME_CONFIG_DEFAULTS) == settings
def test_get_config_values_empty_config_file():
    empty_config_file = os.path.join(TEST_DIR, 'fixtures', 'settings',
                                     'empty_settings.cfg')
    settings = copy.deepcopy(SOME_CONFIG_DEFAULTS)
    settings['download_all_urls'] = []

    assert trailers.get_config_values(empty_config_file,
                                      SOME_CONFIG_DEFAULTS) == settings
def test_get_config_values_normal_config_file():
    empty_config_file = os.path.join(TEST_DIR, 'fixtures', 'settings',
                                     'normal_settings.cfg')
    config_values = {
        'download_dir': '~/Videos/trailers',
        'list_file': '~/Videos/download_list.txt',
        'resolution': '1080',
        'video_types': 'all',
        'output_level': 'error',
        'download_all_urls': [
            '/trailers/one',
            '/trailers/two',
        ]
    }

    assert trailers.get_config_values(empty_config_file,
                                      SOME_CONFIG_DEFAULTS) == config_values