12ef9733a53c3501c1a8dc53ab0a77c29275e025
[ccsdk/cds.git] /
1 package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
2
3 import org.junit.Test
4 import org.junit.runner.RunWith
5 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
6
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
13
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 {
20
21     lateinit var blueprintPythonInterpreterProxy: BlueprintPythonInterpreterProxy
22
23     @Autowired
24     lateinit var pythonExecutorProperty: PythonExecutorProperty
25
26     @BeforeTest
27     fun init() {
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")
34
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]"
39
40         blueprintPythonInterpreterProxy = BlueprintPythonInterpreterProxy(blueprintPython)
41     }
42
43     @Test
44     fun getPythonInterpreter() {
45         val pythonObject = blueprintPythonInterpreterProxy.getPythonInstance(hashMapOf())
46         assertNotNull(pythonObject, "failed to get python interpreter")
47     }
48 }