Skip to content

Commit

Permalink
fix: migrate to native namespace packages (#193)
Browse files Browse the repository at this point in the history
* test: add import test

* 🦉 Updates from OwlBot post-processor

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

* add unit nox session

* refactor tests

* fix: migrate to native namespace packages

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
parthea and gcf-owl-bot[bot] committed Feb 15, 2024
1 parent e4db7ff commit 5840132
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
18 changes: 10 additions & 8 deletions noxfile.py
Expand Up @@ -68,10 +68,11 @@
nox.options.sessions = [
"system",
"lint",
"test",
"integration_test",
"lint_setup_py",
"blacken",
"docs",
"unit",
]

# Error if a python version is missing
Expand Down Expand Up @@ -183,11 +184,6 @@ def default(session):
)


def unit(session):
"""Run the unit test suite."""
default(session)


def install_systemtest_dependencies(session, *constraints):

# Use pre-release gRPC for system tests.
Expand Down Expand Up @@ -225,7 +221,7 @@ def install_systemtest_dependencies(session, *constraints):
],
ids=["asset"],
)
def test(session, library):
def integration_test(session, library):
"""Run tests from a downstream libraries.
To verify that any changes we make here will not break downstream libraries, clone
a few and run their unit and system tests.
Expand All @@ -249,7 +245,7 @@ def test(session, library):
session.cd(library)
if package:
session.cd(f"packages/{package}")
unit(session)
default(session)
# system tests are run 3.7 only
if session.python == "3.7":
system(session)
Expand Down Expand Up @@ -401,3 +397,9 @@ def docfx(session):
os.path.join("docs", ""),
os.path.join("docs", "_build", "html", ""),
)


@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
def unit(session):
"""Run the unit test suite."""
default(session)
9 changes: 2 additions & 7 deletions setup.py
Expand Up @@ -16,6 +16,7 @@
import os

import setuptools
from setuptools import find_namespace_packages

# Package metadata.

Expand All @@ -39,12 +40,6 @@
with io.open(readme_filename, encoding="utf-8") as readme_file:
readme = readme_file.read()

# Only include packages under the 'google' namespace. Do not include tests,
# benchmarks, etc.
packages = [
package for package in setuptools.find_packages() if package.startswith("google")
]

setuptools.setup(
name=name,
version=version,
Expand All @@ -70,7 +65,7 @@
"Topic :: Internet",
],
platforms="Posix; MacOS X; Windows",
packages=packages,
packages=find_namespace_packages(exclude=("tests*", "testing*")),
install_requires=dependencies,
python_requires=">=3.7",
include_package_data=True,
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/test_import.py
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


from google.identity.accesscontextmanager.v1 import access_level_pb2


def test_create_audit_log():
# just check that the import works
# and that an AuditLog instance can be instantiated
access_level_pb2.BasicLevel()
File renamed without changes.

0 comments on commit 5840132

Please sign in to comment.