Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samwaseda committed Jan 28, 2025
1 parent 8c99af9 commit 6f52c9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions semantikon/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,5 @@ def semantikon_class(cls: type):
setattr(cls, key, value) # Append type hints to attributes
except AttributeError:
pass
cls._is_semantikon_class = True
return cls
10 changes: 9 additions & 1 deletion tests/unit/test_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ def original_price(self):
@semantikon_class
@dataclass
class Output:
total_energy: u(float, units="eV", label="TotalEnergy", associate_to_sample=True)
total_energy: u(
float, units="eV", label="TotalEnergy", associate_to_sample=True
)


class TestDataclass(unittest.TestCase):

def test_is_semantikon_class(self):
self.assertTrue(hasattr(Pizza, "_is_semantikon_class"))
self.assertTrue(Pizza._is_semantikon_class)
self.assertTrue(hasattr(Pizza.Topping, "_is_semantikon_class"))
self.assertTrue(Pizza.Topping._is_semantikon_class)

def test_type(self):
self.assertEqual(Pizza.price, int)
self.assertEqual(Pizza.size, Annotated[float, "centimeter"])
Expand Down

0 comments on commit 6f52c9e

Please sign in to comment.