mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
First implementation with Asynchronous gRPC server, a few services and some client python code.
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
|
|
import os, sys
|
|
|
|
# Add the 'api' path to system path to be able to import modules from the 'api' folder
|
|
# python current working directory must be 'tests'
|
|
sys.path.insert(1, os.path.join(sys.path[0], '..\\api'))
|
|
|
|
import ResInsight
|
|
|
|
resInsight = ResInsight.Instance()
|
|
|
|
|
|
# content of test_sample.py
|
|
def getActiveCellCount(caseId):
|
|
activeCellInfoChunks = resInsight.gridInfo.streamActiveCellInfo(caseId)
|
|
|
|
receivedActiveCells = []
|
|
for activeCellChunk in activeCellInfoChunks:
|
|
for activeCell in activeCellChunk.data:
|
|
receivedActiveCells.append(activeCell)
|
|
return len(receivedActiveCells)
|
|
|
|
def myOpenProject(filepath):
|
|
resInsight = ResInsight.Instance()
|
|
#resInsight.commands.setMainWindowSize(width=800, height=500)
|
|
resInsight.commands.openProject(filepath)
|
|
|
|
def test_openProjectAndCountCells():
|
|
testRepositoryRoot = "d:\\gitroot-ceesol\\ResInsight-regression-test"
|
|
|
|
#casePath = testRepositoryRoot + "\\ModelData\\TEST10K_FLT_LGR_NNC\\TEST10K_FLT_LGR_NNC.EGRID"
|
|
#openEclipseCase(casePath)
|
|
|
|
# projectPath = testRepositoryRoot + "\\ProjectFiles\\ProjectFilesSmallTests\\TestCase_10K_Complete\\RegressionTest.rsp"
|
|
# projectPath = testRepositoryRoot + "\\ProjectFiles\\ProjectFilesSmallTests\\TestCase_Norne\\RegressionTest.rsp"
|
|
projectPath = testRepositoryRoot + "\\ProjectFiles\\ProjectFilesSmallTests\\TestCase_10K_Watertight\\RegressionTest.rsp"
|
|
myOpenProject(projectPath)
|
|
|
|
assert getActiveCellCount(0) == 11125
|
|
|
|
|
|
|
|
def test_openCaseAndCountCells():
|
|
testRepositoryRoot = "d:\\gitroot-ceesol\\ResInsight-regression-test"
|
|
|
|
casePath = testRepositoryRoot + "\\ModelData\\TEST10K_FLT_LGR_NNC\\TEST10K_FLT_LGR_NNC.EGRID"
|
|
resInsight.commands.loadCase(casePath)
|
|
|
|
assert getActiveCellCount(0) == 11125
|
|
|
|
resInsight.commands.closeProject()
|