mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-09 11:28:14 +08:00
Add ArtifactNotFound exception
This commit is contained in:
@@ -6,6 +6,7 @@ from unittest.mock import patch
|
||||
import boto3
|
||||
from moto import mock_s3
|
||||
from optuna_dashboard.artifact.boto3 import Boto3Backend
|
||||
from optuna_dashboard.artifact.exceptions import ArtifactNotFound
|
||||
|
||||
|
||||
@mock_s3
|
||||
@@ -63,3 +64,8 @@ class Boto3BackendTestCase(TestCase):
|
||||
backend.remove(artifact_id)
|
||||
objects = self.s3_client.list_objects(Bucket=self.bucket_name).get("Contents", [])
|
||||
assert len([obj for obj in objects if obj["Key"] == artifact_id]) == 0
|
||||
|
||||
def test_file_not_found_exception(self) -> None:
|
||||
backend = Boto3Backend(self.bucket_name)
|
||||
with self.assertRaises(ArtifactNotFound):
|
||||
backend.open("not-found-id")
|
||||
|
||||
@@ -3,6 +3,7 @@ import tempfile
|
||||
from unittest import TestCase
|
||||
|
||||
from optuna_dashboard.artifact.file_system import FileSystemBackend
|
||||
from optuna_dashboard.artifact.exceptions import ArtifactNotFound
|
||||
|
||||
|
||||
class FileSystemBackendTestCase(TestCase):
|
||||
@@ -20,3 +21,10 @@ class FileSystemBackendTestCase(TestCase):
|
||||
with backend.open(artifact_id) as f:
|
||||
actual = f.read()
|
||||
self.assertEqual(actual, dummy_content)
|
||||
|
||||
def test_file_not_found(self) -> None:
|
||||
backend = FileSystemBackend(self.dir.name)
|
||||
with self.assertRaises(ArtifactNotFound):
|
||||
backend.open("not-found-id")
|
||||
with self.assertRaises(ArtifactNotFound):
|
||||
backend.remove("not-found-id")
|
||||
|
||||
Reference in New Issue
Block a user