def test_request_timeout_with_numeric_argument(requests_mock): timeout = 30 toml_config = config.Toml({}) expected_timeout = (http.DEFAULT_CONNECT_TIMEOUT, timeout) _assert_request_timeout(requests_mock, timeout, toml_config, expected_timeout)
def test_request_default_timeout_without_config(requests_mock): timeout = True toml_config = config.Toml({}) expected_timeout = http.DEFAULT_TIMEOUT _assert_request_timeout(requests_mock, timeout, toml_config, expected_timeout)
def test_request_default_timeout_with_config(requests_mock): timeout = 5 toml_config = config.Toml({'core': {'timeout': timeout}}) expected_timeout = (http.DEFAULT_CONNECT_TIMEOUT, timeout) _assert_request_timeout(requests_mock, timeout, toml_config, expected_timeout)
def test_is_request_to_dcos(): toml_config = config.Toml({'core': {'dcos_url': "https://example.com"}}) assert http._is_request_to_dcos("https://example.com/path", toml_config=toml_config) assert http._is_request_to_dcos("https://EXAMPLE.com/path", toml_config=toml_config) assert not http._is_request_to_dcos("https://foo.com/path", toml_config=toml_config)
def conf(): return config.Toml({ "core": { "dcos_url": "mock://test.cluster.mesos", "ssl_verify": "false", "dcos_acs_token": "im-a-fake-token" }, "cluster": { "name": "test-cluster" } })
def test_get_cluster_name_ignore_env(): with env(): os.environ['DCOS_CLUSTER_NAME'] = 'fake-name' cluster_conf = config.Toml({ 'cluster': {'name': 'real-name'}, }) cluster_name = config.get_config_val('cluster.name', cluster_conf) assert cluster_name == 'real-name'
def conf(): return config.Toml(_conf())
def test_get_partial_property(conf): conf['dcos'] == config.Toml({ 'user': '******', 'mesos_uri': 'zk://localhost/mesos' })
def test_request_timeout_with_tuple_argument(requests_mock): timeout = (5, 30) toml_config = config.Toml({}) _assert_request_timeout(requests_mock, timeout, toml_config, timeout)