Files
leocrm/tests/test_semver.py
Agent Zero 98eb1d0d89
Check Cross-Plugin Imports / check (push) Has been cancelled
feat: Plugin-System Umbau — 6 Phasen komplett abgeschlossen
Phase 1: Contracts konsequent nutzen
- 12 neue contracts.py erstellt (alle 19 Plugins haben jetzt contracts)
- 4 bestehende contracts.py an zentrale ContractRegistry angepasst
- Alle 19 Plugins haben on_deactivate mit Contract-Unregister
- 0 echte problematische INTER-Plugin Imports

Phase 2: Hooks/Filters-System
- app/core/hooks.py (HookRegistry mit actions + filters)
- 15 Hook-Punkte in Core-Services (contact, auth, mail, calendar, user, dms)
- BasePlugin.on_deactivate meldet alle Hooks ab

Phase 3: Plugin-Isolation
- scripts/check_cross_plugin_imports.py (Linting-Regel)
- .github/workflows/check-cross-plugin-imports.yml (CI/CD)
- .pre-commit-cross-plugin.yaml (Pre-commit Hook)
- 155 Dateien geprueft, 0 Verstoesse

Phase 4: Plugin-Versioning
- app/plugins/semver.py (SemVer mit Parse, Compare, Pre-release)
- migration_runner.py erweitert: run_migration_down, rollback_to_version
- manifest.py: min_app_version Feld
- registry.py: App-Version-Compatibility-Check bei Installation
- GET /api/v1/plugins/updates Endpoint

Phase 5: Marketplace-Vorbereitung
- app/plugins/signature.py (Ed25519 Signatur-Validierung)
- app/plugins/quarantine.py (Plugin-Quarantine mit Validierung)
- app/models/plugin_allowlist.py + Migration 0046
- manifest.py: author, license, homepage, icon, screenshots, changelog, marketplace_tags, price
- registry.py: discover_external(), discover_all()
- POST /api/v1/plugins/install-marketplace (deaktiviert)

Phase 6: Manifest-Anpassung
- manifest.py: 12 neue Felder + SemVer/Hook-Name Validierung
- MANIFEST_SCHEMA_DOC aktualisiert
- Alle 19 Plugin-Manifeste aktualisiert
- Frontend PluginUiManifest Typ erweitert

Zusaetzliche Bug-Fixes:
- test_sample-Modul erstellt
- conftest.py Deadlock-Prevention
- SESSION_COOKIE_SECURE=true
- dump.rdb aus Git entfernt + .gitignore
- backup.py datetime.utcnow -> func.now()
- system_settings.py JSONB-Import nach oben
- tax.py Mapped[float] -> Mapped[Decimal]
- notification.py type_key-Laengen vereinheitlicht

Tests: 91 neue Tests, alle bestanden
2026-07-26 23:15:34 +02:00

108 lines
3.3 KiB
Python

"""Tests for the SemVer comparison module."""
from __future__ import annotations
import pytest
from app.plugins.semver import (
SemVer,
compare_versions,
is_breaking_change,
is_compatible,
)
class TestSemVerParse:
def test_parse_simple(self):
v = SemVer.parse("1.2.3")
assert v.major == 1
assert v.minor == 2
assert v.patch == 3
assert v.prerelease == ""
def test_parse_with_prerelease(self):
v = SemVer.parse("1.0.0-alpha.1")
assert v.major == 1
assert v.minor == 0
assert v.patch == 0
assert v.prerelease == "alpha.1"
def test_parse_with_v_prefix(self):
v = SemVer.parse("v2.0.0")
assert v.major == 2
def test_parse_invalid(self):
with pytest.raises(ValueError):
SemVer.parse("not-a-version")
def test_parse_empty(self):
with pytest.raises(ValueError):
SemVer.parse("")
def test_parse_two_parts(self):
with pytest.raises(ValueError):
SemVer.parse("1.2")
def test_parse_four_parts(self):
with pytest.raises(ValueError):
SemVer.parse("1.2.3.4")
class TestSemVerComparison:
def test_equal(self):
assert SemVer.parse("1.0.0") == SemVer.parse("1.0.0")
def test_less_than(self):
assert SemVer.parse("1.0.0") < SemVer.parse("1.0.1")
assert SemVer.parse("1.0.0") < SemVer.parse("1.1.0")
assert SemVer.parse("1.0.0") < SemVer.parse("2.0.0")
def test_greater_than(self):
assert SemVer.parse("1.0.1") > SemVer.parse("1.0.0")
assert SemVer.parse("2.0.0") > SemVer.parse("1.9.9")
def test_prerelease_lower_than_release(self):
assert SemVer.parse("1.0.0-alpha") < SemVer.parse("1.0.0")
assert SemVer.parse("1.0.0-beta.1") < SemVer.parse("1.0.0")
def test_prerelease_ordering(self):
assert SemVer.parse("1.0.0-alpha.1") < SemVer.parse("1.0.0-alpha.2")
assert SemVer.parse("1.0.0-alpha") < SemVer.parse("1.0.0-beta")
def test_str(self):
assert str(SemVer.parse("1.2.3")) == "1.2.3"
assert str(SemVer.parse("1.0.0-beta.1")) == "1.0.0-beta.1"
class TestSemVerCompatibility:
def test_breaking_change(self):
assert is_breaking_change("1.0.0", "2.0.0")
assert not is_breaking_change("1.0.0", "1.5.0")
def test_compatible_same_major(self):
assert is_compatible("1.5.0", "1.0.0")
assert not is_compatible("1.0.0", "1.5.0")
def test_compatible_higher_major(self):
assert is_compatible("2.0.0", "1.0.0")
assert not is_compatible("1.0.0", "2.0.0")
def test_is_upgrade_from(self):
assert SemVer.parse("1.1.0").is_upgrade_from(SemVer.parse("1.0.0"))
assert not SemVer.parse("1.0.0").is_upgrade_from(SemVer.parse("1.1.0"))
def test_is_downgrade_from(self):
assert SemVer.parse("1.0.0").is_downgrade_from(SemVer.parse("1.1.0"))
assert not SemVer.parse("1.1.0").is_downgrade_from(SemVer.parse("1.0.0"))
class TestCompareVersions:
def test_compare_equal(self):
assert compare_versions("1.0.0", "1.0.0") == 0
def test_compare_less(self):
assert compare_versions("1.0.0", "1.0.1") == -1
def test_compare_greater(self):
assert compare_versions("1.1.0", "1.0.0") == 1