ASP refactoring, sequence generation via clusterization

This commit is contained in:
Mark Voltov 2024-02-02 14:22:21 +00:00 committed by Igor Brylyov
parent d2ab856d64
commit fd59ab9e26
45 changed files with 1579 additions and 1267 deletions

View file

@ -0,0 +1,73 @@
import os
from helpers.background_console_colors import (
BackgroundConsoleColors,
)
from usecases.open_freecad_document_use_case import (
OpenFreeCadDocumentUseCase,
)
from usecases.read_file_system_and_get_instance_model_use_case import (
ReadFileSystemAndGetInstanceModelUseCase,
)
class FreeCadTest:
testName: str
"""Class for performing FreeCAD model checks
"""
def testHelper(self, testResult):
if isinstance(testResult, bool) is False:
print(
BackgroundConsoleColors.WARNING,
self.testName
+ " expected a value of type Boolean, returned a value of type below ",
)
print(testResult)
return
if testResult:
print(BackgroundConsoleColors.OKGREEN, self.testName + "is complete!")
else:
print(BackgroundConsoleColors.FAIL, self.testName + " is Error!")
pass
class FreeCadASPGenerationTestController(FreeCadTest):
testName: str
"""
FreeCAD Document Validation Controller
"""
def __init__(self, testName: str) -> None:
self.testName = testName
pass
def test(
self,
assertFn,
documentPath: str,
modelName: str,
model,
execComposition,
outPath=os.path.dirname(__file__) + "/out/",
):
try:
OpenFreeCadDocumentUseCase.call(documentPath).either(
leftF=lambda _: (
execComposition(""),
ReadFileSystemAndGetInstanceModelUseCase()
.call(model=model, path=outPath.replace("/helpers", "") + modelName)
.either(
leftF=lambda model: (
self.testHelper(
assertFn(model),
),
),
rightF=lambda error: print(error),
),
),
rightF=lambda error: print(error),
)
except Exception as inst:
print("FreeCadASPGenerationTestController error")
print(inst)
pass