Feat: start working on metadata_repository
This commit is contained in:
54
tests/storage/test_fs_metadata_repository.py
Normal file
54
tests/storage/test_fs_metadata_repository.py
Normal file
@@ -0,0 +1,54 @@
|
||||
from datetime import datetime
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from plesna.storage.metadata_repository.fs_metadata_repository import FSMetaDataRepository
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def location(tmp_path):
|
||||
catalogpath = tmp_path / "catalog"
|
||||
catalogpath.mkdir()
|
||||
|
||||
return catalogpath
|
||||
|
||||
|
||||
def test_init(location):
|
||||
repo = FSMetaDataRepository(location)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def metadata_repository(location) -> FSMetaDataRepository:
|
||||
return FSMetaDataRepository(location)
|
||||
|
||||
|
||||
def test_add_flux(location, metadata_repository):
|
||||
flux_id = "my_flux"
|
||||
metadata_repository.add_flux(flux_id)
|
||||
|
||||
metadata_filepath = location / metadata_repository.EXECUTION_FILEMODEL.format(flux_id=flux_id)
|
||||
assert metadata_filepath.exists()
|
||||
|
||||
with open(metadata_filepath, "r") as csvfile:
|
||||
content = csvfile.read()
|
||||
assert content == "datetime,output\n"
|
||||
|
||||
|
||||
def test_register_flux_execution(location, metadata_repository):
|
||||
flux_id = "my_flux"
|
||||
metadata_repository.add_flux(flux_id)
|
||||
|
||||
metadata_repository.register_flux_execution(
|
||||
flux_id,
|
||||
metadata={
|
||||
"datetime": datetime(2023, 3, 15, 14, 30),
|
||||
"output": {"data": {"truc": "machin"}},
|
||||
},
|
||||
)
|
||||
|
||||
metadata_filepath = location / metadata_repository.EXECUTION_FILEMODEL.format(flux_id=flux_id)
|
||||
with open(metadata_filepath, "r") as csvfile:
|
||||
content = csvfile.read()
|
||||
assert content == 'datetime,output\n1678887000.0,"{""data"":{""truc"":""machin""}}"\n'
|
||||
Reference in New Issue
Block a user