Skip to content

Commit b66ee8c

Browse files
committed
WIP: integrating the python test full suite
1 parent b1cb450 commit b66ee8c

File tree

1 file changed

+80
-80
lines changed

1 file changed

+80
-80
lines changed

tests/integration_tests/pybinds_tests/test_pybind_units.py

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -49,86 +49,86 @@ def test_DFPointCloud_load_from_PLY():
4949
assert pc.normals.__len__() == 7379, "DFPointCloud should have 7379 normals"
5050
assert pc.colors.__len__() == 7379, "DFPointCloud should have 7379 colors"
5151

52-
# @pytest.fixture
53-
# def create_DFPointCloudSampleRoof():
54-
# df_pcd = dfb.dfb_geometry.DFPointCloud()
55-
# df_pcd.load_from_PLY(get_ply_cloud_roof_quarter_path())
56-
# yield df_pcd
57-
58-
# def test_DFPointCloud_properties(create_DFPointCloudSampleRoof):
59-
# pc = create_DFPointCloudSampleRoof
60-
# assert pc.points.__len__() == 7379, "DFPointCloud should have 7379 points"
61-
# assert pc.normals.__len__() == 7379, "DFPointCloud should have 7379 normals"
62-
# assert pc.colors.__len__() == 7379, "DFPointCloud should have 7379 colors"
63-
64-
# assert pc.get_num_points() == 7379, "get_num_points() should return 7379"
65-
# assert pc.get_num_normals() == 7379, "get_num_normals() should return 7379"
66-
# assert pc.get_num_colors() == 7379, "get_num_colors() should return 7379"
67-
68-
# assert pc.has_points() == True, "has_points() should return True"
69-
# assert pc.has_colors() == True, "has_colors() should return True"
70-
# assert pc.has_normals() == True, "has_normals() should return True"
71-
72-
# pc.points = []
73-
# pc.normals = []
74-
# pc.colors = []
75-
# assert pc.has_points() == False, "has_points() should return False"
76-
# assert pc.has_colors() == False, "has_colors() should return False"
77-
# assert pc.has_normals() == False, "has_normals() should return False"
78-
79-
# def test_DFPointCloud_apply_color(create_DFPointCloudSampleRoof):
80-
# pc = create_DFPointCloudSampleRoof
81-
# pc.apply_color(255, 0, 0)
82-
# for color in pc.colors:
83-
# assert (color[0] == 1 and color[1] == 0 and color[2] == 0), "All colors should be (255, 0, 0)"
84-
85-
# def test_DFPointCloud_voxel_func(create_DFPointCloudSampleRoof):
86-
# pc = create_DFPointCloudSampleRoof
87-
# pc.voxel_downsample(0.01)
88-
# assert pc.points.__len__() == 7256, "DFPointCloud should have 7256 points"
89-
# pc.uniform_downsample(3)
90-
# assert pc.points.__len__() == 2419, "DFPointCloud should have 2419 points"
91-
# pc.downsample_by_size(1000)
92-
# assert pc.points.__len__() == 1000, "DFPointCloud should have 1000 points"
93-
94-
# def test_DFPointCloud_compute_normals(create_DFPointCloudSampleRoof):
95-
# pc = create_DFPointCloudSampleRoof
96-
# pc.normals.clear()
97-
# pc.estimate_normals()
98-
# assert pc.normals.__len__() == 7379, "DFPointCloud should have 7379 normals"
99-
100-
# def test_DFPointCloud_get_tight_bounding_box(create_DFPointCloudSampleRoof):
101-
# pc = create_DFPointCloudSampleRoof
102-
# obb = pc.get_tight_bounding_box()
103-
# assert obb[0][0] == 0.1955558282162114, "The min x of the OBB should be 0.1955558282162114"
104-
105-
# # TODO: to implement DFMesh tests
106-
# def test_DFMesh_init():
107-
# pass
108-
109-
# #------------------------------------------------------------------------------
110-
# # dfb_transformation namespace
111-
# #------------------------------------------------------------------------------
112-
113-
# def test_DFTransform_init():
114-
# t = dfb.dfb_transformation.DFTransformation()
115-
# assert t is not None, "DFTransformation should be initialized successfully"
116-
117-
# def test_DFTransform_read_write(create_DFPointCloudSampleRoof):
118-
# pc = create_DFPointCloudSampleRoof
119-
# t = dfb.dfb_transformation.DFTransformation()
120-
121-
# matrix = t.transformation_matrix
122-
# print(matrix)
123-
# assert matrix is not None, "Transformation matrix should be initialized"
124-
125-
# matrix_identity = [[1.0, 0.0, 0.0, 0.0],
126-
# [0.0, 1.0, 0.0, 0.0],
127-
# [0.0, 0.0, 1.0, 0.0],
128-
# [0.0, 0.0, 0.0, 1.0]]
129-
130-
# t.transformation_matrix = matrix_identity
131-
# assert (t.transformation_matrix == matrix_identity).all(), "Transformation matrix should be set to identity"
52+
@pytest.fixture
53+
def create_DFPointCloudSampleRoof():
54+
df_pcd = dfb.dfb_geometry.DFPointCloud()
55+
df_pcd.load_from_PLY(get_ply_cloud_roof_quarter_path())
56+
yield df_pcd
57+
58+
def test_DFPointCloud_properties(create_DFPointCloudSampleRoof):
59+
pc = create_DFPointCloudSampleRoof
60+
assert pc.points.__len__() == 7379, "DFPointCloud should have 7379 points"
61+
assert pc.normals.__len__() == 7379, "DFPointCloud should have 7379 normals"
62+
assert pc.colors.__len__() == 7379, "DFPointCloud should have 7379 colors"
63+
64+
assert pc.get_num_points() == 7379, "get_num_points() should return 7379"
65+
assert pc.get_num_normals() == 7379, "get_num_normals() should return 7379"
66+
assert pc.get_num_colors() == 7379, "get_num_colors() should return 7379"
67+
68+
assert pc.has_points() == True, "has_points() should return True"
69+
assert pc.has_colors() == True, "has_colors() should return True"
70+
assert pc.has_normals() == True, "has_normals() should return True"
71+
72+
pc.points = []
73+
pc.normals = []
74+
pc.colors = []
75+
assert pc.has_points() == False, "has_points() should return False"
76+
assert pc.has_colors() == False, "has_colors() should return False"
77+
assert pc.has_normals() == False, "has_normals() should return False"
78+
79+
def test_DFPointCloud_apply_color(create_DFPointCloudSampleRoof):
80+
pc = create_DFPointCloudSampleRoof
81+
pc.apply_color(255, 0, 0)
82+
for color in pc.colors:
83+
assert (color[0] == 1 and color[1] == 0 and color[2] == 0), "All colors should be (255, 0, 0)"
84+
85+
def test_DFPointCloud_voxel_func(create_DFPointCloudSampleRoof):
86+
pc = create_DFPointCloudSampleRoof
87+
pc.voxel_downsample(0.01)
88+
assert pc.points.__len__() == 7256, "DFPointCloud should have 7256 points"
89+
pc.uniform_downsample(3)
90+
assert pc.points.__len__() == 2419, "DFPointCloud should have 2419 points"
91+
pc.downsample_by_size(1000)
92+
assert pc.points.__len__() == 1000, "DFPointCloud should have 1000 points"
93+
94+
def test_DFPointCloud_compute_normals(create_DFPointCloudSampleRoof):
95+
pc = create_DFPointCloudSampleRoof
96+
pc.normals.clear()
97+
pc.estimate_normals()
98+
assert pc.normals.__len__() == 7379, "DFPointCloud should have 7379 normals"
99+
100+
def test_DFPointCloud_get_tight_bounding_box(create_DFPointCloudSampleRoof):
101+
pc = create_DFPointCloudSampleRoof
102+
obb = pc.get_tight_bounding_box()
103+
assert obb[0][0] == 0.1955558282162114, "The min x of the OBB should be 0.1955558282162114"
104+
105+
# TODO: to implement DFMesh tests
106+
def test_DFMesh_init():
107+
pass
108+
109+
#------------------------------------------------------------------------------
110+
# dfb_transformation namespace
111+
#------------------------------------------------------------------------------
112+
113+
def test_DFTransform_init():
114+
t = dfb.dfb_transformation.DFTransformation()
115+
assert t is not None, "DFTransformation should be initialized successfully"
116+
117+
def test_DFTransform_read_write(create_DFPointCloudSampleRoof):
118+
pc = create_DFPointCloudSampleRoof
119+
t = dfb.dfb_transformation.DFTransformation()
120+
121+
matrix = t.transformation_matrix
122+
print(matrix)
123+
assert matrix is not None, "Transformation matrix should be initialized"
124+
125+
matrix_identity = [[1.0, 0.0, 0.0, 0.0],
126+
[0.0, 1.0, 0.0, 0.0],
127+
[0.0, 0.0, 1.0, 0.0],
128+
[0.0, 0.0, 0.0, 1.0]]
129+
130+
t.transformation_matrix = matrix_identity
131+
assert (t.transformation_matrix == matrix_identity).all(), "Transformation matrix should be set to identity"
132132

133133

134134
#------------------------------------------------------------------------------

0 commit comments

Comments
 (0)