Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
slayoo committed Jul 22, 2024
1 parent a9270ec commit 6221ccc
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/unit_tests/attributes/test_impl_attribute_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
""" checks the attribute registry logic mapping attribute names to classes implementing them
and handling different variants of these implementations picked depending on the choice of
dynamics and formulae options """

import pytest

from PySDM.attributes import Multiplicity
from PySDM.attributes.impl import get_attribute_class, register_attribute


class TestAttributeRegistry:
"""groups multiple tests to facilitate execution"""

@staticmethod
def test_get_attribute_class_ok():
"""checks if inquiring for a valid attribute name yields a valid class"""
assert get_attribute_class("multiplicity") is Multiplicity

@staticmethod
def test_get_attribute_class_fail():
"""checks if inquiring for an invalid attribute name raises an exception"""
with pytest.raises(ValueError):
assert get_attribute_class("lorem ipsum")

@staticmethod
def test_get_attribute_class_variant_fail():
"""checks if variant logic properly throws an exception if no variant match found"""

@register_attribute(name="umaminess", variant=lambda _, __: False)
class Umaminess: # pylint: disable=unused-variable,too-few-public-methods
"""Dummy class"""

with pytest.raises(AssertionError):
assert get_attribute_class("umaminess")

0 comments on commit 6221ccc

Please sign in to comment.