"""
Test harness for smp.py
"""
import sys
import os
sys.path.append('/Users/ptendick/open-source-workspace/cannr Image/source/cannr/lib')
os.environ['PATH'] = '/Library/Frameworks/Python.framework/Versions/3.7/bin:' + os.environ['PATH']

import cannr
import smp

# Test openProcess by opening a Flask process
def test_openProcess1():
    
    return smp.openProcess(
        {"processInfo": "processInfo"},
        ['python', '/Users/ptendick/open-source-workspace/cannr Image/test/flaskSample.py', '5000', '1'])

# Test openProcess by opening a Plumber process
def test_openProcess2():
    
    return smp.openProcess(
        {"processInfo": "processInfo"},
        ['Rscript', '--vanilla', '/Users/ptendick/open-source-workspace/cannr Image/source/cannr/runApp.R', 
            '/Users/ptendick/open-source-workspace/cannr Image/test/hello.R', '5001', '2'])

# Test countPorts
def test_countPorts():
    
    projectFilePath = '/Users/ptendick/open-source-workspace/MyRTAM Service/working/project1/project.json'
    project = cannr.readJSONFile(projectFilePath)
    
    return smp.countPorts(project)

[(6, 'sys.path.append', 'sys.path.append', False, 'import sys\n'), (15, 'smp.openProcess', 'smp.openProcess', False, 'import smp\n'), (22, 'smp.openProcess', 'smp.openProcess', False, 'import smp\n'), (31, 'cannr.readJSONFile', 'cannr.readJSONFile', False, 'import cannr\n'), (33, 'smp.countPorts', 'smp.countPorts', False, 'import smp\n')]