Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-model
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Dandrimont
swh-model
Commits
d52549f3
Commit
d52549f3
authored
4 years ago
by
Stefano Zacchiroli
Browse files
Options
Downloads
Patches
Plain Diff
CLI: add test for swh identify w/o args
and user required=True to check that, as it is the preferred way
parent
7b2cc1fa
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/model/cli.py
+1
-3
1 addition, 3 deletions
swh/model/cli.py
swh/model/tests/test_cli.py
+4
-0
4 additions, 0 deletions
swh/model/tests/test_cli.py
with
5 additions
and
3 deletions
swh/model/cli.py
+
1
−
3
View file @
d52549f3
...
...
@@ -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
"
)
...
...
This diff is collapsed.
Click to expand it.
swh/model/tests/test_cli.py
+
4
−
0
View file @
d52549f3
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment