Skip to content

tests: add SOLID compliance tests#30

Merged
juanmanueldaza merged 6 commits into
juanmanueldaza:mainfrom
Muhtasim-Munif-Fahim:main
Jun 25, 2026
Merged

tests: add SOLID compliance tests#30
juanmanueldaza merged 6 commits into
juanmanueldaza:mainfrom
Muhtasim-Munif-Fahim:main

Conversation

@Muhtasim-Munif-Fahim

Copy link
Copy Markdown
Contributor

Closes #12

Adds SOLID principle compliance tests:

  • S: Single Responsibility - each class has one responsibility
  • O: Open/Closed - classes are open for extension
  • I: Liskov Substitution - subclasses maintain parent contracts
  • I: Interface Segregation - interfaces are minimal
  • D: Dependency Inversion - high-level modules don'''t depend on low-level details

Copilot AI review requested due to automatic review settings June 17, 2026 20:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new pytest module intended to enforce SOLID-oriented architectural constraints around the converter/registry patterns, increasing regression protection for the plugin registration and orchestration pipeline.

Changes:

  • Introduces tests/test_solid.py with SRP/OCP/LSP/ISP/DIP checks for extractor/writer, registries, parsers/formatters, and converter wiring.
  • Adds tests covering decorator-based registration and factory-based dependency injection.

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

Comment thread tests/test_solid.py Outdated
Comment on lines +310 to +311
sig = inspect.signature(GitHubToMarkdownConverter.__init__)
hints = get_type_hints(GitHubToMarkdownConverter.__init__)
Comment thread tests/test_solid.py Outdated
Comment on lines +13 to +16
from typing import Any, get_type_hints

import pytest

Comment thread tests/test_solid.py
Comment on lines +58 to +60
methods = [
m for m in dir(GitHubExtractor) if not m.startswith("_") or m == "__init__"
]
Comment thread tests/test_solid.py Outdated
Comment on lines +86 to +87
parsers = {p.section_key: p for p in [ProfileParser(), ReposParser(), ContributionsParser()]}
formatters = {f.section_key: f for f in [ProfileFormatter(), ReposFormatter(), ContributionsFormatter()]}
Comment thread tests/test_solid.py Outdated
Comment on lines +65 to +68
def test_writer_only_writes(self):
"""MarkdownFileWriter: sole job is writing content to files."""
writer = MarkdownFileWriter(Path("/tmp"))
sig = inspect.signature(writer.write)
Comment thread tests/test_solid.py Outdated
Comment on lines +363 to +366
def test_create_converter_factory_injects_dependencies(self):
"""Factory function wires concrete deps behind abstract interfaces."""
output_dir = Path("/tmp/test_github2md_dip")
conv = create_converter(output_dir)
Comment thread tests/test_solid.py Outdated


class TestDependencyInversion:
"""High-level modules should not depend on low-level details; both should depend on abstractions."""
Comment thread tests/test_solid.py Outdated
assert registered_after == registered_before + 1

def test_converter_uses_registry_not_hardcoded_list(self):
"""Converter iterates registry — adding a new parser/formatter works automatically."""
Comment thread tests/test_solid.py Outdated
"""Subtypes must be substitutable for their base types/protocols."""

def test_parsers_implement_section_parser_protocol(self):
"""All parsers satisfy SectionParser and can be used where SectionParser is expected."""
@juanmanueldaza

Copy link
Copy Markdown
Owner

Thanks for the PR! 🙌 Copilot's review caught a few ruff lint issues that need fixing before merge:

  • F841: unused variable sig
  • F401: unused import pytest
  • E501: several lines exceed 88 chars (docstrings, comprehensions)
  • Hardcoded /tmp paths — should use tmp_path fixture

Could you address these? The tests look solid architecturally — just need the lint cleanup. Happy to merge once CI passes! 🚀

@juanmanueldaza juanmanueldaza left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Code Review: SOLID Compliance Tests

Nice work @Muhtasim-Munif-Fahim! This is a thorough test suite covering all five SOLID principles.

Positive:

  • Comprehensive coverage — S, O, L, I, D all tested ✅
  • Tests are well-organized by principle in separate classes ✅
  • Uses protocols (DataExtractor, OutputWriter) for dependency inversion tests ✅
  • Registry returns copies to prevent external mutation ✅
  • Edge cases: empty data, mock implementations ✅

Suggestion: Consider splitting the test_converter_depends_on_protocols_not_concretions test — it uses get_type_hints which could fail with NameError if forward refs are used in the future. A simpler assertion checking the parameter names (like test_converter_depends_on_abstractions) is more robust.

CI is running now. Will approve once it passes. 🚀

@juanmanueldaza juanmanueldaza left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

CI Results: ❌ 3 lint errors

The CI ran and found 3 I001 (import block un-sorted) errors in tests/test_solid.py:

  1. Line 11 — Top-level imports not properly organized
  2. Line 418test_parsers_reference_only_abstractions — inline imports not organized
  3. Line 430test_formatters_reference_only_abstractions — inline imports not organized

All 3 are auto-fixable with ruff check --fix. Could you:

  1. Run ruff check --fix tests/test_solid.py locally
  2. Commit and push the fixes

These tests also import from production modules (github2md.converter, etc.) which may not be available in the CI environment unless the package is installed — double check that your pyproject.toml has the right dev dependencies.

Other than the lint, the test structure and coverage is solid (pun intended). 🚀

@juanmanueldaza juanmanueldaza dismissed their stale review June 25, 2026 00:48

Fix applied — pushed ruff import sorting fix directly

- Rename format param from 'parsed_data' to 'data' in SectionFormatter protocol
- Ruff format test_solid.py (blank lines after class defs)
- Fix ruff I001 import ordering in test_solid.py
@juanmanueldaza juanmanueldaza merged commit 8a66288 into juanmanueldaza:main Jun 25, 2026
1 check passed
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.

Add SOLID compliance tests for registry and converter patterns

3 participants