Skip to content

Commit

Permalink
fix: allow local and external deps to be specified (#469)
Browse files Browse the repository at this point in the history
Modify noxfile.py to allow local and external dependencies for
system tests to be specified.
  • Loading branch information
busunkim96 authored Apr 7, 2020
1 parent 1df68ed commit 188f1b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions synthtool/gcp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ def py_library(self, **kwargs) -> Path:
# kwargs["metadata"] is required to load values from .repo-metadata.json
if "metadata" not in kwargs:
kwargs["metadata"] = {}
# rename variable to accomodate existing synth.py files
if "system_test_dependencies" in kwargs:
kwargs["system_test_local_dependencies"] = kwargs[
"system_test_dependencies"
]
log.warning(
"Template argument 'system_test_dependencies' is deprecated."
"Use 'system_test_local_dependencies' or 'system_test_external_dependencies'"
"instead."
)

return self._generic_library("python_library", **kwargs)

Expand Down
9 changes: 6 additions & 3 deletions synthtool/gcp/templates/python_library/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,14 @@ def system(session):

# Install all test dependencies, then install this package into the
# virtualenv's dist-packages.
session.install("mock", "pytest")
{% for dependency in system_test_dependencies %}
session.install("-e", "{{dependency}}"){% endfor %}
session.install("mock", "pytest", {% for d in system_test_external_dependencies %}"{{d}}"{% if not loop.last %},{% endif %}{% endfor %})

{%- if system_test_local_dependencies %}
session.install("-e", {% for d in system_test_local_dependencies %}"{{d}}"{% if not loop.last %},{% endif %}{% endfor %})
{%- endif %}
session.install("-e", ".")


# Run py.test against the system tests.
if system_test_exists:
session.run("py.test", "--quiet", system_test_path, *session.posargs)
Expand Down

0 comments on commit 188f1b1

Please sign in to comment.