Пример #1
0
def test_config_missing(tmpdir, errmsg):
    """Check behavior on missing config values."""
    f = tmpdir.join('config.ini')
    f.write('''
[walls]
api_secret = myapisecret
image_dir = {0}
width = 1920
height = 1080
    '''.format(tmpdir))
    with errmsg("Missing config keys: 'api_key', 'tags'\n"):
        walls.load_config(str(f))
Пример #2
0
def test_config_types(tmpdir, errmsg):
    """Check behavior on missing config values."""
    f = tmpdir.join('config.ini')
    f.write('''
[walls]
api_key = myapikey
api_secret = myapisecret
tags = sanfrancisco
image_dir = {0}
width = abc
height = def
    '''.format(tmpdir))
    with errmsg("The following must be integers: 'width', 'height'\n"):
        walls.load_config(str(f))
Пример #3
0
def test_config_dest(tmpdir, errmsg):
    """Nonexistent destination directory."""
    cfg = '''
[walls]
api_key = myapikey
api_secret = myapisecret
tags = sanfrancisco
image_dir = {0}
width = 1920
height = 1080
    '''

    f = tmpdir.join('config1.ini')
    f.write(cfg.format('/does/not/exist'))
    with errmsg('The directory /does/not/exist does not exist.\n'):
        walls.load_config(str(f))

    f = tmpdir.join('config2.ini')
    f.write(cfg.format(f))
    with errmsg('The directory {0} does not exist.\n'.format(f)):
        walls.load_config(str(f))
Пример #4
0
def test_config_no_walls(tmpdir, errmsg):
    """Check for missing [walls] section."""
    f = tmpdir.join('config.ini')
    f.write('\n')
    with errmsg('Config missing [walls] section.\n'):
        walls.load_config(str(f))
Пример #5
0
def test_invalid_config(errmsg):
    """Make sure an error is raised if the config file can't be read."""
    with errmsg("Couldn't load config fake.ini\n"):
        walls.load_config('fake.ini')
Пример #6
0
def test_supplied_config(config):
    """Test a config file passed as a command line argument."""
    cfg = walls.load_config(config)
    assert cfg.get('walls', 'api_key') == 'myapikey'