Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_cli.py
Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | def test_verify_content(self): | ||||
result = self.runner.invoke(cli.identify, ["--verify", expected_id, path]) | result = self.runner.invoke(cli.identify, ["--verify", expected_id, path]) | ||||
self.assertEqual(result.exit_code, 0) | self.assertEqual(result.exit_code, 0) | ||||
# mismatch | # mismatch | ||||
with open(path, "a") as f: | with open(path, "a") as f: | ||||
f.write("trailing garbage to make verification fail") | f.write("trailing garbage to make verification fail") | ||||
result = self.runner.invoke(cli.identify, ["--verify", expected_id, path]) | result = self.runner.invoke(cli.identify, ["--verify", expected_id, path]) | ||||
self.assertEqual(result.exit_code, 1) | self.assertEqual(result.exit_code, 1) | ||||
douardda: At least one test with non-ascii path is needed I'd say | |||||
def test_exclude(self): | |||||
"""exclude patterns""" | |||||
self.make_from_tarball(self.tmpdir_name) | |||||
path = os.path.join(self.tmpdir_name, b"sample-folder") | |||||
excluded_dir = os.path.join(path, b"excluded_dir\x96") | |||||
os.mkdir(excluded_dir) | |||||
with open(os.path.join(excluded_dir, b"some_file"), "w") as f: | |||||
f.write("content") | |||||
result = self.runner.invoke( | |||||
cli.identify, ["--type", "directory", "--exclude", "excluded_*", path] | |||||
) | |||||
self.assertSWHID(result, "swh:1:dir:e8b0f1466af8608c8a3fb9879db172b887e80759") |
At least one test with non-ascii path is needed I'd say