Skip to content

Commit

Permalink
Fix errors from flake8-pytest-style 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mildbyte committed Feb 3, 2023
1 parent 7edb0e9 commit e037a65
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions test/splitgraph/commands/test_external_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from splitgraph.exceptions import (
IncompleteObjectDownloadError,
IncompleteObjectUploadError,
ObjectCacheError,
)
from splitgraph.hooks.s3 import S3ExternalObjectHandler
from splitgraph.hooks.s3_server import (
Expand Down Expand Up @@ -108,6 +109,10 @@ def test_s3_push_pull(
)


class FlakyHandlerError(Exception):
pass


def _flaky_handler(incomplete=False):
class FlakyExternalObjectHandler(S3ExternalObjectHandler):
"""
Expand All @@ -124,7 +129,7 @@ def download_objects(self, objects, remote_engine):
Downloads just the first object and then fails.
"""
super().download_objects(objects[:1], remote_engine)
ex = Exception("Something bad happened.")
ex = FlakyHandlerError("Something bad happened.")
if incomplete:
raise IncompleteObjectDownloadError(reason=ex, successful_objects=[objects[0][0]])
else:
Expand All @@ -135,7 +140,7 @@ def upload_objects(self, objects, remote_engine):
Uploads just the first object and then fails.
"""
super().upload_objects(objects[:1], remote_engine)
ex = Exception("Something bad happened.")
ex = FlakyHandlerError("Something bad happened.")
if incomplete:
raise IncompleteObjectUploadError(
reason=ex, successful_objects=objects[:1], successful_object_urls=objects[:1]
Expand Down Expand Up @@ -163,7 +168,7 @@ def test_push_upload_error(
"splitgraph.hooks.external_objects._EXTERNAL_OBJECT_HANDLERS",
{"S3": _flaky_handler(incomplete=interrupted)},
):
with pytest.raises(Exception):
with pytest.raises(FlakyHandlerError):
PG_MNT.push(remote_repository=unprivileged_pg_repo, handler="S3", handler_options={})

assert head not in unprivileged_pg_repo.images
Expand Down Expand Up @@ -232,7 +237,7 @@ def test_pull_download_error(local_engine_empty, unprivileged_pg_repo, clean_min
"splitgraph.hooks.external_objects._EXTERNAL_OBJECT_HANDLERS",
{"S3": _flaky_handler(interrupted)},
):
with pytest.raises(Exception):
with pytest.raises(FlakyHandlerError if interrupted else ObjectCacheError):
clone(unprivileged_pg_repo, local_repository=PG_MNT, download_all=True)

# Check that the pull succeeded (repository registered locally) but the objects
Expand Down

0 comments on commit e037a65

Please sign in to comment.