Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-24920: improve butler CLI mocking #244

Merged
merged 1 commit into from
May 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions tests/test_cliCmdTestIngest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import unittest

from lsst.daf.butler.cli import butler
from lsst.daf.butler.cli.utils import DAF_BUTLER_MOCK, verifyFunctionInfo
from lsst.daf.butler.cli.utils import Mocker, mockEnvVar


def makeExpectedKwargs(**kwargs):
Expand Down Expand Up @@ -55,15 +55,16 @@ def run_test(self, inputs, expectedKwargs):
The expected arguments to the ingestRaws command function, keys are
the argument name and values are the argument value.
"""
runner = click.testing.CliRunner(env=DAF_BUTLER_MOCK)
runner = click.testing.CliRunner(env=mockEnvVar)
result = runner.invoke(butler.cli, inputs)
self.assertEqual(result.exit_code, 0, f"output: {result.output} exception: {result.exception}")
verifyFunctionInfo(self, result.output, "ingestRaws", (), expectedKwargs)
Mocker.mock.assert_called_with(**expectedKwargs)

def test_repoAndOutput(self):
"""Test the most basic required arguments, repo and output run"""
expected = makeExpectedKwargs(repo="here", output_run="out")
self.run_test(["ingest-raws", "here", "--output-run", "out"], expected)
self.run_test(["ingest-raws", "here",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not necessary, but makes this test function look like the rest of the test functions in the suite, making it so that in the tuple of parameters each option+value is on a separate line (the first line is consistently a special case, subcommand+repo), which IMO is easier to read.

"--output-run", "out"], expected)

def test_configMulti(self):
"""Test config overrides"""
Expand Down