-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added potentially controversial support for using real keys in tests
- Loading branch information
1 parent
452e212
commit 2485da8
Showing
3 changed files
with
16 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
from modelgauge.secret_values import ( | ||
RawSecrets, | ||
RequiredSecret, | ||
SecretDescription, | ||
get_all_secrets, | ||
) | ||
from typing import Dict | ||
|
||
from modelgauge.config import load_secrets_from_config | ||
|
||
from modelgauge.secret_values import get_all_secrets, RawSecrets, RequiredSecret, SecretDescription | ||
|
||
|
||
class FakeRequiredSecret(RequiredSecret): | ||
@classmethod | ||
def description(cls) -> SecretDescription: | ||
return SecretDescription(scope="some-scope", key="some-key", instructions="some-instructions") | ||
|
||
|
||
def fake_all_secrets(value="some-value") -> RawSecrets: | ||
def fake_all_secrets(value="some-value", use_real_secrets_for: list[str] | None = None) -> RawSecrets: | ||
secrets = get_all_secrets() | ||
raw_secrets: Dict[str, Dict[str, str]] = {} | ||
real_secrets = load_secrets_from_config() | ||
|
||
for secret in secrets: | ||
if secret.scope not in raw_secrets: | ||
raw_secrets[secret.scope] = {} | ||
raw_secrets[secret.scope][secret.key] = value | ||
if use_real_secrets_for and secret.scope in use_real_secrets_for: | ||
raw_secrets[secret.scope][secret.key] = real_secrets[secret.scope][secret.key] | ||
else: | ||
raw_secrets[secret.scope][secret.key] = value | ||
|
||
return raw_secrets |