Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_cli.py
Show All 31 Lines | def test_content_id(self): | ||||
self.make_contents(self.tmpdir_name) | self.make_contents(self.tmpdir_name) | ||||
for filename, content in self.contents.items(): | for filename, content in self.contents.items(): | ||||
path = os.path.join(self.tmpdir_name, filename) | path = os.path.join(self.tmpdir_name, filename) | ||||
result = self.runner.invoke(cli.identify, | result = self.runner.invoke(cli.identify, | ||||
['--type', 'content', path]) | ['--type', 'content', path]) | ||||
self.assertPidOK(result, | self.assertPidOK(result, | ||||
'swh:1:cnt:' + hash_to_hex(content['sha1_git'])) | 'swh:1:cnt:' + hash_to_hex(content['sha1_git'])) | ||||
def test_content_id_from_stdin(self): | |||||
"""identify file content""" | |||||
self.make_contents(self.tmpdir_name) | |||||
for _, content in self.contents.items(): | |||||
result = self.runner.invoke(cli.identify, | |||||
input=content['data']) | |||||
self.assertPidOK(result, | |||||
'swh:1:cnt:' + hash_to_hex(content['sha1_git'])) | |||||
def test_directory_id(self): | def test_directory_id(self): | ||||
"""identify an entire directory""" | """identify an entire directory""" | ||||
self.make_from_tarball(self.tmpdir_name) | self.make_from_tarball(self.tmpdir_name) | ||||
path = os.path.join(self.tmpdir_name, b'sample-folder') | path = os.path.join(self.tmpdir_name, b'sample-folder') | ||||
result = self.runner.invoke(cli.identify, | result = self.runner.invoke(cli.identify, | ||||
['--type', 'directory', path]) | ['--type', 'directory', path]) | ||||
self.assertPidOK(result, | self.assertPidOK(result, | ||||
'swh:1:dir:e8b0f1466af8608c8a3fb9879db172b887e80759') | 'swh:1:dir:e8b0f1466af8608c8a3fb9879db172b887e80759') | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |