Exemplo n.º 1
0
def test_user_missing(configure_with, base_config):
    del base_config['user']
    config_file = configure_with(base_config)
    with pytest.raises(ValueError) as ei:
        load(config_file)
    assert str(ei.value) == "No user found in the configuration."
Exemplo n.º 2
0
def test_token_wrong_token_type(configure_with, base_config):
    base_config['token'] = 'xoxo'
    config_file = configure_with(base_config)
    with pytest.raises(ValueError) as ei:
        load(config_file)
    assert str(ei.value) == "The token does not appear to be a bot token."
Exemplo n.º 3
0
def test_token(configure_with, base_config):
    config_file = configure_with(base_config)
    config = load(config_file)
    assert config.token == base_config['token']
Exemplo n.º 4
0
def test_token_wrong_data_type(configure_with, base_config):
    base_config['token'] = 2
    config_file = configure_with(base_config)
    with pytest.raises(ValueError) as ei:
        load(config_file)
    assert str(ei.value) == "The token must be a string, found a int."
Exemplo n.º 5
0
def test_missing_file():
    with pytest.raises(FileNotFoundError):
        load('foo.bar')
Exemplo n.º 6
0
def test_list_configuration(configure_with):
    config_file = configure_with([])
    with pytest.raises(ValueError) as ei:
        load(config_file)
    assert str(ei.value) == "Configuration must be a dictionary, found a list."
Exemplo n.º 7
0
def test_empty_configuration(configure_with):
    config_file = configure_with(None)
    with pytest.raises(ValueError) as ei:
        load(config_file)
    assert str(
        ei.value) == "Configuration must be a dictionary, found a NoneType."
Exemplo n.º 8
0
def test_malformed_config(config_file):
    config_file.write_text(':')
    with pytest.raises(yaml.YAMLError):
        load(config_file)
Exemplo n.º 9
0
def test_unreadable_config(config_file):
    config_file.touch(0o0200)
    with pytest.raises(PermissionError):
        load(config_file)
Exemplo n.º 10
0
def test_user(configure_with, base_config):
    config_file = configure_with(base_config)
    config = load(config_file)
    assert config.user == base_config['user']