← Back to issue list

tests: mock and test provider calls from lifecycle.py

View original Github issue

Metadata

Project
snapcraft
Number
#3928
Type
pull request
State
merged
Author
mr-cal
Labels
Created
Updated
Closed

Current evaluation

Merged unit tests mocking craft-providers calls in lifecycle.py. Simplified verbosity handling to align with charmcraft and rockcraft. Approved, passed CI, and increased overall test coverage by 0.10% with 100% diff coverage.

Suggested action:

No scores available.

Issue body

- [X] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [X] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [X] Have you successfully run `make lint`? - [X] Have you successfully run `pytest tests/unit`? ----- ### Overview Mock and test calls made to `craft-providers` from `lifecycle.py`. This code was not being tested. I also simplified the `verbosity` call to match [charmcraft](https://github.com/canonical/charmcraft/blob/b22fcdba3b894004468abfbf45caa54d93fbf7d0/charmcraft/commands/build.py#L321) and [rockcraft](https://github.com/canonical/rockcraft/blob/5d7ed67646a10e5b35319c12d664df7b1e1a14b9/rockcraft/lifecycle.py#L197). ### Details 3 weeks ago, I [added some unit tests](https://github.com/snapcore/snapcraft/pull/3906) for `run_in_provider()`. Today, I am extending those tests further. The test fixtures are copies of the implementations in [charmcraft](https://github.com/canonical/charmcraft/blob/b22fcdba3b894004468abfbf45caa54d93fbf7d0/tests/conftest.py#L133) and [rockcraft](https://github.com/canonical/rockcraft/blob/5d7ed67646a10e5b35319c12d664df7b1e1a14b9/tests/unit/conftest.py#L28). I'll be using these tests next week when I pull code out of the providers directory.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged unit tests mocking craft-providers calls in lifecycle.py. Simplified verbosity handling to align with charmcraft and rockcraft. Approved, passed CI, and increased overall test coverage by 0.10% with 100% diff coverage.
qwen3.6-35b-a3b-mtp-q6 Merged unit tests mocking craft-providers calls in lifecycle.py, alongside simplified verbosity handling. Achieved 100% diff coverage, increased overall coverage by 0.10%, and reduced code lines.
qwen3.6-35b-a3b-mtp-q6 Merged unit tests mocking craft-providers calls in lifecycle.py and simplified verbosity handling. Achieved 100% diff coverage and increased overall coverage by 0.10 percent.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#83 tests: test lifecycle.py::_run_in_provider rockcraft merged Merged unit tests for lifecycle.py::_run_in_provider(), increasing coverage from 16% to 36%. Approved by one reviewer, passed CI, and added 144 lines across three files.
73%