Skip to content

Commit

Permalink
added unittests for element.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaehring committed Jan 22, 2025
1 parent 37feab3 commit 40e0bab
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/unittests/test_element.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import unittest

from BPTK_Py import Model

from BPTK_Py.sddsl.element import Element

class TestElement(unittest.TestCase):
def setUp(self):
pass

def testElementInit(self):
model = Model()

element = Element(model=model,name="testElement",function_string=None)

self.assertEqual(element.model,model)
self.assertEqual(element.name,"testElement")
self.assertEqual(element.converters,[])
self.assertEqual(element._function_string,element.default_function_string())
self.assertIsNone(element._equation)

self.assertFalse(element.arrayed)
self.assertFalse(element.named_arrayed)

def testElement_add_arr_equation(self):
model = Model()

element = Element(model=model,name="testElement",function_string=None)

result = element.add_arr_equation(name="testName",value=1)

self.assertIsNone(result)

def testElement_add_arr_empty(self):
model = Model()

element = Element(model=model,name="testElement",function_string=None)

result = element.add_arr_empty(name="testName")

self.assertIsNone(result)

def testElement_get_arr_equation(self):
model = Model()

element = Element(model=model,name="testElement",function_string=None)

result = element.get_arr_equation(name="testName")

self.assertIsNone(result)

def testElement_get_item_unarrayed(self):
model = Model()

element = Element(model=model,name="testElement",function_string=None)

self.assertRaises(Exception,element.__getitem__,"testKey")

def testElement_set_item_unarrayed(self):
model = Model()

element = Element(model=model,name="testElement",function_string=None)

self.assertRaises(Exception,element.__setitem__,"testKey")

if __name__ == '__main__':
unittest.main()

0 comments on commit 40e0bab

Please sign in to comment.