Skip to content

Commit

Permalink
update tests_checker
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-cq committed Dec 8, 2023
1 parent fe8c17d commit 61fd0db
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
23 changes: 17 additions & 6 deletions alist_sync/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

from alist_sync.alist_client import AlistClient

__all__ = ["AlistServer", "SyncDir", "CopyTask", "RemoveTask", "SyncJob", "Checker"]
__all__ = ["AlistServer", "SyncDir", "CopyTask",
"RemoveTask", "SyncJob", "Checker"]

CopyStatusModify = Literal["init", "created", "waiting", "getting src object", "", "running", "success"]
CopyStatusModify = Literal["init", "created", "waiting",
"getting src object", "", "running", "success"]


class AlistServer(BaseModel):
Expand Down Expand Up @@ -158,10 +160,19 @@ def checker(cls, *scanned_dirs):
scanned_dir.base_path
)
try:
_result[PurePosixPath(r_path)].setdefault(PurePosixPath(scanned_dir.base_path), item)
_result[PurePosixPath(r_path)].setdefault(
PurePosixPath(scanned_dir.base_path),
item
)
except KeyError:
_result[PurePosixPath(r_path)] = {PurePosixPath(scanned_dir.base_path): item}
return cls(mixmatrix=_result, cols=[PurePosixPath(t.base_path) for t in scanned_dirs])
_result[PurePosixPath(r_path)] = {
PurePosixPath(scanned_dir.base_path): item
}

return cls(
matrix=_result,
cols=[PurePosixPath(t.base_path) for t in scanned_dirs]
)

def model_dump_table(self):
""""""
Expand All @@ -188,5 +199,5 @@ def model_dump_table(self):

checker = Checker.checker(*[SyncDir(**s) for s in json.load(
Path(__file__).parent.parent.joinpath('tests/resource/SyncDirs.json').open())
])
])
checker.model_dump_table()
23 changes: 12 additions & 11 deletions tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@

import pytest

from alist_sync.models import SyncDir, CheckModel
from alist_sync.checker import Checker
from alist_sync.models import SyncDir, Checker

SUP_DIR = Path(__file__).parent.joinpath('resource')


@pytest.mark.parametrize(
"scanned_dirs",
[[SyncDir(**s) for s in json.load(SUP_DIR.joinpath('SyncDirs.json').open())]]
)
def test_checker(scanned_dirs):
checker = Checker(*scanned_dirs)
assert checker.result
# @pytest.mark.skip
# @pytest.mark.parametrize(
# "scanned_dirs",
# [[SyncDir(**s) for s in json.load(SUP_DIR.joinpath('SyncDirs.json').open())]]
# )
# def test_checker(scanned_dirs):
# checker = Checker(*scanned_dirs)
# assert checker.result


@pytest.mark.parametrize(
"scanned_dirs",
[[SyncDir(**s) for s in json.load(SUP_DIR.joinpath('SyncDirs.json').open())]]
)
def test_check(scanned_dirs):
checker = CheckModel.checker(*scanned_dirs)
assert checker.matrix
checker = Checker.checker(*scanned_dirs)
assert checker.matrix

0 comments on commit 61fd0db

Please sign in to comment.