fix(tests): align test imports with refactored module paths
Fix broken test imports after architecture refactoring: - mfaService: _buildTotp -> buildTotp, _decryptSecret -> decryptSecret - _actionSignatureValidator: _validateTypeRef -> validateTypeRef - fkRegistry: modules.shared -> modules.dbHelpers - costEstimate/ragLimits: _costEstimate -> costEstimate, _ragLimits -> ragLimits - udbNodes: _isFeatureAdmin -> isFeatureAdmin - inheritFlags: _normalisePath -> normalisePath - methodTrustee: old workflow path -> features/trustee/workflows - methodDiscovery: fix featuresDir path calculation (4 dirname levels) - mainGraphicalEditor: wrap template labels with t() for i18n Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
cf0233f193
commit
877f859f6b
14 changed files with 34 additions and 34 deletions
|
|
@ -413,7 +413,7 @@ def _buildSystemTemplates():
|
|||
"""Build the graph definitions for platform system templates."""
|
||||
return [
|
||||
{
|
||||
"label": "Personal Assistant: E-Mail-Antwort-Drafting",
|
||||
"label": t("Personal Assistant: E-Mail-Antwort-Drafting"),
|
||||
"mandateId": None,
|
||||
"featureInstanceId": None,
|
||||
"isTemplate": True,
|
||||
|
|
@ -442,7 +442,7 @@ def _buildSystemTemplates():
|
|||
"invocations": [{"type": "schedule", "cronExpression": "0 8 * * 1-5"}],
|
||||
},
|
||||
{
|
||||
"label": "Treuhand: PDF-Klassifizierung & Trustee-Import",
|
||||
"label": t("Treuhand: PDF-Klassifizierung & Trustee-Import"),
|
||||
"mandateId": None,
|
||||
"featureInstanceId": None,
|
||||
"isTemplate": True,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ def discoverMethods(serviceCenter):
|
|||
import os
|
||||
import glob as _glob
|
||||
featuresDir = os.path.join(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))),
|
||||
"features"
|
||||
)
|
||||
for wfInit in _glob.glob(os.path.join(featuresDir, "*", "workflows", "__init__.py")):
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ def resetAccountingBridgeCalls():
|
|||
def patchTrustee(monkeypatch, trusteeInterface):
|
||||
"""Patches ``getInterface`` + ``AccountingBridge`` in both action
|
||||
modules so the real action code runs against the in-memory fakes."""
|
||||
from modules.workflows.methods.methodTrustee.actions import (
|
||||
from modules.features.trustee.workflows.methodTrustee.actions import (
|
||||
processDocuments as _procMod,
|
||||
syncToAccounting as _syncMod,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import pyotp
|
|||
|
||||
from modules.auth.mfaService import (
|
||||
_generateSecret,
|
||||
_buildTotp,
|
||||
buildTotp,
|
||||
generateSetup,
|
||||
confirmSetup,
|
||||
verifyCode,
|
||||
|
|
@ -28,27 +28,27 @@ class TestTotpBasics:
|
|||
assert isinstance(secret, str)
|
||||
assert len(secret) >= 16
|
||||
|
||||
def test_buildTotp_generates_valid_code(self):
|
||||
def testbuildTotp_generates_valid_code(self):
|
||||
secret = _generateSecret()
|
||||
totp = _buildTotp(secret)
|
||||
totp = buildTotp(secret)
|
||||
code = totp.now()
|
||||
assert len(code) == 6
|
||||
assert code.isdigit()
|
||||
|
||||
def test_verifyCode_accepts_current_code(self):
|
||||
secret = _generateSecret()
|
||||
totp = _buildTotp(secret)
|
||||
totp = buildTotp(secret)
|
||||
code = totp.now()
|
||||
encrypted = f"FAKE_ENC:{secret}"
|
||||
|
||||
with patch("modules.auth.mfaService._decryptSecret", return_value=secret):
|
||||
with patch("modules.auth.mfaService.decryptSecret", return_value=secret):
|
||||
assert verifyCode(encrypted, code) is True
|
||||
|
||||
def test_verifyCode_rejects_wrong_code(self):
|
||||
secret = _generateSecret()
|
||||
encrypted = f"FAKE_ENC:{secret}"
|
||||
|
||||
with patch("modules.auth.mfaService._decryptSecret", return_value=secret):
|
||||
with patch("modules.auth.mfaService.decryptSecret", return_value=secret):
|
||||
assert verifyCode(encrypted, "000000") is False
|
||||
|
||||
|
||||
|
|
@ -66,19 +66,19 @@ class TestGenerateSetup:
|
|||
class TestConfirmSetup:
|
||||
def test_confirmSetup_with_valid_code(self):
|
||||
secret = _generateSecret()
|
||||
totp = _buildTotp(secret)
|
||||
totp = buildTotp(secret)
|
||||
code = totp.now()
|
||||
|
||||
with patch("modules.auth.mfaService._decryptSecret", return_value=secret):
|
||||
with patch("modules.auth.mfaService.decryptSecret", return_value=secret):
|
||||
assert confirmSetup("ENC", code) is True
|
||||
|
||||
def test_confirmSetup_with_invalid_code(self):
|
||||
secret = _generateSecret()
|
||||
with patch("modules.auth.mfaService._decryptSecret", return_value=secret):
|
||||
with patch("modules.auth.mfaService.decryptSecret", return_value=secret):
|
||||
assert confirmSetup("ENC", "999999") is False
|
||||
|
||||
def test_confirmSetup_handles_decryption_error(self):
|
||||
with patch("modules.auth.mfaService._decryptSecret", side_effect=Exception("decrypt error")):
|
||||
with patch("modules.auth.mfaService.decryptSecret", side_effect=Exception("decrypt error")):
|
||||
assert confirmSetup("BAD_ENC", "123456") is False
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ def _ensureOptionalDeps():
|
|||
|
||||
|
||||
_LIVE_METHODS = [
|
||||
("modules.workflows.methods.methodTrustee.methodTrustee", "MethodTrustee", "trustee"),
|
||||
("modules.features.trustee.workflows.methodTrustee.methodTrustee", "MethodTrustee", "trustee"),
|
||||
("modules.workflows.methods.methodRedmine.methodRedmine", "MethodRedmine", "redmine"),
|
||||
("modules.workflows.methods.methodSharepoint.methodSharepoint", "MethodSharepoint", "sharepoint"),
|
||||
("modules.workflows.methods.methodOutlook.methodOutlook", "MethodOutlook", "outlook"),
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from modules.workflows.methods._actionSignatureValidator import (
|
|||
_validateActionParameter,
|
||||
_validateActionsDict,
|
||||
_validateMethods,
|
||||
_validateTypeRef,
|
||||
validateTypeRef,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ class TestValidateTypeRef:
|
|||
"List[FeatureInstanceRef]",
|
||||
])
|
||||
def test_validTypes(self, t):
|
||||
assert _validateTypeRef(t) == []
|
||||
assert validateTypeRef(t) == []
|
||||
|
||||
@pytest.mark.parametrize("t", [
|
||||
"list", # too generic
|
||||
|
|
@ -86,7 +86,7 @@ class TestValidateTypeRef:
|
|||
"", # empty
|
||||
])
|
||||
def test_invalidTypes(self, t):
|
||||
errors = _validateTypeRef(t)
|
||||
errors = validateTypeRef(t)
|
||||
assert errors, f"expected validation errors for {t!r}"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from __future__ import annotations
|
|||
|
||||
import unittest
|
||||
|
||||
from modules.serviceCenter.services.serviceKnowledge import _costEstimate
|
||||
from modules.serviceCenter.services.serviceKnowledge import costEstimate as _costEstimate
|
||||
|
||||
|
||||
class TestCostEstimate(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from unittest.mock import AsyncMock, MagicMock
|
|||
|
||||
import pytest
|
||||
|
||||
from modules.shared import fkRegistry
|
||||
from modules.dbHelpers import fkRegistry
|
||||
from modules.serviceCenter.services.serviceAgent.datamodelAgent import (
|
||||
ToolCallRequest, ToolResult,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -626,15 +626,15 @@ class TestCascadeResetFdsRag(unittest.TestCase):
|
|||
|
||||
class TestPathNormalization(unittest.TestCase):
|
||||
def test_empty_path_normalises_to_root(self):
|
||||
self.assertEqual(_inheritFlags._normalisePath(""), "/")
|
||||
self.assertEqual(_inheritFlags._normalisePath(None), "/")
|
||||
self.assertEqual(_inheritFlags.normalisePath(""), "/")
|
||||
self.assertEqual(_inheritFlags.normalisePath(None), "/")
|
||||
|
||||
def test_trailing_slash_stripped(self):
|
||||
self.assertEqual(_inheritFlags._normalisePath("/foo/"), "/foo")
|
||||
self.assertEqual(_inheritFlags._normalisePath("/"), "/")
|
||||
self.assertEqual(_inheritFlags.normalisePath("/foo/"), "/foo")
|
||||
self.assertEqual(_inheritFlags.normalisePath("/"), "/")
|
||||
|
||||
def test_leading_slash_added(self):
|
||||
self.assertEqual(_inheritFlags._normalisePath("foo/bar"), "/foo/bar")
|
||||
self.assertEqual(_inheritFlags.normalisePath("foo/bar"), "/foo/bar")
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from __future__ import annotations
|
|||
|
||||
import pytest
|
||||
|
||||
from modules.shared import fkRegistry
|
||||
from modules.dbHelpers import fkRegistry
|
||||
from modules.serviceCenter.services.serviceAgent.datamodelOntology import (
|
||||
Constraint,
|
||||
ConstraintRule,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from __future__ import annotations
|
|||
|
||||
import unittest
|
||||
|
||||
from modules.serviceCenter.services.serviceKnowledge import _ragLimits
|
||||
from modules.serviceCenter.services.serviceKnowledge import ragLimits as _ragLimits
|
||||
|
||||
|
||||
class TestGetDefaults(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ from modules.serviceCenter.services.serviceAgent.ontologyToPromptCompiler import
|
|||
compileOntologyToPrompt,
|
||||
)
|
||||
from modules.serviceCenter.services.serviceAgent.queryValidator import QueryValidator
|
||||
from modules.shared import fkRegistry
|
||||
from modules.dbHelpers import fkRegistry
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from modules.serviceCenter.services.serviceKnowledge.udbNodes import (
|
|||
FdsWorkspaceNode,
|
||||
FdsTableNode,
|
||||
FdsFieldNode,
|
||||
_isFeatureAdmin,
|
||||
isFeatureAdmin,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -422,27 +422,27 @@ class TestIsFeatureAdmin(unittest.TestCase):
|
|||
def test_no_access_returns_false(self):
|
||||
rootIf = MagicMock()
|
||||
rootIf.getFeatureAccess.return_value = None
|
||||
self.assertFalse(_isFeatureAdmin(rootIf, "user-1", "fi1"))
|
||||
self.assertFalse(isFeatureAdmin(rootIf, "user-1", "fi1"))
|
||||
|
||||
def test_no_roles_returns_false(self):
|
||||
rootIf = MagicMock()
|
||||
rootIf.getFeatureAccess.return_value = MagicMock(id="acc1", enabled=True)
|
||||
rootIf.getRoleIdsForFeatureAccess.return_value = []
|
||||
self.assertFalse(_isFeatureAdmin(rootIf, "user-1", "fi1"))
|
||||
self.assertFalse(isFeatureAdmin(rootIf, "user-1", "fi1"))
|
||||
|
||||
def test_non_admin_role_returns_false(self):
|
||||
rootIf = MagicMock()
|
||||
rootIf.getFeatureAccess.return_value = MagicMock(id="acc1", enabled=True)
|
||||
rootIf.getRoleIdsForFeatureAccess.return_value = ["r1"]
|
||||
rootIf.db.getRecord.return_value = {"id": "r1", "roleLabel": "trustee-user"}
|
||||
self.assertFalse(_isFeatureAdmin(rootIf, "user-1", "fi1"))
|
||||
self.assertFalse(isFeatureAdmin(rootIf, "user-1", "fi1"))
|
||||
|
||||
def test_admin_role_returns_true(self):
|
||||
rootIf = MagicMock()
|
||||
rootIf.getFeatureAccess.return_value = MagicMock(id="acc1", enabled=True)
|
||||
rootIf.getRoleIdsForFeatureAccess.return_value = ["r1"]
|
||||
rootIf.db.getRecord.return_value = {"id": "r1", "roleLabel": "workspace-admin"}
|
||||
self.assertTrue(_isFeatureAdmin(rootIf, "user-1", "fi1"))
|
||||
self.assertTrue(isFeatureAdmin(rootIf, "user-1", "fi1"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import pytest
|
||||
|
||||
from modules.workflows.methods.methodTrustee.actions.queryData import (
|
||||
from modules.features.trustee.workflows.methodTrustee.actions.queryData import (
|
||||
_accountMatcher,
|
||||
_normalizeText,
|
||||
_parseFilterJson,
|
||||
|
|
|
|||
Loading…
Reference in a new issue