Feat: start testing fs_repository
This commit is contained in:
0
tests/repository/__init__.py
Normal file
0
tests/repository/__init__.py
Normal file
BIN
tests/repository/fs_examples/salary.pdf
Normal file
BIN
tests/repository/fs_examples/salary.pdf
Normal file
Binary file not shown.
Binary file not shown.
7
tests/repository/fs_examples/username.csv
Normal file
7
tests/repository/fs_examples/username.csv
Normal file
@@ -0,0 +1,7 @@
|
||||
Username; Identifier;First name;Last name
|
||||
booker12;9012;Rachel;Booker
|
||||
grey07;2070;Laura;Grey
|
||||
johnson81;4081;Craig;Johnson
|
||||
jenkins46;9346;Mary;Jenkins
|
||||
smith79;5079;Jamie;Smith
|
||||
|
||||
|
46
tests/repository/test_fs_repository.py
Normal file
46
tests/repository/test_fs_repository.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from dashboard.libs.repository.fs_repository import FSRepository
|
||||
|
||||
EXAMPLE_DIR = "./tests/repository/fs_examples/"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def location(tmp_path):
|
||||
loc = tmp_path
|
||||
username_loc = loc / "username"
|
||||
username_loc.mkdir()
|
||||
salary_loc = loc / "salary"
|
||||
salary_loc.mkdir()
|
||||
example_src = Path(EXAMPLE_DIR)
|
||||
|
||||
for f in example_src.glob("*"):
|
||||
if "username" in str(f):
|
||||
shutil.copy(f, username_loc)
|
||||
else:
|
||||
shutil.copy(f, salary_loc)
|
||||
|
||||
return loc
|
||||
|
||||
|
||||
def test_init(location):
|
||||
repo = FSRepository("example", location)
|
||||
assert repo.ls() == [
|
||||
"username",
|
||||
"salary",
|
||||
]
|
||||
assert repo.schemas() == [
|
||||
".",
|
||||
"username",
|
||||
"salary",
|
||||
]
|
||||
|
||||
assert repo.tables() == []
|
||||
assert repo.tables("username") == [
|
||||
"username.csv",
|
||||
"username-password-recovery-code.xlsx",
|
||||
]
|
||||
assert repo.tables("salary") == ["salary.pdf"]
|
||||
Reference in New Issue
Block a user