Ejemplo n.º 1
0
    def test_compare_mesh_datasets_equal(self):
        # given
        mesh = Mesh(name="test")
        reference = Mesh(name="test")

        point_list = create_points_with_id()
        edge_list = create_edges()
        face_list = create_faces()
        cell_list = create_cells()

        data = DataContainer()

        mesh.add(point_list)
        mesh.add(edge_list)
        mesh.add(face_list)
        mesh.add(cell_list)

        reference.add(point_list)
        reference.add(edge_list)
        reference.add(face_list)
        reference.add(cell_list)

        mesh.data = data
        reference.data = data

        # this should pass without problems
        compare_mesh_datasets(mesh, reference, testcase=self)
Ejemplo n.º 2
0
    def test_compare_mesh_datasets_equal(self):
        # given
        mesh = Mesh(name="test")
        reference = Mesh(name="test")

        point_list = create_points_with_id()
        edge_list = create_edges()
        face_list = create_faces()
        cell_list = create_cells()

        data = DataContainer()

        mesh.add(point_list)
        mesh.add(edge_list)
        mesh.add(face_list)
        mesh.add(cell_list)

        reference.add(point_list)
        reference.add(edge_list)
        reference.add(face_list)
        reference.add(cell_list)

        mesh.data = data
        reference.data = data

        # this should pass without problems
        compare_mesh_datasets(mesh, reference, testcase=self)
Ejemplo n.º 3
0
 def test_create_points_with_id(self):
     points = create_points_with_id(n=10)
     self.assertEqual(len(points), 10)
     for index, point in enumerate(points):
         self.assertIsInstance(point, Point)
         self.assertIsNotNone(point.uid)
         self.assertEqual(
             point.coordinates, (index, index*10, index*100))
         compare_data_containers(
             point.data, create_data_container(),
             testcase=self)
Ejemplo n.º 4
0
 def test_create_points_with_id(self):
     points = create_points_with_id(n=10)
     self.assertEqual(len(points), 10)
     for index, point in enumerate(points):
         self.assertIsInstance(point, Point)
         self.assertIsNotNone(point.uid)
         self.assertEqual(point.coordinates,
                          (index, index * 10, index * 100))
         compare_data_containers(point.data,
                                 create_data_container(),
                                 testcase=self)
Ejemplo n.º 5
0
 def item_factory(self, n):
     """ Create and return the container object
     """
     return create_points_with_id(n=n)
Ejemplo n.º 6
0
    def test_compare_mesh_datasets_not_equal(self):
        # given
        mesh = Mesh(name="test")
        reference = Mesh(name="test_ref")

        point_list = create_particles_with_id()
        edge_list = create_edges()
        face_list = create_faces()
        cell_list = create_cells()

        data = create_data_container()

        mesh.add_points(point_list)
        mesh.add_edges(edge_list)
        mesh.add_faces(face_list)
        mesh.add_cells(cell_list)

        reference.add_points(point_list)
        reference.add_edges(edge_list)
        reference.add_faces(face_list)
        reference.add_cells(cell_list)

        mesh.data = data
        reference.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)

        # given
        test_points = create_points_with_id()

        mesh = Mesh(name=reference.name)

        mesh.add_points(test_points)
        mesh.add_edges(edge_list)
        mesh.add_faces(face_list)
        mesh.add_cells(cell_list)

        mesh.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)

        # given
        test_edges = create_edges()

        mesh = Mesh(name=reference.name)

        mesh.add_points(point_list)
        mesh.add_edges(test_edges)
        mesh.add_faces(face_list)
        mesh.add_cells(cell_list)

        mesh.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)

        # given
        test_faces = create_faces()

        mesh = Mesh(name=reference.name)

        mesh.add_points(point_list)
        mesh.add_edges(edge_list)
        mesh.add_faces(test_faces)
        mesh.add_cells(cell_list)

        mesh.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)

        # given
        test_cells = create_cells()

        mesh = Mesh(name=reference.name)

        mesh.add_points(point_list)
        mesh.add_edges(edge_list)
        mesh.add_faces(face_list)
        mesh.add_cells(test_cells)

        mesh.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)

        # given
        test_data = DataContainer()

        mesh = Mesh(name=reference.name)

        mesh.add_points(point_list)
        mesh.add_edges(edge_list)
        mesh.add_faces(face_list)
        mesh.add_cells(cell_list)

        mesh.data = test_data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)
Ejemplo n.º 7
0
 def item_factory(self, n):
     """ Create and return the container object
     """
     return create_points_with_id(n=n)
Ejemplo n.º 8
0
    def test_compare_mesh_datasets_not_equal(self):
        # given
        mesh = Mesh(name="test")
        reference = Mesh(name="test_ref")

        point_list = create_points_with_id()
        edge_list = create_edges()
        face_list = create_faces()
        cell_list = create_cells()

        data = create_data_container()

        mesh.add(point_list)
        mesh.add(edge_list)
        mesh.add(face_list)
        mesh.add(cell_list)

        reference.add(point_list)
        reference.add(edge_list)
        reference.add(face_list)
        reference.add(cell_list)

        mesh.data = data
        reference.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)

        # given
        test_points = create_points_with_id()

        mesh = Mesh(name=reference.name)

        mesh.add(test_points)
        mesh.add(edge_list)
        mesh.add(face_list)
        mesh.add(cell_list)

        mesh.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)

        # given
        test_edges = create_edges()

        mesh = Mesh(name=reference.name)

        mesh.add(point_list)
        mesh.add(test_edges)
        mesh.add(face_list)
        mesh.add(cell_list)

        mesh.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)

        # given
        test_faces = create_faces()

        mesh = Mesh(name=reference.name)

        mesh.add(point_list)
        mesh.add(edge_list)
        mesh.add(test_faces)
        mesh.add(cell_list)

        mesh.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)

        # given
        test_cells = create_cells()

        mesh = Mesh(name=reference.name)

        mesh.add(point_list)
        mesh.add(edge_list)
        mesh.add(face_list)
        mesh.add(test_cells)

        mesh.data = data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)

        # given
        test_data = DataContainer()

        mesh = Mesh(name=reference.name)

        mesh.add(point_list)
        mesh.add(edge_list)
        mesh.add(face_list)
        mesh.add(cell_list)

        mesh.data = test_data

        # when/then
        with self.assertRaises(AssertionError):
            compare_mesh_datasets(mesh, reference, testcase=self)