Skip to content

Commit

Permalink
fixing typo, adding test hidden files
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed May 27, 2023
1 parent d7df450 commit ba36160
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
2 changes: 1 addition & 1 deletion shelephant/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ def update(args: list[str]):

with search.cwd(sdir / ".."):
for f in rm_links:
if f.exists():
if f.is_symlink():
f.unlink()

unmanage = []
Expand Down
54 changes: 48 additions & 6 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,14 @@ def test_basic(self):
s2 = create_dummy_files(["a.txt", "b.txt"])
s2 += create_dummy_files(["e.txt", "f.txt"], slice(6, None, None))

with cwd(dataset), contextlib.redirect_stdout(io.StringIO()) as sio:
with cwd(dataset):
shelephant.dataset.init([])
shelephant.dataset.add(["source1", "../source1", "--rglob", "*.txt", "-q"])
shelephant.dataset.add(["source2", "../source2", "--rglob", "*.txt", "-q"])
shelephant.dataset.remove(["source2"])
shelephant.dataset.add(["source2", "../source2", "--rglob", "*.txt", "-q"])

with cwd(dataset), contextlib.redirect_stdout(io.StringIO()) as sio:
shelephant.dataset.status(["--table", "PLAIN_COLUMNS"])

expect = [
Expand Down Expand Up @@ -308,12 +310,14 @@ def test_basic_ssh(self):
s2 = create_dummy_files(["a.txt", "b.txt"])
s2 += create_dummy_files(["e.txt", "f.txt"], slice(6, None, None))

with cwd(dataset), contextlib.redirect_stdout(io.StringIO()) as sio:
with cwd(dataset):
shelephant.dataset.init([])
shelephant.dataset.add(["source1", "../source1", "--rglob", "*.txt", "-q"])
shelephant.dataset.add(
["source2", str(source2), "--ssh", "localhost", "--rglob", "*.txt", "-q"]
)

with cwd(dataset), contextlib.redirect_stdout(io.StringIO()) as sio:
shelephant.dataset.status(["--table", "PLAIN_COLUMNS"])

expect = [
Expand Down Expand Up @@ -443,7 +447,7 @@ def test_basic_ssh_mount(self):
s2 = create_dummy_files(["a.txt", "b.txt"])
s2 += create_dummy_files(["e.txt", "f.txt"], slice(6, None, None))

with cwd(dataset), contextlib.redirect_stdout(io.StringIO()) as sio:
with cwd(dataset):
shelephant.dataset.init([])
shelephant.dataset.add(["source1", "../source1", "--rglob", "*.txt", "-q"])
shelephant.dataset.add(
Expand All @@ -459,6 +463,8 @@ def test_basic_ssh_mount(self):
"-q",
]
)

with cwd(dataset), contextlib.redirect_stdout(io.StringIO()) as sio:
shelephant.dataset.status(["--table", "PLAIN_COLUMNS"])

expect = [
Expand Down Expand Up @@ -643,13 +649,15 @@ def test_shallow(self):
with cwd(source3):
create_dummy_files(["g.txt"], slice(8, None, None))

with cwd(dataset), contextlib.redirect_stdout(io.StringIO()) as sio:
with cwd(dataset):
shelephant.dataset.init([])
shelephant.dataset.add(["source1", "../source1", "--rglob", "*.txt", "-q"])
shelephant.dataset.add(["source2", "../source2", "--rglob", "*.txt", "-q"])
shelephant.dataset.add(
["source3", "../source3", "--rglob", "*.txt", "--shallow", "-q"]
)

with cwd(dataset), contextlib.redirect_stdout(io.StringIO()) as sio:
shelephant.dataset.status(["--table", "PLAIN_COLUMNS"])

expect = [
Expand Down Expand Up @@ -809,7 +817,41 @@ def test_prefix(self):
pathlib.Path(os.path.realpath("f.txt")).parent.parent.name, "source2"
)

def test_git(self):
def test_hidden(self):
with tempdir():
dataset = pathlib.Path("dataset")
source1 = pathlib.Path("source1")
source2 = pathlib.Path("source2")

dataset.mkdir()
source1.mkdir()
source2.mkdir()

with cwd(source1):
files = [".a.txt", "b.txt", "c.txt", "d.txt"]
create_dummy_files(files)

with cwd(source2):
create_dummy_files([".a.txt", "b.txt"])

with cwd(dataset):
shelephant.dataset.init([])
shelephant.dataset.add(["source1", "../source1", "--rglob", "*.txt", "-q"])
shelephant.dataset.add(["source2", "../source2", "--rglob", "*.txt", "-q"])

with cwd(dataset), contextlib.redirect_stdout(io.StringIO()) as sio:
shelephant.dataset.status(["--table", "PLAIN_COLUMNS"])

expect = [
".a.txt source1 == ==",
"b.txt source1 == ==",
"c.txt source1 == x",
"d.txt source1 == x",
]
ret = _plain(sio.getvalue())[1:]
self.assertEqual(ret, expect)

def test_lock(self):
with tempdir():
dataset = pathlib.Path("dataset")
source1 = pathlib.Path("source1")
Expand All @@ -826,7 +868,7 @@ def test_git(self):
with cwd(source2):
s2 = create_dummy_files(["a.txt", "b.txt"])

with cwd(dataset), contextlib.redirect_stdout(io.StringIO()) as sio:
with cwd(dataset):
shelephant.dataset.init([])
shelephant.dataset.add(["source1", "../source1", "--rglob", "*.txt", "-q"])
shelephant.dataset.add(
Expand Down

0 comments on commit ba36160

Please sign in to comment.