Example #1
0
def ITERATIVETEST_Variation_Of_Input_Parameter_inBins():
  """Tests variation of input value at field "inBins"."""
  Logging.infoHTML( "<b>ToDo: Add more \"TestData\" objects to maximize variations!</b>" )
  testDataVariations = {
    "Variation_1" : __getTestDataVariation1_inBins(),
  }
  return ( testDataVariations, executeTestOfUpdate )
Example #2
0
def ITERATIVETEST_Variation_Of_Input_Image_input0():
  """Tests variation of input image connected at field "input0"."""
  Logging.infoHTML( "<b>ToDo: Add more \"TestData\" objects to maximize variations!</b>" )
  testDataVariations = {
    "Variation_1" : __getTestDataVariation1_input0(),
  }
  return ( testDataVariations, executeTestOfUpdate )
Example #3
0
def ITERATIVETEST_Error_Of_Input_Image_input0():
  """Tests occurrence of an error because of an invalid image provided at field "input0"."""
  Logging.infoHTML( "<b>ToDo: Add more \"TestData\" objects to maximize variations!</b>" )
  testDataVariations = {
    "Missing_Object" : __getMissingObjectTestData_input0(),
  }
  return ( testDataVariations, testError_input0 )
Example #4
0
def execute(command, wait=True):
    returnCode = None
    Logging.info('Calling "' + command + '"')
    process = subprocess.Popen(command, shell=True, env={})
    if wait == True:
        returnCode = process.wait()
    return returnCode
def ITERATIVETEST_Variation_Of_Input_Base_inMidsagittalSurface():
  """Tests variation of input Base object connected at field "inMidsagittalSurface"."""
  Logging.infoHTML( "<b>ToDo: Add more \"TestData\" objects to maximize variations!</b>" )
  testDataVariations = {
    "Variation_1" : __getTestDataVariation1_inMidsagittalSurface(),
  }
  return ( testDataVariations, executeTestOfUpdate )
Example #6
0
def __getEmptyObjectTestData_inMidsagittalSurface():
    testData = __getDefaultTestData()
    Logging.infoHTML(
        "<b>ToDo: Replace \"None\" with a path pointing to an empty object!</b>"
    )
    testData.inMidsagittalSurfacePath = None
    return testData
def __getTestDataVariation1_inOptimizer():
    testData = __getDefaultTestData()
    Logging.infoHTML(
        "<b>ToDo: Replace \"None\" with reliable variation values!</b>")
    testData.inOptimizer = None
    testData.output0ReferencePath = None
    return testData
def ITERATIVETEST_Error_Of_Input_Base_inMidsagittalSurface():
  """Tests occurrence of an error because of an invalid Base object connected at field "inMidsagittalSurface"."""
  Logging.infoHTML( "<b>ToDo: Add more \"TestData\" objects to maximize variations!</b>" )
  testDataVariations = {
    "Missing_Object" : __getMissingObjectTestData_inMidsagittalSurface(),
    "Empty_Object" : __getEmptyObjectTestData_inMidsagittalSurface(),
  }
  return ( testDataVariations, testError_inMidsagittalSurface )
Example #9
0
def ITERATIVETEST_Error_Of_Input_Parameter_inBins():
  """Tests occurrence of an error because of an invalid input value provided at field "inBins"."""
  Logging.infoHTML( "<b>ToDo: Add more \"TestData\" objects to maximize variations!</b>" )
  testDataVariations = {
    "Invalid_Variation_1" : __getInvalidTestDataVariation1_inBins(),
    "Invalid_Variation_2" : __getInvalidTestDataVariation2_inBins(),
  }
  return ( testDataVariations, testError_inBins )
Example #10
0
def ITERATIVETEST_Variation_Of_Input_Base_inMidsagittalSurface():
    """Tests variation of input Base object connected at field "inMidsagittalSurface"."""
    Logging.infoHTML(
        "<b>ToDo: Add more \"TestData\" objects to maximize variations!</b>")
    testDataVariations = {
        "Variation_1": __getTestDataVariation1_inMidsagittalSurface(),
    }
    return (testDataVariations, executeTestOfUpdate)
Example #11
0
def ITERATIVETEST_Error_Of_Input_Base_inMidsagittalSurface():
    """Tests occurrence of an error because of an invalid Base object connected at field "inMidsagittalSurface"."""
    Logging.infoHTML(
        "<b>ToDo: Add more \"TestData\" objects to maximize variations!</b>")
    testDataVariations = {
        "Missing_Object": __getMissingObjectTestData_inMidsagittalSurface(),
        "Empty_Object": __getEmptyObjectTestData_inMidsagittalSurface(),
    }
    return (testDataVariations, testError_inMidsagittalSurface)
Example #12
0
def __getTestDataVariation1_inBins():
  testData = __getDefaultTestData()
  Logging.infoHTML( "<b>ToDo: Replace \"None\" with reliable variation values!</b>" )
  testData.inBins = None
  testData.output0ReferencePath = None
  testData.outPlane = None
  testData.outCMSPx = None
  testData.outLog = None
  return testData
def __getInvalidTestDataVariation2_inOptimizer():
    Logging.infoHTML(
        "<b>ToDo: Rename function that the name matches the intention of returned test data!</b>"
    )
    testData = __getDefaultTestData()
    Logging.infoHTML(
        "<b>ToDo: Replace \"None\" with a reliable invalid value of \"inOptimizer\"!</b>"
    )
    testData.inOptimizer = None
    return testData
Example #14
0
def __getDefaultTestData():
  """Returns a default and valid TestData object."""
  Logging.infoHTML( "<b>ToDo: Set valid values for default TestData object!</b>" )
  testData = TestData()
  testData.input0Path = None
  testData.inBins = None
  testData.output0ReferencePath = None
  testData.outPlane = None
  testData.outCMSPx = None
  testData.outLog = None
  return testData
Example #15
0
def __getChecksToValidateOutputAfterUpdate( testData ):
  checks = (
    AMChecks.ImageCompareCheck( "Validate_output0" ),
    AMChecks.FloatEqualCheck( fieldName = "{}.outPlane".format( MODULE_NAME ),
                              value = testData.outPlane,
                              epsilon = 0.0 ),
    AMChecks.EqualCheck( fieldName = "{}.outCMSPx".format( MODULE_NAME ),
                         value = testData.outCMSPx ),
    AMChecks.EqualCheck( fieldName = "{}.outLog".format( MODULE_NAME ),
                         value = testData.outLog ),
  )
  Logging.infoHTML( "<b>ToDo: Set up epsilon value of \"FloatEqualCheck\" objects!</b>" )
  return checks
def __getDefaultTestData():
  """Returns a default and valid TestData object."""
  Logging.infoHTML( "<b>ToDo: Set valid values for default TestData object!</b>" )
  testData = TestData()
  testData.input0Path = None
  testData.inMidsagittalSurfacePath = None
  testData.inIntersectionMode = None
  testData.inVolumeThreshold = None
  testData.inUseGlobalSubsample = None
  testData.inGlobalSubsample = None
  testData.inXSubsample = None
  testData.inYSubsample = None
  testData.inZSubsample = None
  testData.output0ReferencePath = None
  return testData
Example #17
0
def __getDefaultTestData():
    """Returns a default and valid TestData object."""
    Logging.infoHTML(
        "<b>ToDo: Set valid values for default TestData object!</b>")
    testData = TestData()
    testData.input0Path = None
    testData.inMidsagittalSurfacePath = None
    testData.inIntersectionMode = None
    testData.inVolumeThreshold = None
    testData.inUseGlobalSubsample = None
    testData.inGlobalSubsample = None
    testData.inXSubsample = None
    testData.inYSubsample = None
    testData.inZSubsample = None
    testData.output0ReferencePath = None
    return testData
def __getDefaultTestData():
  """Returns a default and valid TestData object."""
  Logging.infoHTML( "<b>ToDo: Set valid values for default TestData object!</b>" )
  testData = TestData()
  testData.input0Path = None
  testData.input1Path = None
  testData.inPlane1 = None
  testData.inPlane2 = None
  testData.inUseSecondPlane = None
  testData.inCMSPx = None
  testData.inBins = None
  testData.inGridSize = None
  testData.inMaxSize = None
  testData.inDelta = None
  testData.inEps = None
  testData.inOptimizer = None
  testData.output0ReferencePath = None
  return testData
def __getDefaultTestData():
    """Returns a default and valid TestData object."""
    Logging.infoHTML(
        "<b>ToDo: Set valid values for default TestData object!</b>")
    testData = TestData()
    testData.input0Path = None
    testData.input1Path = None
    testData.inPlane1 = None
    testData.inPlane2 = None
    testData.inUseSecondPlane = None
    testData.inCMSPx = None
    testData.inBins = None
    testData.inGridSize = None
    testData.inMaxSize = None
    testData.inDelta = None
    testData.inEps = None
    testData.inOptimizer = None
    testData.output0ReferencePath = None
    return testData
Example #20
0
def tearDownTestCase():
    if not mayRunTest():
        return

    Logging.info('Quitting OsiriX...')
    execute(
        '/usr/bin/osascript -e \'tell application id "com.rossetantoine.osirix" to quit\''
    )
    Logging.info('done.')

    if myTestDirPath:
        Logging.info('Removing OsiriX database parent folder...')
        execute('/bin/rm -fvr \'%s\'' % myTestDirPath)
        Logging.info('done.')

    return
Example #21
0
def setUpTestCase():
    global myctx, myTestDirPath

    if not mayRunTest():
        Logging.info('Test is not allowed to run')
        return

    if not socket.gethostname().startswith(('fritter-pc.', 'fritter-nb.')):
        Logging.info('Installing OsiriX plugin...')
        result = execute(
            '/usr/bin/rsync -av --delete \'%s/Applications/MeVisLab.app/Contents/Packages/FMEwork/ReleaseMeVis/bin/PlugIns/OsiriXMeVisLabBridge.osirixplugin\' \'%s/Library/Application Support/OsiriX/Plugins/\''
            % (os.path.expanduser('~'), os.path.expanduser('~')))
        Logging.info('done.')

        ASSERT_EQ(result, 0, 'Return code of rsync')
    else:
        Logging.info('Using already installed OsiriX plugin...')

    Logging.info('Creating OsiriX database parent folder...')
    # make sure we have exotic characters and spaces in the path
    myTestDirPath = tempfile.mkdtemp(prefix=u'Üä éẅ ')
    Logging.info(myTestDirPath)
    Logging.info('done.')

    Logging.info('Starting OsiriX...')
    result = execute(
        '/usr/bin/osascript -e \'tell application id "com.rossetantoine.osirix" to activate\''
    )
    Logging.info('done.')

    ASSERT_EQ(result, 0, 'Return code of osascript')

    Logging.info(
        'Initializing OsiriX database: OsiriX.OpenDB( {"path": "%s"} )' %
        myTestDirPath)
    t = OsiriXXMLRPCThread('''self.OsiriX.OpenDB( {"path": "''' +
                           myTestDirPath + '''"} )''')
    t.start()
    t.waitForFinished()
    Logging.info('Result: ' + str(t.result))

    ASSERT_EQ(int(t.result['error']), 0, 'Result of OpenDB')

    Logging.info('Loading test network...')
    myctx = MLAB.priv().loadNetworkFromFile(
        ctx.localPath() +
        '/OsiriXBridgeTest_manual.mlab').lookupModule('macro')
    Logging.info('done.')

    ASSERT_NE(myctx, 0, 'MeVisLab network context')

    return
Example #22
0
def tearDownTestCase ():
  if not mayRunTest():
    return
  
  Logging.info('Closing OsiriX database: OsiriX.CloseDB( {"path": "%s"} )' % myTestDirPath)
  t = OsiriXXMLRPCThread('''self.OsiriX.CloseDB( {"path": "''' + myTestDirPath + '''"} )''')
  t.start()
  t.waitForFinished()
  Logging.info('Result: ' + str(t.result))

  ASSERT_EQ(int(t.result['error']), 0, 'Result of CloseDB')
  
  Logging.info('Quitting OsiriX...')
  execute('/usr/bin/osascript -e \'tell application id "' + kAppBundleId + '" to quit\'')
  Logging.info('done.')
  
  if myTestDirPath:
    Logging.info('Removing OsiriX database parent folder...')
    execute('/bin/rm -fvr \'%s\'' % myTestDirPath)
    Logging.info('done.')
  
  return
Example #23
0
def TEST001_FilterChain():
    if not mayRunTest():
        return

    try:

        # Import test series
        localTestSeriesPath = os.path.join(
            MLAB.variable('TESTCENTER_EXTERNAL_DATA_FME'),
            'MeVisLabModules/Release/OsiriXBridge/Test_Patient/')
        result = execute(
            '/usr/bin/ditto \'%s\' \'%s/OsiriX Data/INCOMING.noindex/\'' %
            (localTestSeriesPath, myTestDirPath))

        ASSERT_EQ(result, 0, 'Return code of ditto')

        # Grant some time for receiving images
        for n in range(300):
            MLAB.processEvents()
            time.sleep(0.050)

        # Select test series
        Logging.info(
            'OsiriX.DBWindowFind( {"request": "(name LIKE \'*Test*\')", "table": "Study", "execute": "Select"} )'
        )
        t = OsiriXXMLRPCThread(
            '''self.OsiriX.DBWindowFind( {"request": "(name LIKE '*Test*')", "table": "Study", "execute": "Select"} )'''
        )
        t.start()
        t.waitForFinished()
        Logging.info('Result: ' + str(t.result))

        ASSERT_EQ(int(t.result['error']), 0, 'Result of DBWindowFind')
        ASSERT_EQ(int(t.result['elements'][0]['numberOfImages']), 64,
                  'Number of images in study')

        # Send selected series to MeVisLab
        Logging.info(
            'OsiriX.SendSelectedSeriesToMeVisLab( {"target": "TestTarget"} )')
        t = OsiriXXMLRPCThread(
            '''self.OsiriX.SendSelectedSeriesToMeVisLab( {"target": "TestTarget"} )'''
        )
        t.start()
        t.waitForFinished()
        Logging.info('Result: ' + str(t.result))

        ASSERT_EQ(int(t.result['error']), 0,
                  'Result of SendSelectedSeriesToMeVisLab')

        # Grant some time for receiving images
        for n in range(300):
            MLAB.processEvents()
            time.sleep(0.050)

        # Delete test series
        Logging.info(
            'OsiriX.DBWindowFind( {"request": "(name LIKE \'*Test*\')", "table": "Study", "execute": "Delete"} )'
        )
        t = OsiriXXMLRPCThread(
            '''self.OsiriX.DBWindowFind( {"request": "(name LIKE '*Test*')", "table": "Study", "execute": "Delete"} )'''
        )
        t.start()
        t.waitForFinished()
        Logging.info('Result: ' + str(t.result))

        ASSERT_EQ(int(t.result['error']), 0, 'Result of DBWindowFind')
        ASSERT_EQ(int(t.result['elements'][0]['numberOfImages']), 128,
                  'Number of images in study')

    except (xmlrpclib.Error, socket.error), err:
        print "ERROR", err
def __getDefaultTestData():
  """Returns a default and valid TestData object."""
  Logging.infoHTML( "<b>ToDo: Set valid values for default TestData object!</b>" )
  testData = TestData()
  return testData
def __getTestDataVariation1_inOptimizer():
  testData = __getDefaultTestData()
  Logging.infoHTML( "<b>ToDo: Replace \"None\" with reliable variation values!</b>" )
  testData.inOptimizer = None
  testData.output0ReferencePath = None
  return testData
Example #26
0
def TEST001_FilterChain ():
  if not mayRunTest():
    return
  
  try:

    # Check client id
    Logging.info('Checking reported client application bundle id...')
    appId = myctx.field('OsiriXBridge.clientAppBundleId').value
    Logging.info('Connected to %s' % (appId))
    Logging.info('done.')
    
    ASSERT_EQ(appId, kAppBundleId, 'Check for reported client id')
    
    # Import test series
    localTestSeriesPath = os.path.join(MLAB.variable('TESTCENTER_EXTERNAL_DATA_FME'), 'MeVisLabModules/Release/OsiriXBridge/Test_Patient/')
    result = execute('/usr/bin/ditto \'%s\' \'%s/%s/INCOMING.noindex/\'' % (localTestSeriesPath, myTestDirPath, kAppDBDirName))

    ASSERT_EQ(result, 0, 'Return code of ditto')

    # Grant some time for receiving images
    for _ in range(300):
      MLAB.processEvents()
      time.sleep(0.050)
    
    # Select test series
    Logging.info('OsiriX.DBWindowFind( {"request": "(name LIKE \'*Test*\')", "table": "Study", "execute": "Select"} )')
    t = OsiriXXMLRPCThread('''self.OsiriX.DBWindowFind( {"request": "(name LIKE '*Test*')", "table": "Study", "execute": "Select"} )''')
    t.start()
    t.waitForFinished()
    Logging.info('Result: ' + str(t.result))
    
    ASSERT_EQ(int(t.result['error']), 0, 'Result of DBWindowFind')
    ASSERT_EQ(int(t.result['elements'][0]['numberOfImages']), 64, 'Number of images in study')

    # Send selected series to MeVisLab
    Logging.info('OsiriX.SendSelectedSeriesToMeVisLab( {"target": "TestTarget"} )')
    t = OsiriXXMLRPCThread('''self.OsiriX.SendSelectedSeriesToMeVisLab( {"target": "TestTarget"} )''')
    t.start()
    t.waitForFinished()
    Logging.info('Result: ' + str(t.result))
    
    ASSERT_EQ(int(t.result['error']), 0, 'Result of SendSelectedSeriesToMeVisLab')
    
    # Grant some time for receiving images
    for _ in range(300):
      MLAB.processEvents()
      time.sleep(0.050)
      
    # Select complete series
    Logging.info('OsiriX.DBWindowFind( {"request": "(name LIKE \'*Test*\')", "table": "Study", "execute": "Select"} )')
    t = OsiriXXMLRPCThread('''self.OsiriX.DBWindowFind( {"request": "(name LIKE '*Test*')", "table": "Study", "execute": "Select"} )''')
    t.start()
    t.waitForFinished()
    Logging.info('Result: ' + str(t.result))
    
    ASSERT_EQ(int(t.result['error']), 0, 'Result of DBWindowFind')
    ASSERT_EQ(int(t.result['elements'][0]['numberOfImages']), 128, 'Number of images in study')

    # Delete test series
    Logging.info('OsiriX.DBWindowFind( {"request": "(name LIKE \'*Test*\')", "table": "Study", "execute": "Delete"} )')
    t = OsiriXXMLRPCThread('''self.OsiriX.DBWindowFind( {"request": "(name LIKE '*Test*')", "table": "Study", "execute": "Delete"} )''')
    t.start()
    t.waitForFinished()
    Logging.info('Result: ' + str(t.result))
    
    ASSERT_EQ(int(t.result['error']), 0, 'Result of DBWindowFind')

  except (xmlrpc.client.Error, socket.error) as err:
    print ("ERROR", err)
  return
def __getEmptyObjectTestData_inMidsagittalSurface():
  testData = __getDefaultTestData()
  Logging.infoHTML( "<b>ToDo: Replace \"None\" with a path pointing to an empty object!</b>" )
  testData.inMidsagittalSurfacePath = None
  return testData
def __getInvalidTestDataVariation2_inBins():
  Logging.infoHTML( "<b>ToDo: Rename function that the name matches the intention of returned test data!</b>" )
  testData = __getDefaultTestData()
  Logging.infoHTML( "<b>ToDo: Replace \"None\" with a reliable invalid value of \"inBins\"!</b>" )
  testData.inBins = None
  return testData