def forbidden_sim(): config = ServiceConfig() config.server = 'http://127.0.0.1:9000' config.workspace = 'forbidden' config.access_key = '1111' sim = MinimalSim(config) return sim
def unauthorized_sim(): config = ServiceConfig() config.server = 'http://127.0.0.1:9000' config.workspace = 'unauthorized' config.access_key = '1111' sim = MinimalSim(config) return sim
def minimal_sim(): config = ServiceConfig(argv=[__name__]) config.server = 'https://testingBonsaiPyClient.bons.ai' config.workspace = 'minimal_sim' config.access_key = '1111' sim = MinimalSim(config) return sim
def internal_server_err_sim(): config = ServiceConfig() config.server = 'http://127.0.0.1:9000' config.workspace = '500' config.access_key = '1111' sim = MinimalSim(config) return sim
def test_config_reads_args(): config = ServiceConfig(argv=[ __name__, '--accesskey', '111', '--api-host', 'host', '--workspace', 'test', '--sim-context', 'context', '--retry-timeout', '30' ]) assert config.access_key == '111' assert config.server == 'host' assert config.workspace == 'test' assert config.simulator_context == 'context' assert config.retry_timeout_seconds == 30
def test_config_reads_env_vars(): with patch.dict( 'os.environ', { 'SIM_ACCESS_KEY': '111', 'SIM_API_HOST': 'https://bonsai-api.com', 'SIM_WORKSPACE': '777', 'SIM_CONTEXT': 'TRAIN' }): config = ServiceConfig() assert config.access_key == '111' assert config.server == 'https://bonsai-api.com' assert config.workspace == '777'
def gateway_timeout_sim(): config = ServiceConfig() config.server = 'http://127.0.0.1:9000' config.workspace = 'gatewaytimeout' config.access_key = '1111' config.retry_timeout_seconds = 0 sim = MinimalSim(config) return sim
def do_not_retry_sim(): config = ServiceConfig(argv=[__name__]) config.server = 'https://testingBonsaiPyClient.bons.ai' config.workspace = 'no_retry' config.access_key = '1111' config.retry_timeout_seconds = 0 sim = MinimalSim(config) return sim
def test_default_config(): config = ServiceConfig() assert config.workspace == ''