74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
![]() |
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
|