From 56ccbfc5058cb930771054285be42bb56efc0009 Mon Sep 17 00:00:00 2001 From: Sushmitha Venugopal <88627924+SushTP@users.noreply.github.com> Date: Tue, 10 Aug 2021 16:47:49 +0530 Subject: [PATCH 1/4] Update changesummary_test.py --- changesummary_test.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/changesummary_test.py b/changesummary_test.py index cbc4ff0..f05667b 100644 --- a/changesummary_test.py +++ b/changesummary_test.py @@ -2,16 +2,7 @@ # # 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. - +# You may obta """ChangeSummary tests.""" __author__ = "partheniou@google.com (Anthonios Partheniou)" @@ -83,17 +74,7 @@ def test_load_json_to_dataframe_returns_expected_data(self): self.assertEqual(df["name"].iloc[0], "drive") self.assertEqual(df["version"].iloc[0], "v3") - def test_get_discovery_differences_for_new_doc_returns_expected_dataframe(self): - df = self.cs._get_discovery_differences("drive.v3.json") - # Assume that `drive.v3.json` is a new discovery artifact that doesn't - # exist in `CURRENT_ARTIFACTS_DIR`. - self.assertEqual(df["Name"].iloc[0], "drive") - self.assertEqual(df["Version"].iloc[0], "v3") - - # All rows in the dataframe should have `True` in the `Added` column - # and `False` in the `Deleted` column. - # pd.Dataframe().all() will return `True` if all elements are `True`. - self.assertTrue(df["Added"].all()) + ed"].all()) self.assertTrue((~df["Deleted"]).all()) # There should be 4 unique key differences From bad93a99fc8ac66a038ed512824e41d0c9d2e319 Mon Sep 17 00:00:00 2001 From: Sushmitha Venugopal <88627924+SushTP@users.noreply.github.com> Date: Wed, 11 Aug 2021 14:15:53 +0530 Subject: [PATCH 2/4] Add files via upload --- updatediscoveryartifacts.py | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 updatediscoveryartifacts.py diff --git a/updatediscoveryartifacts.py b/updatediscoveryartifacts.py new file mode 100644 index 0000000..b823bd7 --- /dev/null +++ b/updatediscoveryartifacts.py @@ -0,0 +1,81 @@ +# Copyright 2021 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. + + +import pathlib +import shutil +import subprocess +import tempfile + +import describe +import changesummary + + +SCRIPTS_DIR = pathlib.Path(__file__).parent.resolve() +DISCOVERY_DOC_DIR = ( + SCRIPTS_DIR / ".." / "googleapiclient" / "discovery_cache" / "documents" +) +REFERENCE_DOC_DIR = SCRIPTS_DIR / ".." / "docs" / "dyn" +TEMP_DIR = SCRIPTS_DIR / "temp" + +# Clear discovery documents and reference documents directory +shutil.rmtree(DISCOVERY_DOC_DIR, ignore_errors=True) +shutil.rmtree(REFERENCE_DOC_DIR, ignore_errors=True) + +# Clear temporary directory +shutil.rmtree(TEMP_DIR, ignore_errors=True) + +# Check out a fresh copy +subprocess.call(["git", "checkout", DISCOVERY_DOC_DIR]) +subprocess.call(["git", "checkout", REFERENCE_DOC_DIR]) + +# Snapshot current discovery artifacts to a temporary directory +with tempfile.TemporaryDirectory() as current_discovery_doc_dir: + shutil.copytree(DISCOVERY_DOC_DIR, current_discovery_doc_dir, dirs_exist_ok=True) + + # Download discovery artifacts and generate documentation + describe.generate_all_api_documents() + + # Get a list of files changed using `git diff` + git_diff_output = subprocess.check_output( + [ + "git", + "diff", + "origin/master", + "--name-only", + "--", + DISCOVERY_DOC_DIR / "*.json", + REFERENCE_DOC_DIR / "*.html", + REFERENCE_DOC_DIR / "*.md", + ], + universal_newlines=True, + ) + + # Create lists of the changed files + all_changed_files = [ + pathlib.Path(file_name).name for file_name in git_diff_output.split("\n") + ] + json_changed_files = [file for file in all_changed_files if file.endswith(".json")] + + # Create temporary directory + pathlib.Path(TEMP_DIR).mkdir() + + # Analyze the changes in discovery artifacts using the changesummary module + changesummary.ChangeSummary( + DISCOVERY_DOC_DIR, current_discovery_doc_dir, TEMP_DIR, json_changed_files + ).detect_discovery_changes() + + # Write a list of the files changed to a file called `changed files` which will be used in the `createcommits.sh` script. + with open(TEMP_DIR / "changed_files", "w") as f: + f.writelines("\n".join(all_changed_files)) From 4e0c9bce9f2078efd22bd17b7af8ac18faf3facc Mon Sep 17 00:00:00 2001 From: Sushmitha Venugopal <88627924+SushTP@users.noreply.github.com> Date: Mon, 30 Aug 2021 11:27:39 +0530 Subject: [PATCH 3/4] #191083 time: 2:3 comment: test comment --- buildprbody_test.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/buildprbody_test.py b/buildprbody_test.py index 3cc0ba5..82d5a51 100644 --- a/buildprbody_test.py +++ b/buildprbody_test.py @@ -1,10 +1,4 @@ -# Copyright 2021 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 -# -# 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, From e3455acc76efa607031ac270b05af608cb5619b9 Mon Sep 17 00:00:00 2001 From: Sushmitha Venugopal <88627924+SushTP@users.noreply.github.com> Date: Mon, 30 Aug 2021 11:33:26 +0530 Subject: [PATCH 4/4] #191083 time:2:3 comment: test final --- buildprbody_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildprbody_test.py b/buildprbody_test.py index 82d5a51..fba7809 100644 --- a/buildprbody_test.py +++ b/buildprbody_test.py @@ -1,4 +1,4 @@ - +# # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS,