Coverage for mpcforces_extractor\datastructure\test_entities.py: 100%
29 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-06 21:34 +0100
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-06 21:34 +0100
1import unittest
2from mpcforces_extractor.datastructure.entities import Element1D, Node, Element
5class TestElement1D(unittest.TestCase):
6 def test_init(self):
7 """
8 Test the init method. Make sure all variables are set correctly (correct type)
9 """
11 # Test the init method
12 element = Element1D(
13 element_id=1,
14 property_id=1,
15 node1=0,
16 node2=1,
17 )
18 self.assertEqual(element.id, 1)
19 self.assertEqual(element.property_id, 1)
20 self.assertEqual(element.node1, 0)
21 self.assertEqual(element.node2, 1)
24class TestNode(unittest.TestCase):
25 def test_init(self):
26 """
27 Test the init method. Make sure all variables are set correctly (correct type)
28 """
30 # Test the init method
31 node = Node(
32 node_id=1,
33 coords=[0, 0, 0],
34 )
35 self.assertEqual(node.id, 1)
36 self.assertEqual(node.coords, [0, 0, 0])
38 def test_add_Element(self):
39 """
40 Test the add_element method. Make sure the element is added to the connected elements
41 """
43 # Test the add_element method
44 node = Node(
45 node_id=1,
46 coords=[0, 0, 0],
47 )
48 element = Element1D(
49 element_id=1,
50 property_id=1,
51 node1=0,
52 node2=1,
53 )
54 node.add_element(element)
55 self.assertEqual(node.connected_elements, [element])
58class TestElement(unittest.TestCase):
59 """
60 Test the Element class
61 """
63 def test_init(self):
64 """
65 Test the init method. Make sure all variables are set correctly (correct type)
66 """
68 # Nodes
69 node1 = Node(
70 node_id=1,
71 coords=[0, 0, 0],
72 )
73 node2 = Node(
74 node_id=2,
75 coords=[0, 0, 0],
76 )
77 node3 = Node(
78 node_id=3,
79 coords=[0, 0, 0],
80 )
81 nodes = [node1, node2, node3]
83 # Test the init method
84 element = Element(
85 element_id=1,
86 property_id=1,
87 nodes=nodes,
88 )
89 self.assertEqual(element.id, 1)
90 self.assertEqual(element.property_id, 1)
91 self.assertEqual(element.nodes, nodes)