Exemplo n.º 1
0
def test_read_configuration_file_no_general_config_section(mocked_bnc_config_path):
    remove_configuration_file()

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

    with pytest.raises(ConfigException, match='general section cannot be found in configuration file'):
        read_configuration()

    remove_credentials_file()
Exemplo n.º 2
0
def test_read_configuration_file_no_api_info_section(mocked_bnc_config_path):
    remove_configuration_file()

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

    with pytest.raises(ConfigException, match='api_info section cannot be found in configuration file'):
        read_configuration()

    remove_credentials_file()
Exemplo n.º 3
0
def test_read_configuration_file_is_testnet_option_missing(mocked_bnc_config_path):
    config_parser = get_config_parser()
    config_parser.add_section(GENERAL_CONFIG_SECTION)
    config_parser.add_section(API_INFO_SECTION)

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

    with pytest.raises(ConfigException,
                       match='IS_TESTNET cannot be found in configuration file inside general section'):
        read_configuration()

    remove_configuration_file()
Exemplo n.º 4
0
def test_read_configuration_file_bnc_api_endpoint_option_missing(mocked_bnc_config_path):
    config_parser = get_config_parser()
    config_parser.add_section(GENERAL_CONFIG_SECTION)
    config_parser.add_section(API_INFO_SECTION)

    config_parser.set(GENERAL_CONFIG_SECTION, 'IS_TESTNET', 'no')
    config_parser.set(GENERAL_CONFIG_SECTION, 'BNC_CONFIG_PATH', '.bnc')

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

    with pytest.raises(ConfigException,
                       match='BNC_API_ENDPOINT cannot be found in configuration file inside api_info section'):
        read_configuration()

    remove_configuration_file()
Exemplo n.º 5
0
def test_read_configuration_file_is_ok(mocked_bnc_config_path):
    mocked_bnc_config_path.patch('bnc.utils.config.read_json_config_file', return_value={
        "is_testnet": False,
        "bnc_config_path": ".bnc",
        "bnc_api_endpoint": "https://api.binance.com"
    })

    write_configuration_file()
    config = read_configuration()

    assert config['is_testnet'] is False
    assert config['bnc_config_path'] == '.bnc'
    assert config['bnc_api_endpoint'] == 'https://api.binance.com'

    remove_configuration_file()
Exemplo n.º 6
0
def test_read_configuration_file_not_found(mocked_bnc_config_path):
    with pytest.raises(ConfigException, match='Configuration file does not exists'):
        read_configuration()