-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from appliedAI-Initiative/add-missing-fileop-t…
…ests Add missing tests for `fs.exists()` and `fs.rm()`
- Loading branch information
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from lakefs_spec import LakeFSFileSystem | ||
from tests.util import RandomFileFactory | ||
|
||
|
||
def test_exists(fs: LakeFSFileSystem, repository: str) -> None: | ||
"""Test `fs.exists` on an existing file. Requires a populated repository.""" | ||
|
||
example_file = f"{repository}/main/README.md" | ||
assert fs.exists(example_file) | ||
|
||
nonexistent_file = f"{repository}/main/nonexistent.parquet" | ||
assert not fs.exists(nonexistent_file) | ||
|
||
|
||
def test_exists_on_staged_file( | ||
random_file_factory: RandomFileFactory, | ||
fs: LakeFSFileSystem, | ||
repository: str, | ||
temp_branch: str, | ||
) -> None: | ||
random_file = random_file_factory.make() | ||
|
||
lpath = str(random_file) | ||
rpath = f"{repository}/{temp_branch}/{random_file.name}" | ||
|
||
# upload, verify existence. | ||
fs.put(lpath, rpath) | ||
assert fs.exists(rpath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from lakefs_spec import LakeFSFileSystem | ||
|
||
|
||
def test_rm( | ||
fs: LakeFSFileSystem, | ||
repository: str, | ||
temp_branch: str, | ||
) -> None: | ||
path = f"{repository}/{temp_branch}/README.md" | ||
|
||
fs.rm(path) | ||
assert not fs.exists(path) | ||
|
||
|
||
def test_rm_with_postcommit( | ||
fs: LakeFSFileSystem, | ||
repository: str, | ||
temp_branch: str, | ||
) -> None: | ||
with fs.scope(postcommit=True): | ||
path = f"{repository}/{temp_branch}/README.md" | ||
|
||
fs.rm(path) | ||
assert not fs.exists(path) | ||
|
||
commits = fs.client.refs_api.log_commits( | ||
repository=repository, | ||
ref=temp_branch, | ||
) | ||
latest_commit = commits.results[0] | ||
assert latest_commit.message == "Remove file README.md" |