Skip to content

Commit

Permalink
Merge 0d96d56 into bc45658
Browse files Browse the repository at this point in the history
  • Loading branch information
touilleMan committed Feb 13, 2019
2 parents bc45658 + 0d96d56 commit 89c07e9
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions tests/core/fs/test_fs_idempotent_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def test_fs_online_idempotent_sync(
):
class FSOnlineIdempotentSync(TrioRuleBasedStateMachine):
BadPath = Bundle("bad_path")
GoodPath = Bundle("good_path")
GoodFilePath = Bundle("good_file_path")
GoodFolderPath = Bundle("good_folder_path")
GoodPath = st.one_of(GoodFilePath, GoodFolderPath)

async def start_fs(self, device):
async def _fs_controlled_cb(started_cb):
Expand Down Expand Up @@ -71,20 +73,25 @@ async def init(self):

return "/w/dummy"

@rule(
target=GoodPath,
path=st.sampled_from(
[
"/",
"/w",
"/w/good_file.txt",
"/w/good_folder/",
"/w/good_folder/good_sub_file.txt",
]
),
)
async def init_good_path(self, path):
return path
@initialize(target=GoodFolderPath)
async def init_good_folder_path_1(self):
return "/"

@initialize(target=GoodFolderPath)
async def init_good_folder_path_2(self):
return "/w/"

@initialize(target=GoodFolderPath)
async def init_good_folder_path_3(self):
return "/w/good_folder/"

@initialize(target=GoodFilePath)
async def init_good_file_path_1(self):
return "/w/good_file.txt"

@initialize(target=GoodFilePath)
async def init_good_file_path_2(self):
return "/w/good_folder/good_sub_file.txt"

@rule(target=BadPath, type=st_entry_type, bad_parent=BadPath, name=st_entry_name)
async def try_to_create_bad_path(self, type, bad_parent, name):
Expand Down Expand Up @@ -120,16 +127,16 @@ async def try_to_move_bad_src(self, src, dst_name):
with pytest.raises(OSError):
await self.fs.move(src, dst)

@rule(src=GoodPath, dst=GoodPath.filter(lambda x: x.endswith("/")))
@rule(src=GoodPath, dst=GoodFolderPath)
async def try_to_move_bad_dst(self, src, dst):
# TODO: why so much special cases ?
if src == dst and src != "/":
if src == dst and src not in ("/", "/w/"):
await self.fs.move(src, dst)
else:
with pytest.raises(OSError):
await self.fs.move(src, dst)

@rule(path=st.one_of(GoodPath))
@rule(path=GoodPath)
async def sync(self, path):
await self.fs.sync(path)

Expand Down

0 comments on commit 89c07e9

Please sign in to comment.