Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dciclient/v1/shell_commands/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ def parse_arguments(args, environment={}):
p.add_argument("--limit", default=10)
p.add_argument("--offset", default=0)
p.add_argument("--query", help="Query language dsl", required=True)
_create_array_argument(p, "--includes", help="Comma separated list of fields to include.")
_create_array_argument(p, "--excludes", help="Comma separated list of fields to exclude.")
p.set_defaults(command="job-search")

p = subparsers.add_parser("job-show", help="Show a job.", parents=[base_parser])
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ def invoke_raw(arguments):
args = cli.parse_arguments(arguments, environment)
return dci_runner.run(context, args)

def invoke_parse(arguments):
environment = {}
return cli.parse_arguments(arguments, environment)

class Runner(object):
pass

Expand All @@ -245,6 +249,7 @@ class Runner(object):
runner.invoke_create_job = invoke_create_job
runner.invoke_find_latest_component = invoke_find_latest_component
runner.invoke_diff_jobs = invoke_diff_jobs
runner.invoke_parse = invoke_parse
return runner


Expand Down
5 changes: 4 additions & 1 deletion tests/shell_commands/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,8 @@ def test_job_search(mock_requests, runner_remoteci):
mock_requests.get.return_value = res_mock
res_mock.json.return_value = {"hits": "jobs"}
res_mock.status_code = 200
jobs = runner_remoteci.invoke_raw(["job-search", "--query=(name='lol')"])
jobs = runner_remoteci.invoke_raw(["job-search", "--query=(name='lol')", "--includes=name,team", "--excludes=api_secret,remoteci_id"])
assert jobs.json() == {"hits": "jobs"}
parsed_jobs = runner_remoteci.invoke_parse(["job-search", "--query=(name='lol')", "--includes=name,team", "--excludes=api_secret,remoteci_id"])
assert parsed_jobs.includes == ["name", "team"]
assert parsed_jobs.excludes == ["api_secret", "remoteci_id"]