Skip to content
Permalink
Browse files
feat: add Samples section to CONTRIBUTING.rst (#181)
Source-Link: googleapis/synthtool@52e4e46
Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:6186535cbdbf6b9fe61f00294929221d060634dae4a0795c1cefdbc995b2d605
  • Loading branch information
gcf-owl-bot committed Jul 22, 2021
1 parent b0e9533 commit 5bc909c606fdf7cc037e1f014a997272f6284c65
Showing with 31 additions and 10 deletions.
  1. +1 −2 .github/.OwlBot.lock.yaml
  2. +24 −0 CONTRIBUTING.rst
  3. +1 −3 samples/snippets/manage_transfer_configs.py
  4. +4 −3 samples/snippets/noxfile.py
  5. +1 −2 samples/snippets/run_notification_test.py
@@ -1,4 +1,3 @@
docker:
image: gcr.io/repo-automation-bots/owlbot-python:latest
digest: sha256:5ff7446edeaede81c3ed58b23a4e76a5403fba1350ce28478045657303b6479d

digest: sha256:6186535cbdbf6b9fe61f00294929221d060634dae4a0795c1cefdbc995b2d605
@@ -177,6 +177,30 @@ Build the docs via:

$ nox -s docs

*************************
Samples and code snippets
*************************

Code samples and snippets live in the `samples/` catalogue. Feel free to
provide more examples, but make sure to write tests for those examples.
Each folder containing example code requires its own `noxfile.py` script
which automates testing. If you decide to create a new folder, you can
base it on the `samples/snippets` folder (providing `noxfile.py` and
the requirements files).

The tests will run against a real Google Cloud Project, so you should
configure them just like the System Tests.

- To run sample tests, you can execute::

# Run all tests in a folder
$ cd samples/snippets
$ nox -s py-3.8

# Run a single sample test
$ cd samples/snippets
$ nox -s py-3.8 -- -k <name of test>

********************************************
Note About ``README`` as it pertains to PyPI
********************************************
@@ -135,9 +135,7 @@ def schedule_backfill(override_values={}):
)

response = transfer_client.schedule_transfer_runs(
parent=transfer_config_name,
start_time=start_time,
end_time=end_time,
parent=transfer_config_name, start_time=start_time, end_time=end_time,
)

print("Started transfer runs:")
@@ -28,8 +28,9 @@
# WARNING - WARNING - WARNING - WARNING - WARNING
# WARNING - WARNING - WARNING - WARNING - WARNING

# Copy `noxfile_config.py` to your directory and modify it instead.
BLACK_VERSION = "black==19.10b0"

# Copy `noxfile_config.py` to your directory and modify it instead.

# `TEST_CONFIG` dict is a configuration hook that allows users to
# modify the test configurations. The values here should be in sync
@@ -159,7 +160,7 @@ def lint(session: nox.sessions.Session) -> None:

@nox.session
def blacken(session: nox.sessions.Session) -> None:
session.install("black")
session.install(BLACK_VERSION)
python_files = [path for path in os.listdir(".") if path.endswith(".py")]

session.run("black", *python_files)
@@ -226,7 +227,7 @@ def py(session: nox.sessions.Session) -> None:


def _get_repo_root() -> Optional[str]:
"""Returns the root folder of the project."""
""" Returns the root folder of the project. """
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
p = Path(os.getcwd())
for i in range(10):
@@ -17,8 +17,7 @@

def test_run_notification(capsys, transfer_config_name, pubsub_topic):
run_notification.run_notification(
transfer_config_name=transfer_config_name,
pubsub_topic=pubsub_topic,
transfer_config_name=transfer_config_name, pubsub_topic=pubsub_topic,
)
out, _ = capsys.readouterr()
assert "Updated config:" in out

0 comments on commit 5bc909c

Please sign in to comment.