import openmc
import openmc.lib
from openmc.stats import Box

import pytest
from tests.testing_harness import PyAPITestHarness

pytestmark = pytest.mark.skipif(
    not openmc.lib._dagmc_enabled(),
    reason="DAGMC CAD geometry is not enabled.")

class UWUWTest(PyAPITestHarness):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # settings
        self._model.settings.batches = 5
        self._model.settings.inactive = 0
        self._model.settings.particles = 100

        source = openmc.Source(space=Box([-4, -4, -4],
                                         [ 4,  4,  4]))
        self._model.settings.source = source

        # geometry
        dag_univ = openmc.DAGMCUniverse("dagmc.h5m")
        self._model.geometry = openmc.Geometry(root=dag_univ)

        # tally
        tally = openmc.Tally()
        tally.scores = ['total']
        tally.filters = [openmc.CellFilter(1)]
        self._model.tallies = [tally]


def test_uwuw():
    harness = UWUWTest('statepoint.5.h5', model=openmc.Model())
    harness.main()
