Skip to content

feat: add unit test and metric generator#24

Open
Alveaenerle wants to merge 1 commit intomainfrom
feat/testing
Open

feat: add unit test and metric generator#24
Alveaenerle wants to merge 1 commit intomainfrom
feat/testing

Conversation

@Alveaenerle
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds comprehensive unit tests and a metrics generator to the FixMyCodeDB project. The changes include test suites for the scraper, FastAPI, and CLI modules, along with a Python script to generate repository metrics.

Changes:

  • Added comprehensive unit test coverage across all modules (scraper, fastapi, cli)
  • Added a metrics generator script (generate_metrics.py) to calculate file counts, LOC, test counts, and code coverage
  • Updated requirements.txt with testing dependencies and pytest.ini configuration

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 29 comments.

Show a summary per file
File Description
tests/scraper/*.py Unit tests for scraper module components (server, config, labeler, engine, analyzers)
tests/fastapi/*.py Unit tests for FastAPI models, endpoints, and CRUD operations
tests/cli/*.py Unit tests for CLI argument parsing, handlers, interactive loop, and command tree
tests/conftest.py Shared pytest fixtures for test data and mocks
generate_metrics.py Script to generate repository metrics (file count, LOC, tests, coverage)
requirements.txt Added testing dependencies (pytest, pytest-cov, pytest-asyncio)
pytest.ini Updated pytest configuration with python paths and asyncio mode

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



# File extensions to count as source files
SOURCE_EXTENSIONS = {'.py', '.yaml', '.yml', '.sh', '.js', 'Dockerfile'}
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The SOURCE_EXTENSIONS set includes 'Dockerfile' as an element, but this is a filename without an extension. This will never match a file extension check. The logic at lines 71-72 handles Dockerfile separately, so 'Dockerfile' should be removed from SOURCE_EXTENSIONS to avoid confusion.

Suggested change
SOURCE_EXTENSIONS = {'.py', '.yaml', '.yml', '.sh', '.js', 'Dockerfile'}
SOURCE_EXTENSIONS = {'.py', '.yaml', '.yml', '.sh', '.js'}

Copilot uses AI. Check for mistakes.
Comment on lines +169 to +170
export_dir = tmp_path / "export_test"

Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

Variable export_dir is not used.

Suggested change
export_dir = tmp_path / "export_test"

Copilot uses AI. Check for mistakes.

with patch.dict(sys.modules, {'models': MagicMock()}):
import crud
result = await crud.list_entries(db, filter_dict=filter_dict)
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

Variable result is not used.

Suggested change
result = await crud.list_entries(db, filter_dict=filter_dict)
await crud.list_entries(db, filter_dict=filter_dict)

Copilot uses AI. Check for mistakes.
with patch('scraper.labeling.labeler.CppcheckAnalyzer') as mock_analyzer_class:
from scraper.labeling.labeler import Labeler

labeler = Labeler(
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

Variable labeler is not used.

Suggested change
labeler = Labeler(
Labeler(

Copilot uses AI. Check for mistakes.
try:
# Need to reload module to get default
import importlib
import scraper.core.engine as engine
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

Module 'scraper.core.engine' is imported with both 'import' and 'import from'.

Suggested change
import scraper.core.engine as engine
engine = importlib.import_module("scraper.core.engine")

Copilot uses AI. Check for mistakes.
"""
import pytest
from unittest.mock import MagicMock, patch
import socket
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

Import of 'socket' is not used.

Suggested change
import socket

Copilot uses AI. Check for mistakes.

try:
start_server(mock_callback)
except KeyboardInterrupt:
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.

try:
start_server(mock_callback)
except KeyboardInterrupt:
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.

try:
start_server(mock_callback)
except KeyboardInterrupt:
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.

try:
start_server(mock_callback)
except KeyboardInterrupt:
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.
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.

3 participants