Exemple #1
0
    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())
Exemple #2
0
def config():
    return Config()
Exemple #3
0
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
Exemple #4
0
def test_validation_url_matches_environment(env, url):
    config = Config(env)

    assert config.edl_validation_url == url
Exemple #5
0
def test_harmony_hostname_matches_environment(env, url):
    config = Config(env)

    assert config.harmony_hostname == url
Exemple #6
0
def test_config_built_in():
    config = Config()
    assert config.NUM_REQUESTS_WORKERS is not None
Exemple #7
0
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
Exemple #10
0
def test_url_scheme_matches_environment(env, url):
    config = Config(env)

    assert config.url_scheme == url