Example #1
0
def test_set_and_get_config(mocker, cfg_params):
    # Mocking the global variable ``_config``.
    # The value of a global variable will affect other test cases.
    mocker.patch('ai.backend.client.config._config', None)
    cfg = APIConfig(**cfg_params)
    set_config(cfg)
    assert get_config() == cfg
Example #2
0
def test_set_and_get_config(mocker, cfg_params):
    # Mocking the global variable ``_config``.
    # The value of a global variable will affect other test cases.
    mocker.patch('ai.backend.client.config._config', None)
    cfg = APIConfig(**cfg_params)
    set_config(cfg)
    assert get_config() == cfg
Example #3
0
def defconfig():
    endpoint = os.environ.get('BACKEND_TEST_ENDPOINT', 'http://127.0.0.1:8081')
    access_key = os.environ.get('BACKEND_TEST_ADMIN_ACCESS_KEY',
                                'AKIAIOSFODNN7EXAMPLE')
    secret_key = os.environ.get('BACKEND_TEST_ADMIN_SECRET_KEY',
                                'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY')
    c = APIConfig(endpoint=endpoint, access_key=access_key, secret_key=secret_key)
    set_config(c)
    return c
Example #4
0
def userconfig():
    endpoint = os.environ.get('BACKEND_TEST_ENDPOINT', 'http://127.0.0.1:8081')
    access_key = os.environ.get('BACKEND_TEST_USER_ACCESS_KEY',
                                'AKIANABBDUSEREXAMPLE')
    secret_key = os.environ.get('BACKEND_TEST_USER_SECRET_KEY',
                                'C8qnIo29EZvXkPK_MXcuAakYTy4NYrxwmCEyNPlf')
    c = APIConfig(endpoint=endpoint, access_key=access_key, secret_key=secret_key)
    set_config(c)
    return c
Example #5
0
def defconfig():
    endpoint = os.environ.get('BACKEND_TEST_ENDPOINT', 'http://127.0.0.1:8081')
    access_key = os.environ.get('BACKEND_TEST_ADMIN_ACCESS_KEY',
                                'AKIAIOSFODNN7EXAMPLE')
    secret_key = os.environ.get('BACKEND_TEST_ADMIN_SECRET_KEY',
                                'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY')
    c = APIConfig(endpoint=endpoint,
                  access_key=access_key,
                  secret_key=secret_key)
    set_config(c)
    return c
Example #6
0
def userconfig():
    endpoint = os.environ.get('BACKEND_TEST_ENDPOINT', 'http://127.0.0.1:8081')
    access_key = os.environ.get('BACKEND_TEST_USER_ACCESS_KEY',
                                'AKIANABBDUSEREXAMPLE')
    secret_key = os.environ.get('BACKEND_TEST_USER_SECRET_KEY',
                                'C8qnIo29EZvXkPK_MXcuAakYTy4NYrxwmCEyNPlf')
    c = APIConfig(endpoint=endpoint,
                  access_key=access_key,
                  secret_key=secret_key)
    set_config(c)
    return c
def test_config(runner, monkeypatch, example_keypair, unused_tcp_port_factory):
    api_port = unused_tcp_port_factory()
    api_url = 'http://127.0.0.1:{}'.format(api_port)
    set_config(None)
    monkeypatch.setenv('BACKEND_ACCESS_KEY', example_keypair[0])
    monkeypatch.setenv('BACKEND_SECRET_KEY', example_keypair[1])
    monkeypatch.setenv('BACKEND_ENDPOINT', api_url)
    config = get_config()
    result = runner.invoke(main, ['config'])
    assert result.exit_code == 0
    assert str(config.endpoint) in result.output
    assert config.version in result.output
    assert config.access_key in result.output
    assert config.secret_key[:6] in result.output
    assert config.hash_type in result.output
Example #8
0
def defconfig():
    c = APIConfig(endpoint='http://127.0.0.1:8081',
                  access_key='AKIAIOSFODNN7EXAMPLE',
                  secret_key='wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY')
    set_config(c)
    return c