def __init__( self, *, auth: Optional[Tuple[str, str]] = None, should_validate_auth: bool = True, env: Environment = Environment.PROD, ): """Creates a Harmony Client that can be used to interact with Harmony. Args: auth : A tuple of the format ('edl_username', 'edl_password') should_validate_auth: Whether EDL credentials will be validated. """ self.config = Config(env) self.session = None self.auth = auth num_workers = int(self.config.NUM_REQUESTS_WORKERS) self.executor = ThreadPoolExecutor(max_workers=num_workers) if should_validate_auth: validate_auth(self.config, self._session())
def config(): return Config()
def test_config_from_env(mocker): expected_value = 'bar' mocker.patch('harmony.config.os.getenv', return_value=expected_value) config = Config() assert config.FOO == expected_value
def test_validation_url_matches_environment(env, url): config = Config(env) assert config.edl_validation_url == url
def test_harmony_hostname_matches_environment(env, url): config = Config(env) assert config.harmony_hostname == url
def test_config_built_in(): config = Config() assert config.NUM_REQUESTS_WORKERS is not None
def test_config_not_there(): config = Config() assert config.ASDF is None
def test_localhost_port_is_overridable(env, url): config = Config(env, localhost_port=9999) assert config.root_url == url
def test_root_url_matches_environment(env, url): config = Config(env) assert config.root_url == url
def test_url_scheme_matches_environment(env, url): config = Config(env) assert config.url_scheme == url