-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add py.typed marker * Add Mypy to dev pipeline * Fix typing bugs * Extend interface to allow monkey patching original SecretsSettingsSource
- Loading branch information
Showing
9 changed files
with
145 additions
and
35 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest | ||
|
||
import pydantic_settings.main # import to monkeypatch | ||
from pydantic_file_secrets import FileSecretsSettingsSource | ||
|
||
|
||
@pytest.fixture | ||
def monkeypatch_settings(monkeypatch): | ||
monkeypatch.setattr( | ||
pydantic_settings.main, | ||
'SecretsSettingsSource', | ||
FileSecretsSettingsSource, | ||
) | ||
|
||
|
||
def test_dropin(settings_model, monkeypatch_settings, secrets_dir): | ||
secrets_dir.add_files( | ||
('dir1/key1', 'secret1'), | ||
('dir2/key2', 'secret2'), | ||
) | ||
|
||
class Settings(pydantic_settings.BaseSettings): | ||
key1: str | ||
key2: str | ||
|
||
conf = Settings(_secrets_dir=[secrets_dir / 'dir1', secrets_dir / 'dir2']) | ||
|
||
assert conf.key1 == 'secret1' | ||
assert conf.key2 == 'secret2' |