Esempio n. 1
0
def test_read_credentials_file_no_section(mocked_bnc_config_path):
    remove_credentials_file()

    config_parser = get_config_parser()
    with open(get_bnc_config_filename_path('credentials'), 'w') as f:
        config_parser.write(f)

    with pytest.raises(ConfigException, match='api_credentials section cannot be found in credentials file'):
        read_credentials()
Esempio n. 2
0
def test_read_credentials_file_no_secret_option(mocked_bnc_config_path):
    config_parser = get_config_parser()
    config_parser.add_section('api_credentials')
    config_parser.set(CREDENTIALS_SECTION, 'BNC_CLI_API_KEY', 'MY_API_KEY')

    with open(get_bnc_config_filename_path('credentials'), 'w') as f:
        config_parser.write(f)

    with pytest.raises(ConfigException, match='BNC_CLI_SECRET_KEY cannot be found in credentials file'):
        read_credentials()

    remove_credentials_file()
Esempio n. 3
0
def test_read_credentials_file_is_ok(mocked_bnc_config_path):
    write_credentials_file('MY_API_KEY', 'MY_SECRET')
    result = read_credentials()

    assert isinstance(result, dict)
    assert result['api_key'] == 'MY_API_KEY'
    assert result['secret'] == 'MY_SECRET'

    remove_credentials_file()
Esempio n. 4
0
def test_read_credentials_file_not_found(mocked_bnc_config_path):
    with pytest.raises(ConfigException, match='Credentials file does not exists'):
        read_credentials()