Skip to content

Add unit tests for core functionality #5

@KaykCaputo

Description

@KaykCaputo

Description

The project currently lacks automated tests. Adding unit tests would improve code reliability and make future refactoring safer.

Scope

Prioritize testing for these functions:

  1. normalize() - Text normalization with accents and special characters
  2. parse_cifra_html() - HTML parsing and chord markup conversion
  3. URL generation logic in fetch_song()

Suggested Framework

  • pytest - Modern Python testing framework
  • pytest-cov - Code coverage reporting

Example Test Structure

# test_main.py
import pytest
from main import OpenCifraApp

def test_normalize_accents():
    app = OpenCifraApp()
    assert app.normalize("João") == "joao"
    assert app.normalize("Música") == "musica"

def test_normalize_special_chars():
    app = OpenCifraApp()
    assert app.normalize("Rock & Roll!") == "rock & roll"

Additional Considerations

  • Add GitHub Actions workflow for CI
  • Set target coverage threshold (e.g., 70%)
  • Document testing setup in README

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions