Implement user API for Artifacts

This commit is contained in:
c-bata
2023-01-14 00:22:38 +09:00
parent 29233909a2
commit ded0200904
6 changed files with 196 additions and 3 deletions
+22
View File
@@ -0,0 +1,22 @@
import io
import tempfile
from unittest import TestCase
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)