Skip to content

Commit

Permalink
Drop unitest
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Nov 21, 2023
1 parent c3077c0 commit 21382bd
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 89 deletions.
81 changes: 0 additions & 81 deletions test/test_FMUPointToFieldFunction.py

This file was deleted.

57 changes: 57 additions & 0 deletions test/test_p2f.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python

import openturns as ot
import otfmi
import otfmi.example.deviation
import pytest


@pytest.fixture
def path_fmu():
"""Load FMU and setup pure python reference."""
return otfmi.example.utility.get_path_fmu("epid")


@pytest.fixture
def mesh():
return ot.RegularGrid(2.0, 0.5, 50)


def test_start_time_coherence(path_fmu, mesh):
"""Check if incoherent start time raises an error"""
with pytest.raises(AssertionError):
_ = otfmi.FMUPointToFieldFunction(mesh, path_fmu,
inputs_fmu=["infection_rate", "healing_rate"],
outputs_fmu=["infected"],
start_time=10)


def test_start_time(path_fmu, mesh):
"""Check if start times are taken into account."""
model_fmu_1 = otfmi.FMUPointToFieldFunction(
mesh,
path_fmu,
inputs_fmu=["infection_rate", "healing_rate"],
outputs_fmu=["infected"],
start_time=0,
)
model_fmu_2 = otfmi.FMUPointToFieldFunction(
mesh,
path_fmu,
inputs_fmu=["infection_rate", "healing_rate"],
outputs_fmu=["infected"],
start_time=1,
)
input_value = [0.007, 0.02]
y1 = model_fmu_1(input_value)
y2 = model_fmu_2(input_value)
assert y2[0][0] - y1[0][0] != 0


def test_final_time_coherence(path_fmu, mesh):
"""Check if incoherent final time raises an error."""
with pytest.raises(AssertionError):
_ = otfmi.FMUPointToFieldFunction(mesh, path_fmu,
inputs_fmu=["infection_rate", "healing_rate"],
outputs_fmu=["infected"],
final_time=10)
19 changes: 11 additions & 8 deletions test/test_pyfmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@

import otfmi.example.utility
import pyfmi
import pytest


def test_pyfmi_load_fmu():
@pytest.fixture
def model():
"""Load an fmu."""
path_fmu = otfmi.example.utility.get_path_fmu("deviation")
pyfmi.load_fmu(path_fmu)
model = pyfmi.load_fmu(path_fmu)
return model


def test_pyfmi_load(model):
pass

def test_pyfmi_simulate():

def test_pyfmi_simulate(model):
"""Simulate an fmu."""
path_fmu = otfmi.example.utility.get_path_fmu("deviation")
model = pyfmi.load_fmu(path_fmu)
model.simulate(options={"silent_mode": True})


def test_pyfmi_reset():
def test_pyfmi_reset(model):
"""Reset an fmu."""
path_fmu = otfmi.example.utility.get_path_fmu("deviation")
model = pyfmi.load_fmu(path_fmu)
model.simulate(options={"silent_mode": True})
model.reset()
model.simulate(options={"silent_mode": True})

0 comments on commit 21382bd

Please sign in to comment.