Skip to content
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

add simple validate_bookstore function & tests (not traitlets validate) #44

Merged
merged 2 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bookstore/bookstore_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ 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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go ahead and add a simple docstring for the autodocs. Examples are in the papermill docs PR that is soon to merge. numpy format.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!

valid_settings = [settings.workspace_prefix != "",
settings.published_prefix != "",
settings.s3_bucket != "",
settings.s3_endpoint_url != "",
]
return all(valid_settings)
11 changes: 9 additions & 2 deletions bookstore/tests/test_bookstore_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
"""Tests for bookstore config"""
import pytest

from bookstore.bookstore_config import BookstoreSettings, validate_bookstore

def test_bookstore_config():
pass

def test_validate_bookstore_defaults():
settings = BookstoreSettings()
assert validate_bookstore(settings)

def test_validate_bookstore_endpoint():
settings2 = BookstoreSettings(s3_endpoint_url="")
assert not validate_bookstore(settings2)