MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / load_config

Function load_config

tests/helpers.py:999–1079  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

997
998
999def load_config(): # noqa: C901
1000
1001 cluster_info = ClusterInformation()
1002 try:
1003 config = ConfigParser()
1004 config.read(CONFIG_FILE)
1005
1006 if config.getboolean('realserver', 'enabled'):
1007 cluster_info.real_server_enabled = True
1008 cluster_info.host = config.get('realserver', 'host')
1009 cluster_info.port = config.getint('realserver', 'port')
1010 cluster_info.admin_username = config.get(
1011 'realserver', 'admin_username')
1012 cluster_info.admin_password = config.get(
1013 'realserver', 'admin_password')
1014 cluster_info.bucket_name = config.get('realserver', 'bucket_name')
1015 cluster_info.bucket_password = config.get(
1016 'realserver', 'bucket_password')
1017
1018 mock_path = ''
1019 mock_url = ''
1020 mock_version = ''
1021 # @TODO(jc): allow override of log dir and filename
1022 # log_dir = ''
1023 # log_filename = ''
1024 if config.getboolean('gocaves', 'enabled'):
1025 if cluster_info.real_server_enabled:
1026 raise CouchbaseTestEnvironmentException(
1027 "Both real and mock servers cannot be enabled at the same time.")
1028
1029 cluster_info.mock_server_enabled = True
1030
1031 if config.has_option('gocaves', 'path'):
1032 mock_path = str(
1033 BASEDIR.joinpath(config.get('gocaves', 'path')))
1034 if config.has_option('gocaves', 'url'):
1035 mock_url = config.get('gocaves', 'url')
1036 if config.has_option('gocaves', 'version'):
1037 mock_version = config.get('gocaves', 'version')
1038
1039 cluster_info.mock_server = create_mock_server(MockServerType.GoCAVES,
1040 mock_path,
1041 mock_url,
1042 mock_version)
1043 cluster_info.bucket_name = "default"
1044 # cluster_info.port = cluster_info.mock_server.rest_port
1045 # cluster_info.host = "127.0.0.1"
1046 cluster_info.admin_username = "Administrator"
1047 cluster_info.admin_password = "password"
1048
1049 if config.has_section('legacymockserver') and config.getboolean('legacymockserver', 'enabled'):
1050 if cluster_info.real_server_enabled:
1051 raise CouchbaseTestEnvironmentException(
1052 "Both real and mock servers cannot be enabled at the same time.")
1053
1054 if cluster_info.mock_server_enabled:
1055 raise CouchbaseTestEnvironmentException(
1056 "Both java mock and gocaves mock cannot be enabled at the same time.")

Callers 1

couchbase_test_configFunction · 0.85

Calls 4

ClusterInformationClass · 0.85
create_mock_serverFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected