Skip to content

Conversation

@chalmerlowe
Copy link
Collaborator

Adds unit tests to exercise the functions in utils.py.

  • _load_resource() # used by both _load_template() and _load_config()
  • _load_template()
  • _load_config()
  • walk_codebase()
  • write_code_to_file()

@chalmerlowe chalmerlowe requested review from a team as code owners September 22, 2025 15:32
@chalmerlowe chalmerlowe requested review from Linchin and removed request for a team September 22, 2025 15:32
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Sep 22, 2025
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Sep 22, 2025
@chalmerlowe chalmerlowe changed the title test: adds unit tests for utils.py test: microgen - adds unit tests for utils.py Sep 22, 2025
@chalmerlowe chalmerlowe added this to the µgen PoC milestone Sep 23, 2025
strategy:
matrix:
python: ['3.9', '3.10', "3.11", "3.12", "3.13"]
python: ["3.13"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't you removing the unit test matrix for all the normal testing by this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shollyman
Yes. This code is focused on the microgenerator and getting ready for alpha release.
It is less worried about the code that the GAPIC generator produces and all the GAPIC generated unit tests.

In order to simplify figuring out how this workflow would work along with the regular GAPIC unittest workflow, I opted to reduce it to a single runtime to speed up iteration and experimentation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment explaining that this is an experiment for the alpha release.

We are simply attempting to better understand the testing process for two disparate parts of the codebase in the event that we choose to keep the microgenerator as some part of the main package (I think we will want to move it into a package of it's own, but that is a story for another day).

COVERAGE_FILE: .coverage-${{ matrix.python }}
BUILD_TYPE: presubmit
TEST_TYPE: unit
TEST_TYPE: unit xxx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear why this is added. Is it used to parameterize the output in some way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to identify how the task names and TEST_TYPEs reflect in the outputs displayed in the GH user interface, so I dropped in some characters to see what shows up and what does not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added some comments and renamed some things.

PY_VERSION: ${{ matrix.python }}
run: |
nox -s unit-${{ matrix.python }}
- name: Run microgenerator unit tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think microgenerator testing is sufficiently distinct from the normal testing, another strategy here would be to define it all in an addition, custom workflow rather than in unitttest.yml

Copy link
Collaborator Author

@chalmerlowe chalmerlowe Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, that is another strategy.
It seemed reasonable at first glance to put all unit tests into a unittests workflow to get us in a position to be able to test a unit test setup for the microgenerator with the minimum amount of fuss.

If I can't get this work, I may try that approach.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, it looks like we are able to run two sets of tests AND when running the microgenerator tests, it runs the desired tests (18 total).

Breakout:

Screenshot 2025-09-23 at 14 41 15

See the separate line items above.

The test summary:

Screenshot 2025-09-23 at 14 41 40

@chalmerlowe chalmerlowe assigned chalmerlowe and unassigned yirutang Sep 23, 2025
@chalmerlowe chalmerlowe added the automerge Merge the pull request once unit tests and other checks pass. label Sep 23, 2025
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Sep 24, 2025
@chalmerlowe chalmerlowe added the automerge Merge the pull request once unit tests and other checks pass. label Sep 25, 2025
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Sep 26, 2025
Copy link
Contributor

@shollyman shollyman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this was landing in autogen rather than main

@chalmerlowe chalmerlowe merged commit f5c24b9 into autogen Sep 30, 2025
21 checks passed
@chalmerlowe chalmerlowe deleted the test/test-utils-load_resource branch September 30, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants