Ejemplo n.º 1
0
    def test_init_domain(self):

        model = MicroBenthosModel(domain={})
        assert model.domain is None

        model = MicroBenthosModel(domain=DOMAIN_DEF)
        assert model.domain
        assert model.domain.cell_size == DOMAIN_DEF['init_params']['cell_size']
        with pytest.raises(RuntimeError):
            model.create_full_equation()

        # bad input
        with pytest.raises(ValueError):
            model = MicroBenthosModel(domain=3)
Ejemplo n.º 2
0
    def test_create_full_equation(self):

        model = MicroBenthosModel()
        with pytest.raises(RuntimeError):
            model.create_full_equation()

        Meqn = mock.MagicMock(ModelEquation)
        eqn = Meqn()
        model.equations['eqn'] = eqn
        model.equations['eqn2'] = eqn

        model.create_full_equation()
        eqn.obj.__and__.assert_called_once_with(eqn.obj)

        assert model.full_eqn is not None
        import operator
        import functools
        assert model.full_eqn == functools.reduce(
            operator.and_, [eqn.obj for eqn in (eqn, eqn)])