Skip to content

Commit

Permalink
build: add mock server tests to Owlbot config (#1254)
Browse files Browse the repository at this point in the history
* build: add mock server tests to Owlbot config

* chore: add escapes

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
olavloite and gcf-owl-bot[bot] authored Dec 5, 2024
1 parent c064815 commit a81af3b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]

DEFAULT_PYTHON_VERSION = "3.8"
DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION = "3.12"

DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION = "3.12"
UNIT_TEST_PYTHON_VERSIONS: List[str] = [
"3.7",
"3.8",
Expand Down
45 changes: 45 additions & 0 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,49 @@ def prerelease_deps\(session, protobuf_implementation\):""",
def prerelease_deps(session, protobuf_implementation, database_dialect):""",
)


mockserver_test = """
@nox.session(python=DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION)
def mockserver(session):
# Install all test dependencies, then install this package in-place.
constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
# install_unittest_dependencies(session, "-c", constraints_path)
standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES
session.install(*standard_deps, "-c", constraints_path)
session.install("-e", ".", "-c", constraints_path)
# Run py.test against the mockserver tests.
session.run(
"py.test",
"--quiet",
f"--junitxml=unit_{session.python}_sponge_log.xml",
"--cov=google",
"--cov=tests/unit",
"--cov-append",
"--cov-config=.coveragerc",
"--cov-report=",
"--cov-fail-under=0",
os.path.join("tests", "mockserver_tests"),
*session.posargs,
)
"""

place_before(
"noxfile.py",
"def install_systemtest_dependencies(session, *constraints):",
mockserver_test,
escape="()_*:",
)

place_before(
"noxfile.py",
"UNIT_TEST_PYTHON_VERSIONS: List[str] = [",
'DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION = "3.12"',
escape="[]",
)

s.shell.run(["nox", "-s", "blacken"], hide_output=False)

0 comments on commit a81af3b

Please sign in to comment.