-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4bda82
commit ff68e56
Showing
2 changed files
with
48 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
|
||
from core.config import CannotLoadConfiguration | ||
from core.service.storage.configuration import StorageConfiguration | ||
|
||
|
||
def test_region_validation_fail(): | ||
with pytest.raises(CannotLoadConfiguration) as exc_info: | ||
StorageConfiguration(region="foo bar baz") | ||
|
||
assert "PALACE_STORAGE_REGION: Invalid region: foo bar baz." in str(exc_info.value) | ||
|
||
|
||
def test_region_validation_success(): | ||
configuration = StorageConfiguration(region="us-west-2") | ||
assert configuration.region == "us-west-2" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url", | ||
[ | ||
"http://localhost:9000", | ||
"https://real.endpoint.com", | ||
"http://192.168.0.1", | ||
], | ||
) | ||
def test_endpoint_url_validation_success(url: str): | ||
configuration = StorageConfiguration(endpoint_url=url) | ||
assert configuration.endpoint_url == url | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url, error", | ||
[ | ||
("ftp://localhost:9000", "URL scheme not permitted"), | ||
("foo bar baz", "invalid or missing URL scheme"), | ||
], | ||
) | ||
def test_endpoint_url_validation_fail(url: str, error: str): | ||
with pytest.raises(CannotLoadConfiguration) as exc_info: | ||
StorageConfiguration(endpoint_url=url) | ||
|
||
assert "PALACE_STORAGE_ENDPOINT_URL" in str(exc_info.value) | ||
assert error in str(exc_info.value) |