1 package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
4 import org.junit.runner.RunWith
5 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
7 import kotlin.test.assertNotNull
8 import org.springframework.beans.factory.annotation.Autowired
9 import org.springframework.test.context.ContextConfiguration
10 import org.springframework.test.context.TestPropertySource
11 import org.springframework.test.context.junit4.SpringRunner
12 import kotlin.test.BeforeTest
14 @RunWith(SpringRunner::class)
15 @ContextConfiguration(classes = [BluePrintPython::class, PythonExecutorProperty::class, String::class])
16 @TestPropertySource(properties =
17 ["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
18 "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"])
19 class BlueprintPythonInterpreterProxyTest {
21 lateinit var blueprintPythonInterpreterProxy: BlueprintPythonInterpreterProxy
24 lateinit var pythonExecutorProperty: PythonExecutorProperty
28 val blueprintBasePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
29 val pythonPath: MutableList<String> = arrayListOf()
30 pythonPath.add(blueprintBasePath)
31 pythonPath.addAll(pythonExecutorProperty.modulePaths)
32 val pythonClassName = "PythonTestScript"
33 val content = JacksonUtils.getContent("./src/test/resources/PythonTestScript.py")
35 val blueprintPython = BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf())
36 blueprintPython.content = content
37 blueprintPython.pythonClassName = pythonClassName
38 blueprintPython.moduleName = "Unit test - Blueprint Python Script [Class Name = $pythonClassName]"
40 blueprintPythonInterpreterProxy = BlueprintPythonInterpreterProxy(blueprintPython)
44 fun getPythonInterpreter() {
45 val pythonObject = blueprintPythonInterpreterProxy.getPythonInstance(hashMapOf())
46 assertNotNull(pythonObject, "failed to get python interpreter")