lablup / lablup/backend.ai

Rewrite artifact service unit tests

Open
#7,324 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

## Motivation

The existing artifact service tests were located in `tests/manager/services/artifact/actions/` directory and mixed service layer logic with database operations. This violated the testing convention established in other parts of the codebase (e.g., notification tests), where:

- Service layer tests should use mocked repositories
- Database integration tests should reside in the repository layer

## Objective

Restructure artifact and artifact_revision tests to follow the established testing conventions, ensuring clear separation between unit tests (service layer with mocks) and integration tests (repository layer with real DB).

## Details

1. **Create service layer unit tests with mocked repositories:**
- `tests/manager/services/artifact/test_artifact_service.py`
- `tests/manager/services/artifact_revision/test_artifact_revision_service.py`
1. **Create repository layer integration tests:**
- `tests/manager/repositories/artifact/test_artifact_repository.py`
- `tests/manager/repositories/artifact_revision/test_artifact_revision_repository.py`
1. **Delete old test files:**
- Remove `tests/manager/services/artifact/actions/*`
- Remove `tests/manager/services/artifact_revision/actions/*`
1. **Separate artifact vs revision tests:**
- Artifact-only tests go in artifact test files
- Revision-related tests go in revision test files
- Tests requiring both should be placed in revision test files
1. **Update to new Updater pattern:**
- Replace `ArtifactModifier` with `ArtifactUpdaterSpec` and `Updater[ArtifactRow]`
- Update `UpdateArtifactAction` to use `updater` parameter instead of `artifact_id` + `modifier`
1. **Update BUILD files** for new test locations

## Impact

- Improves test maintainability by clearly separating unit tests from integration tests
- Aligns artifact/revision tests with the codebase testing conventions
- Makes it easier to run fast unit tests independently from slower DB integration tests
- Future artifact-related test additions will follow a consistent pattern

JIRA Issue: BA-3386

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.