diff --git a/bookstore/bookstore_config.py b/bookstore/bookstore_config.py index 2cb7937..25e465d 100644 --- a/bookstore/bookstore_config.py +++ b/bookstore/bookstore_config.py @@ -36,3 +36,19 @@ class BookstoreSettings(LoggingConfigurable): 16, help="Maximum number of threads for the threadpool allocated for S3 read/writes", ).tag(config=True) + + +def validate_bookstore(settings: BookstoreSettings): + """Test for establishing that bookstore has been appropriately set up. + + Parameters + ---------- + settings: bookstore.bookstore_config.BookstoreSettings + The instantiated Settings object to be validated. + """ + valid_settings = [settings.workspace_prefix != "", + settings.published_prefix != "", + settings.s3_bucket != "", + settings.s3_endpoint_url != "", + ] + return all(valid_settings) diff --git a/bookstore/tests/test_bookstore_config.py b/bookstore/tests/test_bookstore_config.py index d63d9e6..0694010 100644 --- a/bookstore/tests/test_bookstore_config.py +++ b/bookstore/tests/test_bookstore_config.py @@ -1,6 +1,34 @@ """Tests for bookstore config""" import pytest +from bookstore.bookstore_config import BookstoreSettings, validate_bookstore -def test_bookstore_config(): - pass + +def test_validate_bookstore_defaults(): + """Tests that all bookstore validates with default values.""" + settings = BookstoreSettings() + assert validate_bookstore(settings) + + +def test_validate_bookstore_published(): + """Tests that bookstore does not validate with an empty published_prefix.""" + settings = BookstoreSettings(published_prefix="") + assert not validate_bookstore(settings) + + +def test_validate_bookstore_workspace(): + """Tests that bookstore does not validate with an empty workspace_prefix.""" + settings = BookstoreSettings(workspace_prefix="") + assert not validate_bookstore(settings) + + +def test_validate_bookstore_endpoint(): + """Tests that bookstore does not validate with an empty s3_endpoint_url.""" + settings = BookstoreSettings(s3_endpoint_url="") + assert not validate_bookstore(settings) + + +def test_validate_bookstore_bucket(): + """Tests that bookstore does not validate with an empty s3_bucket.""" + settings = BookstoreSettings(s3_bucket="") + assert not validate_bookstore(settings)