mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4576 Python: Add tests to check for expected exceptions
This commit is contained in:
parent
7afeae144a
commit
071bb42101
@ -2,6 +2,7 @@ import sys
|
||||
import os
|
||||
import tempfile
|
||||
import pytest
|
||||
import grpc
|
||||
|
||||
sys.path.insert(1, os.path.join(sys.path[0], '../../'))
|
||||
import rips
|
||||
@ -49,4 +50,9 @@ def test_exportFlowCharacteristics(rips_instance, initializeTest):
|
||||
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
||||
print("Temporary folder: ", tmpdirname)
|
||||
fileName = tmpdirname + "/exportFlowChar.txt"
|
||||
rips_instance.commands.exportFlowCharacteristics(caseId=0, timeSteps=8, producers=[], injectors = "I01", fileName = fileName)
|
||||
rips_instance.commands.exportFlowCharacteristics(caseId=0, timeSteps=8, producers=[], injectors = "I01", fileName = fileName)
|
||||
|
||||
def test_loadNonExistingCase(rips_instance, initializeTest):
|
||||
casePath = "Nonsense/Nonsense/Nonsense"
|
||||
with pytest.raises(grpc.RpcError):
|
||||
assert rips_instance.project.loadCase(casePath)
|
||||
|
@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import os
|
||||
import grpc
|
||||
import pytest
|
||||
|
||||
sys.path.insert(1, os.path.join(sys.path[0], '../../'))
|
||||
@ -33,6 +34,32 @@ def test_10kSync(rips_instance, initializeTest):
|
||||
assert(average != pytest.approx(0.0158893, abs=0.0000001))
|
||||
assert(average == pytest.approx(0.0558893, abs=0.0000001))
|
||||
|
||||
def test_10k_set(rips_instance, initializeTest):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
|
||||
results = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', 1)
|
||||
case.properties.setActiveCellProperty(results, 'GENERATED', 'SOIL', 1)
|
||||
|
||||
def test_10k_set_out_of_bounds(rips_instance, initializeTest):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
|
||||
results = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', 1)
|
||||
results.append(5.0)
|
||||
with pytest.raises(grpc.RpcError):
|
||||
assert case.properties.setActiveCellProperty(results, 'GENERATED', 'SOIL', 1)
|
||||
|
||||
def test_10k_set_out_of_bounds_client(rips_instance, initializeTest):
|
||||
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||
case = rips_instance.project.loadCase(path=casePath)
|
||||
|
||||
results = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', 1)
|
||||
case.properties.chunkSize = len(results)
|
||||
results.append(5.0)
|
||||
with pytest.raises(IndexError):
|
||||
assert case.properties.setActiveCellProperty(results, 'GENERATED', 'SOIL', 1)
|
||||
|
||||
def createResult(poroChunks, permxChunks):
|
||||
for (poroChunk, permxChunk) in zip(poroChunks, permxChunks):
|
||||
resultChunk = []
|
||||
|
Loading…
Reference in New Issue
Block a user