Skip to content

Commit

Permalink
Add even more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzBangar committed Nov 6, 2023
1 parent 043ab29 commit f79c69b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from classy_blocks.construct.operations.box import Box
from classy_blocks.construct.shapes.cylinder import Cylinder
from classy_blocks.construct.shapes.sphere import EighthSphere
from classy_blocks.lists.block_list import BlockList
from classy_blocks.lists.edge_list import EdgeList
from classy_blocks.lists.face_list import FaceList
Expand Down Expand Up @@ -236,6 +237,17 @@ def test_clear_mesh_block_list(self, klass):

mock_clear.assert_called()

def test_with_geometry(self):
esph = EighthSphere([0, 0, 0], [1, 0, 0], [0, 0, 1])
esph.chop_axial(count=10)
esph.chop_radial(count=10)
esph.chop_tangential(count=10)

self.mesh.add(esph)
self.mesh.assemble()

self.assertEqual(len(self.mesh.geometry_list.geometry), 1)

def test_backport(self):
box = Box([0, 0, 0], [1, 1, 1])
self.mesh.add(box)
Expand All @@ -245,3 +257,9 @@ def test_backport(self):
self.mesh.backport()

np.testing.assert_array_equal(box.point_array[0], [-1, -1, -1])

def test_backport_empty(self):
self.mesh.add(self.make_loft(0))

with self.assertRaises(RuntimeError):
self.mesh.backport()
Empty file added tests/test_optimize/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions tests/test_optimize/test_clamps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from classy_blocks.items.vertex import Vertex
from classy_blocks.modify.clamps.curve import CurveClamp, LineClamp, RadialClamp
from classy_blocks.modify.clamps.free import FreeClamp
from classy_blocks.modify.clamps.links import TranslationLink
from classy_blocks.modify.clamps.surface import ParametricSurfaceClamp, PlaneClamp
from classy_blocks.types import NPPointType
from classy_blocks.util import functions as f
Expand Down Expand Up @@ -37,6 +38,17 @@ def test_free_relaxation(self):

np.testing.assert_array_almost_equal(self.vertex.position, [0.5, 0, 0])

def test_linked(self):
clamp = FreeClamp(self.vertex)
follower = Vertex([1, 1, 1], 1)
link = TranslationLink(clamp.vertex, follower)
clamp.add_link(link)

self.assertTrue(clamp.is_linked)

def test_not_linked(self):
self.assertFalse(FreeClamp(self.vertex).is_linked)


class CurveClampTests(ClampTestsBase):
def setUp(self):
Expand Down

0 comments on commit f79c69b

Please sign in to comment.