-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into python-blunderbuss
- Loading branch information
Showing
15 changed files
with
256 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
3 changes: 3 additions & 0 deletions
3
...ures/python_mono_repo/packages/google-cloud-asset/another_path/another_file.rst
This file contains 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,3 @@ | ||
First replacement | ||
First replacement | ||
Second replacement |
3 changes: 3 additions & 0 deletions
3
tests/fixtures/python_mono_repo/packages/google-cloud-asset/docs/index.rst
This file contains 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,3 @@ | ||
First replacement | ||
First replacement | ||
Second replacement |
20 changes: 20 additions & 0 deletions
20
...google-cloud-asset/scripts/client-post-processing/paths-must-be-for-the-same-package.yaml
This file contains 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,20 @@ | ||
description: Update docs/index.rst to show that a bot was here. | ||
url: N/A | ||
replacements: | ||
- paths: [ | ||
"packages/google-cloud-asset/docs/index.rst", | ||
"packages/google-cloud-asset/another_path/another_file.rst", | ||
# adding a path for a different package should cause an assertion error | ||
"packages/another-path/another_path/another_file.rst", | ||
] | ||
before: "First replacement" | ||
after: "Completed replacement 1." | ||
count: 4 | ||
- paths: ["packages/google-cloud-asset/docs/index.rst"] | ||
before: "Second replacement" | ||
after: "Completed replacement 2." | ||
count: 1 | ||
- paths: ["packages/some-other-asset/docs/index.rst"] | ||
before: "Does not exist" | ||
after: "Replacement does not exist" | ||
count: 1 |
3 changes: 3 additions & 0 deletions
3
.../python_mono_repo/packages/google-cloud-workflows/another_path/another_file.rst
This file contains 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,3 @@ | ||
First replacement | ||
First replacement | ||
Second replacement |
3 changes: 3 additions & 0 deletions
3
tests/fixtures/python_mono_repo/packages/google-cloud-workflows/docs/index.rst
This file contains 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,3 @@ | ||
First replacement | ||
First replacement | ||
Second replacement |
18 changes: 18 additions & 0 deletions
18
...packages/google-cloud-workflows/scripts/client-post-processing/update-docs-index-rst.yaml
This file contains 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,18 @@ | ||
description: Update docs/index.rst to show that a bot was here. | ||
url: N/A | ||
replacements: | ||
- paths: [ | ||
"packages/google-cloud-workflows/docs/index.rst", | ||
"packages/google-cloud-workflows/another_path/another_file.rst", | ||
] | ||
before: "First replacement" | ||
after: "Completed replacement 1." | ||
count: 4 | ||
- paths: ["packages/google-cloud-workflows/docs/index.rst"] | ||
before: "Second replacement" | ||
after: "Completed replacement 2." | ||
count: 1 | ||
- paths: ["packages/some-other-package/docs/index.rst"] | ||
before: "Does not exist" | ||
after: "Replacement does not exist" | ||
count: 1 |
20 changes: 20 additions & 0 deletions
20
...s/python_mono_repo/scripts/client-post-processing/paths-must-be-for-the-same-package.yaml
This file contains 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,20 @@ | ||
description: Update docs/index.rst to show that a bot was here. | ||
url: N/A | ||
replacements: | ||
- paths: [ | ||
"packages/google-cloud-asset/docs/index.rst", | ||
"packages/google-cloud-asset/another_path/another_file.rst", | ||
# adding a path for a different package should cause an assertion error | ||
"packages/another-path/another_path/another_file.rst", | ||
] | ||
before: "First replacement" | ||
after: "Completed replacement 1." | ||
count: 4 | ||
- paths: ["packages/google-cloud-asset/docs/index.rst"] | ||
before: "Second replacement" | ||
after: "Completed replacement 2." | ||
count: 1 | ||
- paths: ["packages/some-other-asset/docs/index.rst"] | ||
before: "Does not exist" | ||
after: "Replacement does not exist" | ||
count: 1 |
18 changes: 18 additions & 0 deletions
18
tests/fixtures/python_mono_repo/scripts/client-post-processing/update-docs-index-rst.yaml
This file contains 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,18 @@ | ||
description: Update docs/index.rst to show that a bot was here. | ||
url: N/A | ||
replacements: | ||
- paths: [ | ||
"packages/google-cloud-workflows/docs/index.rst", | ||
"packages/google-cloud-workflows/another_path/another_file.rst", | ||
] | ||
before: "First replacement" | ||
after: "Completed replacement 1." | ||
count: 4 | ||
- paths: ["packages/google-cloud-workflows/docs/index.rst"] | ||
before: "Second replacement" | ||
after: "Completed replacement 2." | ||
count: 1 | ||
- paths: ["packages/some-other-package/docs/index.rst"] | ||
before: "Does not exist" | ||
after: "Replacement does not exist" | ||
count: 1 |
This file contains 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,60 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# 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 | ||
# | ||
# https://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 pathlib import Path | ||
import pytest | ||
|
||
from synthtool.languages import python_mono_repo | ||
from . import util | ||
|
||
|
||
TEST_FIXTURE_DIR = Path(__file__).parent / "fixtures" / "python_mono_repo" | ||
|
||
|
||
def test_apply_workaround(): | ||
with util.copied_fixtures_dir(TEST_FIXTURE_DIR): | ||
docs_index_rst = Path( | ||
"packages/google-cloud-workflows/docs/index.rst" | ||
).read_text() | ||
assert ( | ||
docs_index_rst | ||
== "First replacement\nFirst replacement\nSecond replacement\n" | ||
) | ||
python_mono_repo.apply_client_specific_post_processing( | ||
"packages/google-cloud-workflows/scripts/client-post-processing", | ||
"google-cloud-workflows", | ||
) | ||
docs_index_rst = Path( | ||
"packages/google-cloud-workflows/docs/index.rst" | ||
).read_text() | ||
assert ( | ||
docs_index_rst | ||
== "Completed replacement 1.\nCompleted replacement 1.\nCompleted replacement 2.\n" | ||
) | ||
|
||
# Confirm that `AssertionError`` is raised if you run the post processing more than once | ||
# because the replacement should only occur once. | ||
with pytest.raises(AssertionError): | ||
python_mono_repo.apply_client_specific_post_processing( | ||
"packages/google-cloud-workflows/scripts/client-post-processing", | ||
"google-cloud-workflows", | ||
) | ||
|
||
# Confirm that `AssertionError`` is raised if | ||
# there is a replacement is defined for multiple packages. | ||
# Each path in replacement["paths"] should only be for a single package. | ||
with pytest.raises(AssertionError): | ||
python_mono_repo.apply_client_specific_post_processing( | ||
"packages/google-cloud-asset/scripts/client-post-processing", | ||
"google-cloud-asset", | ||
) |