Closed ckoerber closed 4 years ago
I have added the ObjectParser
class in lattedb.utilities.tests
which simplifies the consistency check logic for tables. A example of how it is used is in lattedb.fermionaction.tests
:
from django.test import TestCase
from lattedb.utilities.tests import ObjectParser
from lattedb.linksmear.tests import UnsmearedTestCase
from lattedb.fermionaction.models import Hisq as HisqFermionAction
class HisqTestCase(ObjectParser, TestCase):
"""Tests for Hisq fermion action.
"""
model = HisqFermionAction
tree = {"linksmear": "Unsmeared"}
parameters = {
"quark_mass": "0.01",
"quark_tag": "light",
"naik": "1.23",
"linksmear": UnsmearedTestCase.parameters,
}
consistency_check_changes = [{"quark_tag": "not-light"}]
If you now run
pytest -k Hisq
in the repo root, this will run two tests:
HisqFermionAction
with the keywords provided in parameters
using the get_or_create_from_parameters
methodconsistency_check_changes
(a separate test for each entry in the list) and expects that a ConsitencyError
is raised.Note that this allows to also adjust parameters in in the FKs like {"linksmear.flow": 100}
.
I think we're done with this...
We should add more unittests to LatteDB