mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-11 12:30:25 +08:00
Add exponential backoff middleware for ArtifactBackend
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import io
|
||||
import tempfile
|
||||
from unittest import TestCase
|
||||
|
||||
from optuna_dashboard.artifact.exceptions import ArtifactNotFound
|
||||
from optuna_dashboard.artifact.file_system import FileSystemBackend
|
||||
|
||||
|
||||
class FileSystemBackendTestCase(TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.dir = tempfile.TemporaryDirectory()
|
||||
|
||||
def tearDown(self) -> None:
|
||||
self.dir.cleanup()
|
||||
|
||||
def test_upload_download(self) -> None:
|
||||
artifact_id = "dummy-uuid"
|
||||
dummy_content = b"Hello World"
|
||||
backend = FileSystemBackend(self.dir.name)
|
||||
backend.write(artifact_id, io.BytesIO(dummy_content))
|
||||
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