Refact: change method to access to schema an tables
This commit is contained in:
@@ -4,6 +4,7 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from plesna.datastore.fs_datacatalogue import FSDataCatalogue
|
||||
from plesna.models.storage import Schema
|
||||
|
||||
FIXTURE_DIR = Path(__file__).parent.parent / Path("./raw_datas/")
|
||||
|
||||
@@ -42,31 +43,19 @@ def test_init(location):
|
||||
|
||||
def test_list_schema(location):
|
||||
repo = FSDataCatalogue("example", location)
|
||||
assert {id: s.model_dump()["ref"]["id"] for id, s in repo.schemas().items()} == {
|
||||
".": ".",
|
||||
"username": "username",
|
||||
"salary": "salary",
|
||||
}
|
||||
assert {id: s.model_dump()["ref"]["value"] for id, s in repo.schemas().items()} == {
|
||||
".": ".",
|
||||
"username": "username",
|
||||
"salary": "salary",
|
||||
}
|
||||
assert {id: s.model_dump()["path"] for id, s in repo.schemas().items()} == {
|
||||
".": Path("."),
|
||||
"username": Path("username"),
|
||||
"salary": Path("salary"),
|
||||
}
|
||||
|
||||
assert repo.schemas == [".", "username", "salary"]
|
||||
assert repo.schema(".").ref == Schema(id=".", value=".")
|
||||
assert repo.schema("username").ref == Schema(id="username", value="username")
|
||||
|
||||
def test_list_tables(location):
|
||||
def test_list_tables_schema(location):
|
||||
repo = FSDataCatalogue("example", location)
|
||||
assert repo.tables() == {}
|
||||
assert {id: t.model_dump()["ref"]["value"] for id,t in repo.tables("username").items()} == {
|
||||
"username.csv": "username.csv",
|
||||
"username-password-recovery-code.xlsx": "username-password-recovery-code.xlsx",
|
||||
"username-password-recovery-code.xls": "username-password-recovery-code.xls",
|
||||
}
|
||||
assert {id: t.model_dump()["ref"]["value"] for id,t in repo.tables("salary").items()} == {
|
||||
"salary.pdf": "salary.pdf",
|
||||
}
|
||||
|
||||
assert repo.schema(".").tables == []
|
||||
assert repo.schema("username").tables == [
|
||||
'username.csv',
|
||||
'username-password-recovery-code.xlsx',
|
||||
'username-password-recovery-code.xls',
|
||||
]
|
||||
assert repo.schema("salary").tables == ["salary.pdf"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user