Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 23, 2024
1 parent 8ab53f3 commit f514ea4
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions packages/jupyter-ai/jupyter_ai/tests/test_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def common_cm_kwargs(config_path, schema_path):
"embeddings_provider_id": None,
"api_keys": None,
"fields": None,
}
},
}


Expand Down Expand Up @@ -103,6 +103,7 @@ def cm_with_allowlists(common_cm_kwargs):
}
return ConfigManager(**kwargs)


def cm_with_defaults(cm_kargs_with_defaults):
"""The default ConfigManager instance, with an empty config and config schema."""
return ConfigManager(**cm_kargs_with_defaults)
Expand Down Expand Up @@ -226,8 +227,9 @@ def test_init_with_allowlists(cm: ConfigManager, common_cm_kwargs):
assert test_cm.lm_gid == None
assert test_cm.em_gid == None


def test_init_with_default_values(
cm_with_defaults: ConfigManager, config_path: str, schema_path: str
cm_with_defaults: ConfigManager, config_path: str, schema_path: str
):
"""
Test that the ConfigManager initializes with the expected default values.
Expand All @@ -238,18 +240,25 @@ def test_init_with_default_values(
schema_path (str): The path to the schema file.
"""
config_response = cm_with_defaults.get_config()
#assert config response
# assert config response
assert config_response.model_provider_id == "bedrock-chat:anthropic.claude-v1"
assert config_response.embeddings_provider_id == "bedrock:amazon.titan-embed-text-v1"
assert (
config_response.embeddings_provider_id == "bedrock:amazon.titan-embed-text-v1"
)
assert config_response.api_keys == ["OPENAI_API_KEY"]
assert config_response.fields == {"bedrock-chat:anthropic.claude-v1":{"credentials_profile_name": "default","region_name": "us-west-2"}}
assert config_response.fields == {
"bedrock-chat:anthropic.claude-v1": {
"credentials_profile_name": "default",
"region_name": "us-west-2",
}
}

del cm_with_defaults

log = logging.getLogger()
lm_providers = get_lm_providers()
em_providers = get_em_providers()
cm_with_defaults_override =ConfigManager(
cm_with_defaults_override = ConfigManager(
log=log,
lm_providers=lm_providers,
em_providers=em_providers,
Expand All @@ -261,7 +270,7 @@ def test_init_with_default_values(


def test_init_with_default_values(
cm_with_defaults: ConfigManager, config_path: str, schema_path: str
cm_with_defaults: ConfigManager, config_path: str, schema_path: str
):
"""
Test that the ConfigManager initializes with the expected default values.
Expand All @@ -272,18 +281,25 @@ def test_init_with_default_values(
schema_path (str): The path to the schema file.
"""
config_response = cm_with_defaults.get_config()
#assert config response
# assert config response
assert config_response.model_provider_id == "bedrock-chat:anthropic.claude-v1"
assert config_response.embeddings_provider_id == "bedrock:amazon.titan-embed-text-v1"
assert (
config_response.embeddings_provider_id == "bedrock:amazon.titan-embed-text-v1"
)
assert config_response.api_keys == ["OPENAI_API_KEY"]
assert config_response.fields == {"bedrock-chat:anthropic.claude-v1":{"credentials_profile_name": "default","region_name": "us-west-2"}}
assert config_response.fields == {
"bedrock-chat:anthropic.claude-v1": {
"credentials_profile_name": "default",
"region_name": "us-west-2",
}
}

del cm_with_defaults

log = logging.getLogger()
lm_providers = get_lm_providers()
em_providers = get_em_providers()
cm_with_defaults_override =ConfigManager(
cm_with_defaults_override = ConfigManager(
log=log,
lm_providers=lm_providers,
em_providers=em_providers,
Expand All @@ -293,7 +309,10 @@ def test_init_with_default_values(
provider_defaults={"model_provider_id": "bedrock-chat:anthropic.claude-v2"},
)

assert cm_with_defaults_override.get_config().model_provider_id == "bedrock-chat:anthropic.claude-v2"
assert (
cm_with_defaults_override.get_config().model_provider_id
== "bedrock-chat:anthropic.claude-v2"
)


def test_init_with_default_values(
Expand Down

0 comments on commit f514ea4

Please sign in to comment.