-
Notifications
You must be signed in to change notification settings - Fork 38
feat: add support for add and remove report scope #124
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
Open
smcgowan-smartsheet
wants to merge
11
commits into
smartsheet:mainline
Choose a base branch
from
smcgowan-smartsheet:mainline
base: mainline
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f5398a1
feat: add support for add and remove report scope
smcgowan-smartsheet 5be666b
feat: add support for add and remove report scope
smcgowan-smartsheet 7a3b6b7
feat: add support for add and remove report scope
smcgowan-smartsheet 4145bbb
feat: add support for add and remove report scope
smcgowan-smartsheet c42e77c
feat: add support for add and remove report scope
smcgowan-smartsheet cf38ef6
feat: add support for add and remove report scope
smcgowan-smartsheet e5a572b
feat: add support for add and remove report scope
smcgowan-smartsheet 11c2312
feat: add support for add and remove report scope
smcgowan-smartsheet 0811911
feat: add support for add and remove report scope
smcgowan-smartsheet dc21552
feat: add support for add and remove report scope
smcgowan-smartsheet f1f5f69
feat: add support for add and remove report scope
smcgowan-smartsheet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # pylint: disable=C0111,R0902,R0904,R0912,R0913,R0915,E1101 | ||
| # Smartsheet Python SDK. | ||
| # | ||
| # Copyright 2018 Smartsheet.com, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"): you may | ||
| # not use this file except in compliance with the License. You may obtain | ||
| # a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for the specific language governing permissions and limitations | ||
| # under the License. | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class ReportAssetType(str, Enum): | ||
| SHEET = 'SHEET' | ||
| WORKSPACE = 'WORKSPACE' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # pylint: disable=C0111,R0902,R0904,R0912,R0913,R0915,E1101 | ||
| # Smartsheet Python SDK. | ||
| # | ||
| # Copyright 2018 Smartsheet.com, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"): you may | ||
| # not use this file except in compliance with the License. You may obtain | ||
| # a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for the specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| from __future__ import absolute_import | ||
|
|
||
| from smartsheet.models.enums.report_asset_type import ReportAssetType | ||
|
|
||
| from ..types import EnumeratedValue, Number, json | ||
| from ..util import deserialize, serialize | ||
|
|
||
| class ReportScopeInclusion: | ||
|
|
||
| """Smartsheet ReportScopeInclusion data model.""" | ||
|
|
||
| def __init__(self, props=None, base_obj=None): | ||
| """Initialize the ReportScopeInclusion model.""" | ||
| self._base = None | ||
| if base_obj is not None: | ||
| self._base = base_obj | ||
|
|
||
| self._asset_type = EnumeratedValue(ReportAssetType) | ||
| self._asset_id = Number() | ||
|
|
||
| if props: | ||
| deserialize(self, props) | ||
|
|
||
| @property | ||
| def asset_id(self) -> int: | ||
| return self._asset_id.value | ||
|
|
||
| @asset_id.setter | ||
| def asset_id(self, value: int): | ||
| self._asset_id.value = value | ||
|
|
||
| @property | ||
| def asset_type(self) -> ReportAssetType: | ||
| return self._asset_type | ||
|
|
||
| @asset_type.setter | ||
| def asset_type(self, value: ReportAssetType): | ||
smcgowan-smartsheet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self._asset_type.set(value) | ||
|
|
||
| def to_dict(self) -> dict: | ||
| return serialize(self) | ||
|
|
||
| def to_json(self) -> str: | ||
| return json.dumps(self.to_dict()) | ||
|
|
||
| def __str__(self) -> str: | ||
| return self.to_json() | ||
smcgowan-smartsheet marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| TEST_SUCCESS_MESSAGE = "SUCCESS" | ||
| TEST_RESULT_CODE = 0 | ||
| TEST_SHEET_ID = 9876543210 | ||
| TEST_WORKSPACE_ID = 1122334455 | ||
| TEST_REPORT_ID = 2233445566 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import json | ||
| import uuid | ||
| from urllib.parse import urlparse | ||
|
|
||
| from smartsheet.models import Error | ||
| from smartsheet.models.enums.report_asset_type import ReportAssetType | ||
| from smartsheet.models.report_scope_inclusion import ReportScopeInclusion | ||
| from tests.mock_api.reports.common_test_constants import TEST_REPORT_ID, TEST_SHEET_ID, TEST_SUCCESS_MESSAGE, TEST_RESULT_CODE | ||
| from tests.mock_api.mock_api_test_helper import ( | ||
| get_mock_api_client, | ||
| get_wiremock_request, | ||
| ) | ||
|
|
||
|
|
||
| def test_add_report_scope_generated_url_is_correct(): | ||
| request_id = uuid.uuid4().hex | ||
| client = get_mock_api_client( | ||
| "/reports/add-report-scope/all-response-body-properties", request_id | ||
| ) | ||
|
|
||
| scopes = [ReportScopeInclusion({ | ||
| "assetId": TEST_SHEET_ID, "assetType": ReportAssetType.SHEET | ||
| } | ||
| )] | ||
|
|
||
| client.Reports.add_report_scope( | ||
| report_id=TEST_REPORT_ID, | ||
| scopes=scopes | ||
| ) | ||
|
|
||
| wiremock_request = get_wiremock_request(request_id) | ||
| url = urlparse(wiremock_request["absoluteUrl"]) | ||
| assert url.path == f'/2.0/reports/{TEST_REPORT_ID}/scope' | ||
| assert wiremock_request["method"] == "POST" | ||
|
|
||
| def test_add_report_scope_all_response_properties(): | ||
| request_id = uuid.uuid4().hex | ||
| client = get_mock_api_client( | ||
| "/reports/add-report-scope/all-response-body-properties", request_id | ||
| ) | ||
|
|
||
| scopes = [ReportScopeInclusion({ | ||
| "assetId": TEST_SHEET_ID, "assetType": ReportAssetType.SHEET | ||
| } | ||
| )] | ||
|
|
||
| response = client.Reports.add_report_scope( | ||
| report_id=TEST_REPORT_ID, | ||
| scopes=scopes | ||
| ) | ||
|
|
||
| assert response.message == TEST_SUCCESS_MESSAGE | ||
| assert response.result_code == TEST_RESULT_CODE | ||
|
|
||
| wiremock_request = get_wiremock_request(request_id) | ||
| body = json.loads(wiremock_request["body"]) | ||
| assert body == [{"assetId": TEST_SHEET_ID, "assetType": "SHEET"}] | ||
|
|
||
|
|
||
|
|
||
| def test_add_report_scope_error_4xx(): | ||
| request_id = uuid.uuid4().hex | ||
| client = get_mock_api_client( | ||
| "/errors/400-response", request_id | ||
| ) | ||
|
|
||
| scopes = [ReportScopeInclusion({ | ||
| "assetId": TEST_SHEET_ID, "assetType": ReportAssetType.SHEET | ||
| } | ||
| )] | ||
|
|
||
| response = client.Reports.add_report_scope( | ||
| report_id=TEST_REPORT_ID, | ||
| scopes=scopes | ||
| ) | ||
|
|
||
| assert isinstance(response, Error) | ||
|
|
||
|
|
||
| def test_add_report_scope_error_5xx(): | ||
| request_id = uuid.uuid4().hex | ||
| client = get_mock_api_client( | ||
| "/errors/500-response", request_id | ||
| ) | ||
|
|
||
| scopes = [ReportScopeInclusion({ | ||
| "assetId": TEST_SHEET_ID, "assetType": ReportAssetType.SHEET | ||
| } | ||
| )] | ||
|
|
||
| response = client.Reports.add_report_scope( | ||
| report_id=TEST_REPORT_ID, | ||
| scopes=scopes | ||
| ) | ||
|
|
||
| assert isinstance(response, Error) | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.