Skip to content

test: unit tests for lifecycle service - #57

Draft
cmatsuoka with Copilot wants to merge 14 commits into
mainfrom
copilot/sub-pr-54-another-one
Draft

test: unit tests for lifecycle service#57
cmatsuoka with Copilot wants to merge 14 commits into
mainfrom
copilot/sub-pr-54-another-one

Conversation

Copilot AI commented Nov 28, 2025

Copy link
Copy Markdown
Contributor
  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run make lint && make test?

Addresses review feedback from #54 requesting unit test coverage for the Lifecycle service class.

Changes

  • Add tests/unit/services/test_lifecycle.py with tests covering:
    • _get_prime_dirs_from_project() helper function (partition-to-package name mapping)
    • Lifecycle.get_prime_dir() method (including error handling for non-existent packages)
    • Lifecycle.prime_dirs property

Test Coverage

# Tests verify partition prefix stripping works correctly
project_info.prime_dirs = {
    "package/my-package": Path("/work/partitions/package/my-package/prime"),
}
result = _get_prime_dirs_from_project(project_info)
# Returns: {None: default_prime, "my-package": package_prime}

Tests also verify:

  • Non-package partitions are ignored
  • Empty partition keys are handled
  • DebcraftError is raised for non-existent package lookups

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

cmatsuoka and others added 9 commits November 27, 2025 19:47
Iterate through all packages declared in the project file and
create a deb file for each file, adding proper control metadata
to each one.

Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
Copilot AI and others added 2 commits November 28, 2025 13:52
Co-authored-by: cmatsuoka <317355+cmatsuoka@users.noreply.github.com>
Co-authored-by: cmatsuoka <317355+cmatsuoka@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address feedback on creating debs for declared packages Add unit tests for Lifecycle service Nov 28, 2025
Copilot AI requested a review from cmatsuoka November 28, 2025 13:58
@cmatsuoka cmatsuoka changed the title Add unit tests for Lifecycle service test: unit tests for lifecycle service Nov 28, 2025
@cmatsuoka
cmatsuoka requested a review from lengau November 28, 2025 14:13
@cmatsuoka

cmatsuoka commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

We can land this directly on main after landing #54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive unit tests for the Lifecycle service class, addressing review feedback from PR #54. The tests validate partition-to-package name mapping logic and directory retrieval methods.

  • Adds tests/unit/services/test_lifecycle.py with tests for the helper function _get_prime_dirs_from_project(), the get_prime_dir() method, and the prime_dirs property
  • Tests cover edge cases including partition prefix stripping, non-package partition filtering, empty partition handling, and error handling for non-existent packages
  • All tests use proper mocking and follow the repository's established testing patterns

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Base automatically changed from work/DEBCRAFT-21-Create-multiple-deb-packages to main December 4, 2025 14:41
@lengau

lengau commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

@copilot rebase this on main.

Copilot AI commented Dec 6, 2025

Copy link
Copy Markdown
Contributor Author

@copilot rebase this on main.

I'm unable to rebase this branch. My environment doesn't support git rebase operations since force push is not available. Could you please perform the rebase manually, or alternatively, I can recreate the changes on a fresh branch based on main if that would help.

@lengau

lengau commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

@copilot merge main into this branch and fix the conflicts.

Co-authored-by: lengau <4305943+lengau@users.noreply.github.com>

Copilot AI commented Dec 6, 2025

Copy link
Copy Markdown
Contributor Author

@copilot merge main into this branch and fix the conflicts.

Merged main into this branch and resolved conflicts in commit 4ea7627. All conflicts were resolved by accepting the main branch version (which contains PR #54), while keeping the lifecycle test file from this branch.

@lengau

lengau commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

@copilot fix the linting issue here. Use conventional commits on your commit message.

Co-authored-by: lengau <4305943+lengau@users.noreply.github.com>

Copilot AI commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

@copilot fix the linting issue here. Use conventional commits on your commit message.

Fixed the import formatting issue in tools/schema.py in commit 975c0e4. The linting now passes.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • canonical-bos01.cdn.snapcraftcontent.com
    • Triggering command: /usr/lib/snapd/snapd /usr/lib/snapd/snapd (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants