Skip to content

Commit

Permalink
Temporily xfail local remote storage test
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldk authored and jikanter committed Mar 29, 2024
1 parent 9f96b81 commit cc72da2
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions spacy/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,67 @@ def test_applycli_user_data():
assert result[0]._.ext == val


# TODO: remove this xfail after merging master into v4. The issue
# is that for local files, pathy started returning os.stat_result,
# which doesn't have a last_modified property. So, recency-sorting
# fails and the test fails. However, once we merge master into
# v4, we'll use weasel, which in turn uses cloudpathlib, which
# should resolve this issue.
@pytest.mark.xfail(reason="Recency sorting is broken on some platforms")
def test_local_remote_storage():
with make_tempdir() as d:
filename = "a.txt"

content_hashes = ("aaaa", "cccc", "bbbb")
for i, content_hash in enumerate(content_hashes):
# make sure that each subsequent file has a later timestamp
if i > 0:
time.sleep(1)
content = f"{content_hash} content"
loc_file = d / "root" / filename
if not loc_file.parent.exists():
loc_file.parent.mkdir(parents=True)
with loc_file.open(mode="w") as file_:
file_.write(content)

# push first version to remote storage
remote = RemoteStorage(d / "root", str(d / "remote"))
remote.push(filename, "aaaa", content_hash)

# retrieve with full hashes
loc_file.unlink()
remote.pull(filename, command_hash="aaaa", content_hash=content_hash)
with loc_file.open(mode="r") as file_:
assert file_.read() == content

# retrieve with command hash
loc_file.unlink()
remote.pull(filename, command_hash="aaaa")
with loc_file.open(mode="r") as file_:
assert file_.read() == content

# retrieve with content hash
loc_file.unlink()
remote.pull(filename, content_hash=content_hash)
with loc_file.open(mode="r") as file_:
assert file_.read() == content

# retrieve with no hashes
loc_file.unlink()
remote.pull(filename)
with loc_file.open(mode="r") as file_:
assert file_.read() == content


def test_local_remote_storage_pull_missing():
# pulling from a non-existent remote pulls nothing gracefully
with make_tempdir() as d:
filename = "a.txt"
remote = RemoteStorage(d / "root", str(d / "remote"))
assert remote.pull(filename, command_hash="aaaa") is None
assert remote.pull(filename) is None


def test_cli_find_threshold(capsys):
def make_examples(nlp: Language) -> List[Example]:
docs: List[Example] = []
Expand Down

0 comments on commit cc72da2

Please sign in to comment.