-
Notifications
You must be signed in to change notification settings - Fork 96
Convert CLI tests to integration tests, increase overall test coverage, slight change to API url building logistics #385
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
Conversation
… remove ref to auth in example The orders API includes multiple api endpoints. They all begin with 'https://api.planet.com/' but then the relative paths are: 'compute/ops/stats/orders/v2/', 'compute/ops/orders/v2/', and 'compute/ops/bulk/orders/v2/'. The auth API endpoint begins with the same url and the relative path is 'v0/auth/'. Setting the base url for auth to 'https://api.planet.com/v0/auth/' makes sense for the auth client, but for the orders client we cannot use one of the relative paths for the base url. We could use `compute/ops` but that doesn't actually get us to the orders API endpoint. Backing off to just have the base url be 'https://api.planet.com/' seems less confusing than having the base url for the orders API be some portion of the full path to the endpoint and having the base url for the auth API be the full path.
…rls, reduce passing test coverage to 97%
tests/unit/test_cli_io.py
Outdated
@pytest.mark.parametrize( | ||
"pretty,expected", | ||
[(False, '{"key": "val"}'), (True, '{\n "key": "val"\n}')]) | ||
def test_cli_echo_json(pretty, expected, monkeypatch): | ||
mock_echo = Mock() | ||
monkeypatch.setattr(io.click, 'echo', mock_echo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreiberkyle what would you think about using mock.patch instead of pytest's monkeypatch?
@pytest.mark.parametrize( | |
"pretty,expected", | |
[(False, '{"key": "val"}'), (True, '{\n "key": "val"\n}')]) | |
def test_cli_echo_json(pretty, expected, monkeypatch): | |
mock_echo = Mock() | |
monkeypatch.setattr(io.click, 'echo', mock_echo) | |
@pytest.mark.parametrize( | |
"pretty,expected", | |
[(False, '{"key": "val"}'), (True, '{\n "key": "val"\n}')]) | |
@mock.patch('io.click.echo') | |
def test_cli_echo_json(mock_echo, pretty, expected, monkeypatch): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works beautifully with one change: patch uses the full path name to the module. (see paragraph discussing the target arg in the patch docs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one suggestion inline for using mock.patch instead of pytest.monkeypatch in the case where we're using mock.Mock.
Changes:
Closes #327