lablup / lablup/backend.ai

Apply new fixtures to repository tests

Open
#7,668 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

## Overview

Migrate repository tests to use the new selective table loading infrastructure. Each repository test file should only create the tables it actually needs.

## Target Files

|Repository|Test File|Expected Improvement|
|---|---|---|
|Domain|`tests/unit/manager/repositories/domain/test_domain.py`|~18s saved|
|Notification|`tests/unit/manager/repositories/notification/test_notification_*.py`|~29s saved|
|Deployment|`tests/unit/manager/repositories/deployment/test_deployment_repository.py`|~12s saved|

## Work Items

### For Each Repository Test Directory:

1. **Create** `conftest.py` with:
- `REQUIRED_TABLES` list (analyze FK dependencies)
- `required_tables` fixture using `with_tables` (module scope)
1. **Update test files** to:
- Remove `database_fixture` dependency
- Use `required_tables` + `database_connection` instead

### Example Structure

```python
# tests/unit/manager/repositories/domain/conftest.py
from tests.testutils.db import with_tables

REQUIRED_TABLES = [
DomainRow.__table__,
UserRow.__table__,
GroupRow.__table__,
KeypairRow.__table__,
]

@pytest.fixture(scope="module")
async def required_tables(database_connection):
async with with_tables(database_connection, REQUIRED_TABLES):
yield
```

## Acceptance Criteria

- [ ] Domain repository tests use selective tables
- [ ] Notification repository tests use selective tables
- [ ] Deployment repository tests use selective tables
- [ ] All repository tests pass with new fixtures
- [ ] Test execution time reduced by ~50%

## Parent Epic

BA-3611

JIRA Issue: BA-3613

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.