Skip to content

Commit

Permalink
Merge pull request #1831 from MVrachev/small-tests
Browse files Browse the repository at this point in the history
Add missing small tests
  • Loading branch information
lukpueh authored Feb 8, 2022
2 parents efc6877 + 6db3f69 commit c7da199
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,13 @@ def test_targetfile_from_file(self) -> None:
with self.assertRaises(ValueError):
TargetFile.from_file(file_path, file_path, ["123"])

def test_targetfile_custom(self) -> None:
# Test creating TargetFile and accessing custom.
targetfile = TargetFile(
100, {"sha256": "abc"}, "file.txt", {"custom": "foo"}
)
self.assertEqual(targetfile.custom, "foo")

def test_targetfile_from_data(self) -> None:
data = b"Inline test content"
target_file_path = os.path.join(
Expand Down
1 change: 1 addition & 0 deletions tests/test_metadata_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def test_invalid_root_serialization(self, test_case_data: str) -> None:

invalid_metafiles: utils.DataSet = {
"wrong length type": '{"version": 1, "length": "a", "hashes": {"sha256" : "abc"}}',
"version 0": '{"version": 0, "length": 1, "hashes": {"sha256" : "abc"}}',
"length 0": '{"version": 1, "length": 0, "hashes": {"sha256" : "abc"}}',
"length below 0": '{"version": 1, "length": -1, "hashes": {"sha256" : "abc"}}',
"empty hashes dict": '{"version": 1, "length": 1, "hashes": {}}',
Expand Down

0 comments on commit c7da199

Please sign in to comment.