Skip to content

Commit 356351f

Browse files
committed
Make archive_settings and published_settings, require valid s3_bucket
Also updates required version of pytest in accordance with advice in pytest-dev/pytest-asyncio#115 as needed for pytest-asyncio to use 'get_closest_marker'.
1 parent c3a88b5 commit 356351f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

bookstore/bookstore_config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def validate_bookstore(settings: BookstoreSettings):
7676
Existence of settings by category (general, archive, publish)
7777
"""
7878
general_settings = [settings.s3_bucket != "", settings.s3_endpoint_url != ""]
79-
archive_settings = [settings.workspace_prefix != ""]
80-
published_settings = [settings.published_prefix != ""]
79+
archive_settings = [*general_settings, settings.workspace_prefix != ""]
80+
published_settings = [*general_settings, settings.published_prefix != ""]
8181

8282
validation_checks = {
8383
"bookstore_valid": all(general_settings),

bookstore/tests/test_bookstore_config.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@
66

77
def test_validate_bookstore_defaults():
88
"""Tests that all bookstore validates with default values."""
9-
expected = {"bookstore_valid": False, "publish_valid": True, "archive_valid": True}
9+
expected = {"bookstore_valid": False, "publish_valid": False, "archive_valid": False}
1010
settings = BookstoreSettings()
1111
assert validate_bookstore(settings) == expected
1212

1313

1414
def test_validate_bookstore_published():
1515
"""Tests that bookstore does not validate with an empty published_prefix."""
16-
expected = {"bookstore_valid": False, "publish_valid": False, "archive_valid": True}
17-
settings = BookstoreSettings(published_prefix="")
16+
expected = {"bookstore_valid": True, "publish_valid": False, "archive_valid": True}
17+
settings = BookstoreSettings(s3_bucket="A_bucket", published_prefix="")
1818
assert validate_bookstore(settings) == expected
1919

2020

2121
def test_validate_bookstore_workspace():
2222
"""Tests that bookstore does not validate with an empty workspace_prefix."""
23-
expected = {"bookstore_valid": False, "publish_valid": True, "archive_valid": False}
24-
settings = BookstoreSettings(workspace_prefix="")
23+
expected = {"bookstore_valid": True, "publish_valid": True, "archive_valid": False}
24+
settings = BookstoreSettings(s3_bucket="A_bucket", workspace_prefix="")
2525
assert validate_bookstore(settings) == expected
2626

2727

2828
def test_validate_bookstore_endpoint():
2929
"""Tests that bookstore does not validate with an empty s3_endpoint_url."""
30-
expected = {"bookstore_valid": False, "publish_valid": True, "archive_valid": True}
30+
expected = {"bookstore_valid": False, "publish_valid": False, "archive_valid": False}
3131
settings = BookstoreSettings(s3_endpoint_url="")
3232
assert validate_bookstore(settings) == expected
3333

3434

3535
def test_validate_bookstore_bucket():
36-
"""Tests that bookstore does not validate with an empty s3_bucket."""
36+
"""Tests that all bookstore features validate with an s3_bucket."""
3737
expected = {"bookstore_valid": True, "publish_valid": True, "archive_valid": True}
3838
settings = BookstoreSettings(s3_bucket="A_bucket")
3939
assert validate_bookstore(settings) == expected

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ flake8
44
mock
55
mypy==0.660 # pin to avoid surprises
66
pre-commit
7-
pytest>=3.3
7+
pytest>=3.6
88
pytest-asyncio
99
pytest-cov
1010
pytest-mock

0 commit comments

Comments
 (0)