-
Notifications
You must be signed in to change notification settings - Fork 5
Allow setup_credentials to work with selected dbs
#206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -83,6 +83,25 @@ def test_setup_credentials(mocker, config_): | |||||||||||||||||
| assert config_[db_name]["password"] == "test123!" | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| def test_setup_credentials_with_db_names_subset(mocker, config_): | ||||||||||||||||||
| mocker.patch.object(db, "check_credentials_are_valid", return_value=True) | ||||||||||||||||||
|
|
||||||||||||||||||
| os.environ["PYSTATIS_GENESIS_API_USERNAME"] = "test" | ||||||||||||||||||
| os.environ["PYSTATIS_GENESIS_API_PASSWORD"] = "test123!" | ||||||||||||||||||
|
|
||||||||||||||||||
| config.setup_credentials(db_names=["genesis"]) | ||||||||||||||||||
|
|
||||||||||||||||||
| # Only the specified DB should be set | ||||||||||||||||||
| assert config_["genesis"]["username"] == "test" | ||||||||||||||||||
| assert config_["genesis"]["password"] == "test123!" | ||||||||||||||||||
|
Comment on lines
+86
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This subset test can still pass if all DBs are configured.
Proposed fix def test_setup_credentials_with_db_names_subset(mocker, config_):
mocker.patch.object(db, "check_credentials_are_valid", return_value=True)
os.environ["PYSTATIS_GENESIS_API_USERNAME"] = "test"
os.environ["PYSTATIS_GENESIS_API_PASSWORD"] = "test123!"
+ os.environ.pop("PYSTATIS_ZENSUS_API_USERNAME", None)
+ os.environ.pop("PYSTATIS_ZENSUS_API_PASSWORD", None)
+ os.environ.pop("PYSTATIS_REGIO_API_USERNAME", None)
+ os.environ.pop("PYSTATIS_REGIO_API_PASSWORD", None)
config.setup_credentials(db_names=["genesis"])
- # Only the specified DB should be set
assert config_["genesis"]["username"] == "test"
assert config_["genesis"]["password"] == "test123!"
+ assert config_["zensus"]["username"] == ""
+ assert config_["zensus"]["password"] == ""
+ assert config_["regio"]["username"] == ""
+ assert config_["regio"]["password"] == ""🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| def test_setup_credentials_invalid_credentials_raises(mocker, config_): | ||||||||||||||||||
| mocker.patch.object(db, "check_credentials_are_valid", return_value=False) | ||||||||||||||||||
|
|
||||||||||||||||||
| with pytest.raises(KeyError) as _exc_info: | ||||||||||||||||||
| config.setup_credentials(db_names=["regio_s"]) | ||||||||||||||||||
|
Comment on lines
+99
to
+103
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test never reaches the invalid-credentials branch. With Suggested direction-def test_setup_credentials_invalid_credentials_raises(mocker, config_):
- mocker.patch.object(db, "check_credentials_are_valid", return_value=False)
-
- with pytest.raises(KeyError) as _exc_info:
- config.setup_credentials(db_names=["regio_s"])
+def test_setup_credentials_invalid_db_name_raises(config_):
+ with pytest.raises(KeyError):
+ config.setup_credentials(db_names=["regio_s"])Then add a separate test for the actual invalid-credentials path using a supported name such as 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| @pytest.mark.parametrize( | ||||||||||||||||||
| "mock_return, check_result", | ||||||||||||||||||
| [ | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.