Handle blank database URLs#28
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that invoking the CLI without specifying a database URL fails fast, surfaces a clear error, and exits with a non-zero status.
- Adds validation in
config.initializeto raise an error ifurlis blank - Updates the CLI entrypoint to catch that error, print a message, and
sys.exit(1) - Introduces
test_no_urland adjusts the existing preference-order test intests/test_cli.py
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_cli.py | Added test_no_url and updated call count assertion in the settings-preference test |
| dslr/config.py | Added a blank-URL check that raises ValueError |
| dslr/cli.py | Catches the blank-URL error, prints it in red, and exits 1 |
Comments suppressed due to low confidence (2)
dslr/config.py:26
- Define and raise a more specific exception (e.g. MissingDatabaseUrlError) instead of the generic ValueError, so consumers can distinguish missing-URL errors from other configuration issues.
if not self.url:
tests/test_cli.py:261
- [nitpick] Consider adding a unit test directly against
config.initialize(url="", debug=False)to verify it raises the expected exception, improving coverage of the validation logic.
def test_no_url(self, mock_get_snapshots):
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #27