Skip to content
Snippets Groups Projects
Commit d52549f3 authored by Stefano Zacchiroli's avatar Stefano Zacchiroli
Browse files

CLI: add test for swh identify w/o args

and user required=True to check that, as it is the preferred way
parent 7b2cc1fa
No related merge requests found
......@@ -159,7 +159,7 @@ def identify_object(obj_type, follow_symlinks, obj):
type=PidParamType(),
help="reference identifier to be compared with computed one",
)
@click.argument("objects", nargs=-1)
@click.argument("objects", nargs=-1, required=True)
def identify(obj_type, verify, show_filename, follow_symlinks, objects):
"""Compute the Software Heritage persistent identifier (SWHID) for the given
source code object(s).
......@@ -190,8 +190,6 @@ def identify(obj_type, verify, show_filename, follow_symlinks, objects):
swh:1:snp:510aa88bdc517345d258c1fc2babcd0e1f905e93 helloworld.git
""" # NoQA # overlong lines in shell examples are fine
if not objects:
raise click.UsageError("no object given")
if verify and len(objects) != 1:
raise click.BadParameter("verification requires a single object")
......
......@@ -26,6 +26,10 @@ class TestIdentify(DataMixin, unittest.TestCase):
self.assertEqual(result.exit_code, 0)
self.assertEqual(result.output.split()[0], pid)
def test_no_args(self):
result = self.runner.invoke(cli.identify)
self.assertNotEqual(result.exit_code, 0)
def test_content_id(self):
"""identify file content"""
self.make_contents(self.tmpdir_name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment