Skip to content

Commit

Permalink
chore: resolve issue with prerelease presubmit [autoapprove] (#417)
Browse files Browse the repository at this point in the history
* chore(python): fix prerelease session [autoapprove]

Source-Link: googleapis/synthtool@1b9ad76
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:9db98b055a7f8bd82351238ccaacfd3cda58cdf73012ab58b8da146368330021

* fix flaky test

* fix api_shortname in .repo-metadata.json

* use unittest.mock

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
  • Loading branch information
3 people authored Aug 2, 2022
1 parent b612dec commit eb73395
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 22 deletions.
4 changes: 2 additions & 2 deletions packages/google-cloud-translate/.github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
digest: sha256:c8878270182edaab99f2927969d4f700c3af265accd472c3425deedff2b7fd93
# created: 2022-07-14T01:58:16.015625351Z
digest: sha256:9db98b055a7f8bd82351238ccaacfd3cda58cdf73012ab58b8da146368330021
# created: 2022-07-25T16:02:49.174178716Z
4 changes: 2 additions & 2 deletions packages/google-cloud-translate/.repo-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"library_type": "GAPIC_COMBO",
"repo": "googleapis/python-translate",
"distribution_name": "google-cloud-translate",
"api_id": "translation.googleapis.com",
"api_id": "translate.googleapis.com",
"requires_billing": true,
"default_version": "v3",
"codeowner_team": "@googleapis/cdpe-cloudai",
"api_shortname": "translation",
"api_shortname": "translate",
"api_description": "can dynamically translate text between thousands of language pairs. Translation lets websites and programs programmatically integrate with the translation service."
}
33 changes: 18 additions & 15 deletions packages/google-cloud-translate/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ def prerelease_deps(session):

# Install all dependencies
session.install("-e", ".[all, tests, tracing]")
session.install(*UNIT_TEST_STANDARD_DEPENDENCIES)
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
session.install(*unit_deps_all)
system_deps_all = (
SYSTEM_TEST_STANDARD_DEPENDENCIES
+ SYSTEM_TEST_EXTERNAL_DEPENDENCIES
Expand Down Expand Up @@ -362,12 +363,6 @@ def prerelease_deps(session):

session.install(*constraints_deps)

if os.path.exists("samples/snippets/requirements.txt"):
session.install("-r", "samples/snippets/requirements.txt")

if os.path.exists("samples/snippets/requirements-test.txt"):
session.install("-r", "samples/snippets/requirements-test.txt")

prerel_deps = [
"protobuf",
# dependency of grpc
Expand Down Expand Up @@ -404,11 +399,19 @@ def prerelease_deps(session):
system_test_folder_path = os.path.join("tests", "system")

# Only run system tests if found.
if os.path.exists(system_test_path) or os.path.exists(system_test_folder_path):
session.run("py.test", "tests/system")

snippets_test_path = os.path.join("samples", "snippets")

# Only run samples tests if found.
if os.path.exists(snippets_test_path):
session.run("py.test", "samples/snippets")
if os.path.exists(system_test_path):
session.run(
"py.test",
"--verbose",
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_path,
*session.posargs,
)
if os.path.exists(system_test_folder_path):
session.run(
"py.test",
"--verbose",
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_folder_path,
*session.posargs,
)
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_detect_language(capsys):
def test_list_languages(capsys):
beta_snippets.list_languages(PROJECT_ID)
out, _ = capsys.readouterr()
assert "zh-CN" in out
assert "zh" in out


def test_list_languages_with_target(capsys):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
def test_list_languages(capsys):
translate_v3_get_supported_languages.get_supported_languages(PROJECT_ID)
out, _ = capsys.readouterr()
assert "zh-CN" in out
assert "zh" in out
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import unittest

import mock
from unittest import mock


class TestConnection(unittest.TestCase):
Expand Down

0 comments on commit eb73395

Please sign in to comment.