Skip to content

Commit

Permalink
test: re-add coverage requirement (#937)
Browse files Browse the repository at this point in the history

Co-authored-by: arithmetic1728 <58957152+arithmetic1728@users.noreply.github.com>
  • Loading branch information
busunkim96 and arithmetic1728 authored Jun 29, 2021
1 parent 9817acc commit 678def6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ branchProtectionRules:
isAdminEnforced: true
requiredStatusCheckContexts:
- 'cla/google'
- 'codecov/patch'
- 'codecov/project'
- 'conventionalcommits.org'
- 'docs'
- 'mypy'
Expand Down
21 changes: 15 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def unit(session):
"""Run the unit test suite."""

session.install(
"pytest", "pytest-xdist", "pyfakefs",
"coverage", "pytest-cov", "pytest", "pytest-xdist", "pyfakefs",
)
session.install("-e", ".")

Expand All @@ -45,6 +45,10 @@ def unit(session):
or [
"-vv",
"-n=auto",
"--cov=gapic",
"--cov-config=.coveragerc",
"--cov-report=term",
"--cov-fail-under=100",
path.join("tests", "unit"),
]
),
Expand Down Expand Up @@ -115,7 +119,7 @@ def showcase_library(
)

# Install the library.
session.install(tmp_dir)
session.install("-e", tmp_dir)

yield tmp_dir

Expand Down Expand Up @@ -181,7 +185,9 @@ def showcase_mtls_alternative_templates(session):

def run_showcase_unit_tests(session, fail_under=100):
session.install(
"coverage",
"pytest",
"pytest-cov",
"pytest-xdist",
"asyncmock",
"pytest-asyncio",
Expand All @@ -192,6 +198,9 @@ def run_showcase_unit_tests(session, fail_under=100):
"py.test",
"-n=auto",
"--quiet",
"--cov=google",
"--cov-append",
f"--cov-fail-under={str(fail_under)}",
*(session.posargs or [path.join("tests", "unit")]),
)

Expand All @@ -217,11 +226,11 @@ def showcase_unit(
# google-auth is a transitive dependency so it isn't in the
# lower bound constraints file produced above.
session.install("google-auth==1.21.1")
run_showcase_unit_tests(session)
run_showcase_unit_tests(session, fail_under=0)

# 2. Run the tests again with latest version of dependencies
session.install(".", "--upgrade", "--force-reinstall")
run_showcase_unit_tests(session)
run_showcase_unit_tests(session, fail_under=100)


@nox.session(python=["3.7", "3.8", "3.9"])
Expand All @@ -248,11 +257,11 @@ def showcase_unit_add_iam_methods(session):
# google-auth is a transitive dependency so it isn't in the
# lower bound constraints file produced above.
session.install("google-auth==1.21.1")
run_showcase_unit_tests(session)
run_showcase_unit_tests(session, fail_under=0)

# 2. Run the tests again with latest version of dependencies
session.install(".", "--upgrade", "--force-reinstall")
run_showcase_unit_tests(session)
run_showcase_unit_tests(session, fail_under=100)


@nox.session(python="3.8")
Expand Down
39 changes: 39 additions & 0 deletions tests/unit/schema/wrappers/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,45 @@ def test_service_any_streaming():
assert service.any_server_streaming == server


def test_service_any_deprecated():
service = make_service(
name='Service',
methods=(
(
make_method(
f"GetMollusc",
input_message=make_message(
"GetMolluscRequest",
),
output_message=make_message(
"GetMolluscResponse",
),
),
)
))

assert service.any_deprecated == False

deprecated_service = make_service(
name='ServiceWithDeprecatedMethod',
methods=(
(
make_method(
f"GetMollusc",
input_message=make_message(
"GetMolluscRequest",
),
output_message=make_message(
"GetMolluscResponse",
),
is_deprecated=True,
),
)
))

assert deprecated_service.any_deprecated == True


def test_has_pagers():
paged = make_field(name='foos', message=make_message('Foo'), repeated=True)
input_msg = make_message(
Expand Down

0 comments on commit 678def6

Please sign in to comment.