Skip to content

Commit

Permalink
Also mock preCICE dependency for unittests to avoid dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminRodenberg committed Jan 21, 2025
1 parent 6e8ece7 commit e9fbeb3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tests/unit/test_adapter_core.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from unittest.mock import MagicMock
from unittest.mock import MagicMock, patch
from unittest import TestCase
from tests import MockedPrecice
import numpy as np
from fenics import FunctionSpace, VectorFunctionSpace, UnitSquareMesh, SubDomain, near, vertices, Expression, interpolate


@patch.dict('sys.modules', {'precice': MockedPrecice})
class TestAdapterCore(TestCase):
def test_get_coupling_boundary_edges(self):
"""
Expand Down
11 changes: 9 additions & 2 deletions tests/unit/test_checkpointing.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from unittest.mock import MagicMock
from unittest.mock import MagicMock, patch
from unittest import TestCase
from tests import MockedPrecice
from fenics import FunctionSpace, UnitSquareMesh, Expression, interpolate
from fenicsprecice.solverstate import SolverState


@patch.dict('sys.modules', {'precice': MockedPrecice})
class TestCheckpointing(TestCase):
def test_solverstate_basic(self):
"""
Check if correct values are read from the checkpoint, while the state of the object that is copied is not changed
"""
from fenicsprecice.solverstate import SolverState

n = 1
size = 5
mesh = UnitSquareMesh(size, size)
Expand Down Expand Up @@ -37,6 +40,8 @@ def test_solverstate_modification_vector(self):
Motivation for this test: Related to https://github.com/precice/fenics-adapter/pull/172 and https://github.com/precice/tutorials/pull/554
"""
from fenicsprecice.solverstate import SolverState

n = 1
size = 5
mesh = UnitSquareMesh(size, size)
Expand Down Expand Up @@ -67,6 +72,8 @@ def test_solverstate_modification_assign(self):
Check if correct values are read from the checkpoint, if the dof of the dolfin functions are changed with the assign function
and not directly via the dof vector
"""
from fenicsprecice.solverstate import SolverState

n = 1
size = 5
mesh = UnitSquareMesh(size, size)
Expand Down

0 comments on commit e9fbeb3

Please sign in to comment.